mkfs_ext2: fix 60k image creation

Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
Denys Vlasenko 2009-10-20 16:21:29 +02:00
parent 95484c8706
commit cbeb452824
2 changed files with 7 additions and 16 deletions

View File

@ -88,13 +88,14 @@ static uint32_t div_roundup(uint64_t size, uint32_t n)
static void allocate(uint8_t *bitmap, uint32_t blocksize, uint32_t start, uint32_t end)
{
uint32_t i;
//bb_info_msg("ALLOC: [%u][%u][%u]: [%u-%u]:=[%x],[%x]", blocksize, start, end, start/8, blocksize - end/8 - 1, (1 << (start & 7)) - 1, (uint8_t)(0xFF00 >> (end & 7)));
memset(bitmap, 0, blocksize);
i = start / 8;
memset(bitmap, 0xFF, i);
bitmap[i] = 0xFF >> (8 - (start & 7));
//bb_info_msg("ALLOC: [%u][%u][%u]: [%u-%u]:=[%x],[%x]", blocksize, start, end, start/8, blocksize - end/8 - 1, 0xFF >> (8 - (start & 7)), (uint8_t)(0xFF << (8-(end&7))));
bitmap[i] = (1 << (start & 7)) - 1; //0..7 => 00000000..01111111
i = end / 8;
bitmap[blocksize - i - 1] = 0xFF << (8 - (end & 7));
bitmap[blocksize - i - 1] |= 0x7F00 >> (end & 7); //0..7 => 00000000..11111110
memset(bitmap + blocksize - i, 0xFF, i); // N.B. no overflow here!
}

View File

@ -38,22 +38,12 @@ test_mke2fs() {
}
}
# Should start from kilobytes=60, but e2fsck complains on it:
# e2fsck 1.41.4 (27-Jan-2009)
# Pass 1: Checking inodes, blocks, and sizes
# Pass 2: Checking directory structure
# Pass 3: Checking directory connectivity
# Pass 4: Checking reference counts
# Pass 5: Checking group summary information
# Inode bitmap differences: +(9--11)
# Free inodes count wrong for group #0 (5, counted=8).
# Directories count wrong for group #0 (2, counted=1).
# Free inodes count wrong (5, counted=8).
# image_bb: 11/16 files (0.0% non-contiguous), 9/60 blocks
kilobytes=68
# kilobytes=60 is the minimal allowed size
kilobytes=60
while true; do
test_mke2fs #|| exit 1
: $((kilobytes++))
test $kilobytes = 200 && break
done
exit