masahiro331 / go-ext4-filesystem

Apache License 2.0
7 stars 10 forks source link

Error "failed to read inode: EOF" on small size filesystem #15

Open mappu opened 5 months ago

mappu commented 5 months ago

Hi, thanks for this project.

I have a small size ext4 filesystem image: volume.ext4.zip

It was created simply by mkfs -t ext4 with default options on a 128MB loopback device. It has the 64-bit feature flag.

When listing files, this library gives EOF looking for the inode (same as #5):

This same filesystem image can be loaded successfully with the https://github.com/dsoprea/go-ext4/ library.

Somehow the GetInodeTableLoc() returned a too high value, i'll compare it further.

mappu commented 5 months ago

I think the ext4.GroupDescriptor is parsed wrongly for this filesystem.

masahiro331/go-ext4-filesystem ``` In getInode() function inodeAddress=2 bgd=ext4.GroupDescriptor{ GroupDescriptor32:ext4.GroupDescriptor32{ BlockBitmapLo:0x8000, InodeBitmapLo:0x20000, InodeTableLo:0x1999, FreeBlocksCountLo:0x90f1, FreeInodesCountLo:0x1, UsedDirsCountLo:0x7fea, Flags:0x0, ExcludeBitmapLo:0x1, BlockBitmapCsumLo:0x0, InodeBitmapCsumLo:0x0, ItableUnusedLo:0x0, Checksum:0x0 }, BlockBitmapHi:0x2000, InodeBitmapHi:0x2000, InodeTableHi:0x800, FreeBlocksCountHi:0x2458, FreeInodesCountHi:0x6582, UsedDirsCountHi:0x2459, ItableUnusedHi:0x6582, ExcludeBitmapHi:0xffff0001, BlockBitmapCsumHi:0xef53, InodeBitmapCsumHi:0x1, Reserved:0x1 } ```
dsoprea/go-ext4 ``` GetWithAbsoluteInode(InodeRootDirectory) Dump() BgBlockBitmapHi: (0) BgBlockBitmapLo: (259) BgChecksum: [d0d4] BgFlags: (0) BgFreeBlocksCountHi: (0) BgFreeBlocksCountLo: (202) BgFreeInodesCountHi: (0) BgFreeInodesCountLo: (2027) BgInodeBitmapHi: (0) BgInodeBitmapLo: (275) BgInodeTableHi: (0) BgInodeTableLo: (291) BgItableUnusedHi: (0) BgItableUnusedLo: (2027) BgUsedDirsCountHi: (0) BgUsedDirsCountLo: (7) BgExcludeBitmapHi: (0) BgBlockBitmapCsumHi: (56393) BgInodeBitmapCsumHi: (31456) ```