nerd2 / gexto

EXT2/EXT3/EXT4 Filesystem library for Golang
Apache License 2.0
41 stars 14 forks source link

Extent Traversal Logic #3

Open ayushr2 opened 5 years ago

ayushr2 commented 5 years ago

I think the implemented extent traversal logic is incorrect. This is not documented anywhere but ext4_extent_idx structs after the ext4_extent_header are sorted by the ei_block.

The current logic picks the ext4_extent_idx which satisfies ext4_extent_idx.ei_block < file_block_no but that will always choose the first ext4_extent_idx struct. This will lead to incorrect results for larger files.

The linux kernel implementation does a binary search: look at ext4_ext_binsearch_idx.