Skip to content

Commit 6693615

Browse files
authoredMar 6, 2025··
squashfs: fix directory inode size (#286)
Due to SquashFS spec https://dr-emann.github.io/squashfs/squashfs.html#_directory_inodes Section 5.2, it says about directory inode file size ''' This value is 3 bytes larger than the real listing. The Linux kernel creates "." and ".." entries for offsets 0 and 1, and only after 3 looks into the listing, subtracting 3 from the size. ''' In go-disks the size is calculated by serialize the 'directory'. A directory serialization includes multiple 'directoryHeader's and 'directoryEntryRaw's. This aligns with the dir_size calculation logic with well-known squasjfs-tools project https://github.com/plougher/squashfs-tools/blob/master/squashfs-tools/mksquashfs.c#L1549 Note that the file_size is set to 3 larger than the size. Thus here, we set directoryLocation.size to 3 bytes larger and the new value will be used to set basicDirectory.fileSize. Fixes #285 Signed-off-by: Xynnn007 <[email protected]>
1 parent 9238e8f commit 6693615

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed
 

‎filesystem/squashfs/finalize.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -1448,7 +1448,7 @@ func populateDirectoryLocations(directories []*finalizeFileInfo) {
14481448
d.directoryLocation = blockPosition{
14491449
block: uint32(pos / int(metadataBlockSize)),
14501450
offset: uint16(pos % int(metadataBlockSize)),
1451-
size: len(b),
1451+
size: len(b) + 3,
14521452
}
14531453
pos += len(b)
14541454
}

0 commit comments

Comments
 (0)
Please sign in to comment.