You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm attempting to open the file "/usr/lib/test.txt" on my ext4 filesystem, but receiving an error.
If I do _, err := filesystem.Open("/usr/lib/test.txt"), err is:
open usr/lib/test.txt: failed to read directory: read directory usr/lib/: failed to list directory entries inode(15336348): failed to get directory entries: failed to get extents: failed to get extents: failed to get extents: failed to read leaf node extent: unexpected EOF
Going through the code in the debugger, I believe I know what the problem is.
I can see that I get to a point where extentHeader.Entries is 50. The extent tree header itself is 12 bytes, and whether internal or leaf nodes of the extent tree, the entries are each 12 bytes. So the header + 50 entries is 612 bytes.
However, when reading the block to pass in to recursive calls to extents(), the buffer is always created to match the SectorSize, 512.
That is why when looping through the 50 entries, extents() is getting an EOF. It creates a byte reader around the 512 bytes it was called with, but it needs to be able to read 612 bytes of data.
I believe the read should be a full block, not just a sector of data. If I change the line b := make([]byte, SectorSize) to b := make([]byte, ext4.sb.GetBlockSize()), I no longer get the error.
The text was updated successfully, but these errors were encountered:
I'm attempting to open the file "/usr/lib/test.txt" on my ext4 filesystem, but receiving an error.
If I do
_, err := filesystem.Open("/usr/lib/test.txt")
, err is:open usr/lib/test.txt: failed to read directory: read directory usr/lib/: failed to list directory entries inode(15336348): failed to get directory entries: failed to get extents: failed to get extents: failed to get extents: failed to read leaf node extent: unexpected EOF
Going through the code in the debugger, I believe I know what the problem is.
In the extents() function
go-ext4-filesystem/ext4/ext4.go
Line 121 in ca14e63
I can see that I get to a point where
extentHeader.Entries
is 50. The extent tree header itself is 12 bytes, and whether internal or leaf nodes of the extent tree, the entries are each 12 bytes. So the header + 50 entries is 612 bytes.However, when reading the block to pass in to recursive calls to extents(), the buffer is always created to match the SectorSize, 512.
go-ext4-filesystem/ext4/ext4.go
Line 145 in ca14e63
That is why when looping through the 50 entries, extents() is getting an EOF. It creates a byte reader around the 512 bytes it was called with, but it needs to be able to read 612 bytes of data.
I believe the read should be a full block, not just a sector of data. If I change the line
b := make([]byte, SectorSize)
tob := make([]byte, ext4.sb.GetBlockSize())
, I no longer get the error.The text was updated successfully, but these errors were encountered: