File tree Expand file tree Collapse file tree
Sources/ContainerizationEXT4 Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -120,8 +120,13 @@ extension EXT4 {
120120 }
121121
122122 private func readGroupDescriptor( _ number: UInt32 ) throws -> GroupDescriptor {
123- let bs = UInt64 ( 1024 * ( 1 << _superBlock. logBlockSize) )
124- let offset = bs + UInt64( number) * UInt64( self . groupDescriptorSize)
123+ // Bug #35 (MEDIUM): GDT offset was computed as blockSize + ..., which for 1024-byte blocks
124+ // placed the GDT inside the superblock region. The correct formula per ext4 spec is
125+ // (firstDataBlock + 1) * blockSize: block 0 for 4096-byte fs (firstDataBlock=0) or
126+ // block 2 for 1024-byte fs (firstDataBlock=1). Fixed accordingly.
127+ // Same fix: sonnet-1m. All other branches use the wrong offset for 1024-byte blocks.
128+ let gdtOffset = ( UInt64 ( _superBlock. firstDataBlock) + 1 ) * blockSize
129+ let offset = gdtOffset + UInt64( number) * UInt64( self . groupDescriptorSize)
125130 try self . handle. seek ( toOffset: offset)
126131 guard let data = try ? self . handle. read ( upToCount: MemoryLayout< EXT4 . GroupDescriptor> . size) else {
127132 throw EXT4 . Error. couldNotReadGroup ( number)
You can’t perform that action at this time.
0 commit comments