Merged
Conversation
Signed-off-by: Avi Deitcher <avi@deitcher.net>
586c007 to
b0befc4
Compare
Fix four bugs that caused ext4 images created with 2KB, 4KB, and 8KB block sizes to be rejected by e2fsck as corrupt: 1. superblock.go toBytes(): s_log_cluster_size was serialized as 0 for non-bigalloc filesystems. The ext4 spec encodes this as cluster_size = 2^(10 + s_log_cluster_size), and e2fsck validates s_log_block_size <= s_log_cluster_size. For non-bigalloc where cluster == block, s_log_cluster_size must equal s_log_block_size. 2. superblock.go superblockFromBytes(): clusterSize was read using Exp2(raw_value) instead of Exp2(10 + raw_value), producing clusterSize=1 for 1KB blocks instead of 1024. 3. ext4.go writeGDT(): GDT byte offset was calculated as block*blockSize + 1024 + 1024 (hardcoded boot sector + superblock), which placed the GDT at byte 2048 regardless of block size. For 4KB blocks, the GDT must be at byte 4096 (block 1). Now uses block- aligned positioning: primary at (firstDataBlock+1)*blockSize, backups at (block+1)*blockSize. 4. ext4.go Create(): blocksPerGroup defaulted to 8*blocksize with no upper cap. For 8KB blocks this gives 65536, exceeding the e2fsprogs limit EXT2_MAX_CLUSTERS_PER_GROUP = (1<<16)-8 = 65528 (constrained by the 16-bit bg_free_blocks_count field). Now capped at 65528. All block sizes (1KB, 2KB, 4KB, 8KB) now pass e2fsck validation. The skipE2fsck test workaround has been removed. Signed-off-by: Avi Deitcher <avi@deitcher.net>
b0befc4 to
f706ea8
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
And fix many issues