anchor.diff:  (in-package :mezzano.ext4-file-system)
   
   ;; Compatible feature set flags.
  -(defconstant +compat-dir-prealloc+ #x1)
  -(defconstant +compat-imagic-inodes+ #x2)
  -(defconstant +compat-has-journal+ #x4)
  -(defconstant +compat-ext-attr+ #x8)
  -(defconstant +compat-resize-inode+ #x10)
  -(defconstant +compat-dir-index+ #x20)
  -(defconstant +compat-lazy-bg+ #x40)
  -(defconstant +compat-exclude-inode+ #x80)
  -(defconstant +compat-exclude-bitmap+ #x100)
  -(defconstant +compat-sparse-super2+ #x200)
  +(defconstant +compat-dir-prealloc+ 0)
  +(defconstant +compat-imagic-inodes+ 1)
  +(defconstant +compat-has-journal+ 2)
  +(defconstant +compat-ext-attr+ 3)
  +(defconstant +compat-resize-inode+ 4)
  +(defconstant +compat-dir-index+ 5)
  +(defconstant +compat-lazy-bg+ 6)
  +(defconstant +compat-exclude-inode+ 7)
  +(defconstant +compat-exclude-bitmap+ 8)
  +(defconstant +compat-sparse-super2+ 9)
   
   ;; Incompatible feature set.
  -(defconstant +incompat-compression+ #x1)
  -(defconstant +incompat-filetype+ #x2)
  -(defconstant +incompat-recover+ #x4)
  -(defconstant +incompat-journal-dev+ #x8)
  -(defconstant +incompat-meta-bg+ #x10)
  -(defconstant +incompat-extents+ #x40)
  -(defconstant +incompat-64bit+ #x80)
  -(defconstant +incompat-mmp+ #x100)
  -(defconstant +incompat-flex-bg+ #x200)
  -(defconstant +incompat-ea-inode+ #x400)
  -(defconstant +incompat-dirdata+ #x1000)
  -(defconstant +incompat-csum-seed+ #x2000)
  -(defconstant +incompat-largedir+ #x4000)
  -(defconstant +incompat-inline-data+ #x8000)
  -(defconstant +incompat-encrypt+ #x10000)
  +(defconstant +incompat-compression+ 0)
  +(defconstant +incompat-filetype+ 1)
  +(defconstant +incompat-recover+ 2)
  +(defconstant +incompat-journal-dev+ 3)
  +(defconstant +incompat-meta-bg+ 4)
  +(defconstant +incompat-extents+ 6)
  +(defconstant +incompat-64bit+ 7)
  +(defconstant +incompat-mmp+ 8)
  +(defconstant +incompat-flex-bg+ 9)
  +(defconstant +incompat-ea-inode+ 10)
  +(defconstant +incompat-dirdata+ 12)
  +(defconstant +incompat-csum-seed+ 13)
  +(defconstant +incompat-largedir+ 14)
  +(defconstant +incompat-inline-data+ 15)
  +(defconstant +incompat-encrypt+ 16)
   
   ;; Readonly-compatible feature set.
  -(defconstant +ro-compat-sparse-super+ #x1)
  -(defconstant +ro-compat-large-file+ #x2)
  -(defconstant +ro-compat-btree-dir+ #x4)
  -(defconstant +ro-compat-huge-file+ #x8)
  -(defconstant +ro-compat-gdt-csum+ #x10)
  -(defconstant +ro-compat-dir-nlink+ #x20)
  -(defconstant +ro-compat-extra-isize+ #x40)
  -(defconstant +ro-compat-has-snapshot+ #x80)
  -(defconstant +ro-compat-quota+ #x100)
  -(defconstant +ro-compat-bigalloc+ #x200)
  -(defconstant +ro-compat-metadata-csum+ #x400)
  -(defconstant +ro-compat-replica+ #x800)
  -(defconstant +ro-compat-readonly+ #x1000)
  -(defconstant +ro-compat-project+ #x2000)
  +(defconstant +ro-compat-sparse-super+ 0)
  +(defconstant +ro-compat-large-file+ 1)
  +(defconstant +ro-compat-btree-dir+ 2)
  +(defconstant +ro-compat-huge-file+ 3)
  +(defconstant +ro-compat-gdt-csum+ 4)
  +(defconstant +ro-compat-dir-nlink+ 5)
  +(defconstant +ro-compat-extra-isize+ 6)
  +(defconstant +ro-compat-has-snapshot+ 7)
  +(defconstant +ro-compat-quota+ 8)
  +(defconstant +ro-compat-bigalloc+ 9)
  +(defconstant +ro-compat-metadata-csum+ 10)
  +(defconstant +ro-compat-replica+ 11)
  +(defconstant +ro-compat-readonly+ 12)
  +(defconstant +ro-compat-project+ 13)
   
   ;; Inode flags
  -(defconstant +sync-flag+ #x8 "All writes to the file must be synchronous")
  -(defconstant +immutable-flag+ #x10 "File is immutable")
  -(defconstant +append-flag+ #x20 "File can only be appended")
  -(defconstant +noatime-flag+ #x80 "Do not update access time")
  -(defconstant +encrypt-flag+ #x800 "Encrypted inode")
  -(defconstant +hashed-indexes-flag+ #x1000 "Directory has hashed indexes")
  -(defconstant +imagic-flag+ #x2000 "AFS magic directory")
  -(defconstant +journal-data-flag+ #x4000 "File data must always be written through the journal")
  -(defconstant +notail-flag+ #x8000 "File tail should not be merged (not used by ext4)")
  -(defconstant +dirsync-flag+ #x10000 "All directory entry data should be written synchronously")
  -(defconstant +topdir-flag+ #x20000 "Top of directory hierarchy")
  -(defconstant +huge-file-flag+ #x40000 "This is a huge file")
  -(defconstant +extents-flag+ #x80000 "Inode uses extents")
  -(defconstant +ea-inode-flag+ #x200000 "Inode stores a large extended attribute value in its data blocks")
  -(defconstant +inline-data-flag+ #x10000000 "Inode has inline data")
  +(defconstant +sync-flag+ 3 "All writes to the file must be synchronous")
  +(defconstant +immutable-flag+ 4 "File is immutable")
  +(defconstant +append-flag+ 5 "File can only be appended")
  +(defconstant +noatime-flag+ 7 "Do not update access time")
  +(defconstant +encrypt-flag+ 11 "Encrypted inode")
  +(defconstant +hashed-indexes-flag+ 12 "Directory has hashed indexes")
  +(defconstant +imagic-flag+ 13 "AFS magic directory")
  +(defconstant +journal-data-flag+ 14 "File data must always be written through the journal")
  +(defconstant +notail-flag+ 15 "File tail should not be merged (not used by ext4)")
  +(defconstant +dirsync-flag+ 16 "All directory entry data should be written synchronously")
  +(defconstant +topdir-flag+ 17 "Top of directory hierarchy")
  +(defconstant +huge-file-flag+ 18 "This is a huge file")
  +(defconstant +extents-flag+ 19 "Inode uses extents")
  +(defconstant +ea-inode-flag+ 21 "Inode stores a large extended attribute value in its data blocks")
  +(defconstant +inline-data-flag+ 28 "Inode has inline data")
   
   ;; Directory file types
   (defconstant +unknown-type+ #x0)
  
positive.code: (defun read-extent (inode-block offset)
    (let ((length (sys.int::ub16ref/le inode-block (+ 4 offset))))
      (when (> length 32768)
        (error "Uninitialized extent not suported"))
      (make-extent :n-block (sys.int::ub16ref/le inode-block offset)
                   :length length
  
negative.code:                     (collecting (read-block-group-descriptor superblock block offset)))))
  
  (defun read-block-bitmap (disk superblock bgds)
    (let ((n-blocks (if (logbitp +incompat-flex-bg+ (superblock-feature-incompat superblock))
                        (expt 2 (superblock-log-groups-per-flex superblock)) 1)))
      (read-block disk superblock (block-group-descriptor-block-bitmap bgds) n-blocks)))
  
  (defun read-inode-bitmap (disk superblock bgds)
    (let ((n-blocks (if (logbitp +incompat-flex-bg+ (superblock-feature-incompat superblock))
                        (expt 2 (superblock-log-groups-per-flex superblock)) 1)))
      (read-block disk superblock (block-group-descriptor-inode-bitmap bgds) n-blocks)))
  
  (defstruct inode
  