diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-20 16:21:29 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2009-10-20 16:21:29 +0200 |
commit | cbeb4528247cca8eb1aa6c5d7e43778ea6de1762 (patch) | |
tree | d24754751af23bf00c864c668cfe481cc1217c42 | |
parent | 95484c870645ebda34c9202799f3b31111b90e4f (diff) | |
download | busybox-w32-cbeb4528247cca8eb1aa6c5d7e43778ea6de1762.tar.gz busybox-w32-cbeb4528247cca8eb1aa6c5d7e43778ea6de1762.tar.bz2 busybox-w32-cbeb4528247cca8eb1aa6c5d7e43778ea6de1762.zip |
mkfs_ext2: fix 60k image creation
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | util-linux/mkfs_ext2.c | 7 | ||||
-rwxr-xr-x | util-linux/mkfs_ext2_test.sh | 16 |
2 files changed, 7 insertions, 16 deletions
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c index da27dc77d..5d5429f07 100644 --- a/util-linux/mkfs_ext2.c +++ b/util-linux/mkfs_ext2.c | |||
@@ -88,13 +88,14 @@ static uint32_t div_roundup(uint64_t size, uint32_t n) | |||
88 | static void allocate(uint8_t *bitmap, uint32_t blocksize, uint32_t start, uint32_t end) | 88 | static void allocate(uint8_t *bitmap, uint32_t blocksize, uint32_t start, uint32_t end) |
89 | { | 89 | { |
90 | uint32_t i; | 90 | uint32_t i; |
91 | |||
92 | //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))); | ||
91 | memset(bitmap, 0, blocksize); | 93 | memset(bitmap, 0, blocksize); |
92 | i = start / 8; | 94 | i = start / 8; |
93 | memset(bitmap, 0xFF, i); | 95 | memset(bitmap, 0xFF, i); |
94 | bitmap[i] = 0xFF >> (8 - (start & 7)); | 96 | bitmap[i] = (1 << (start & 7)) - 1; //0..7 => 00000000..01111111 |
95 | //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)))); | ||
96 | i = end / 8; | 97 | i = end / 8; |
97 | bitmap[blocksize - i - 1] = 0xFF << (8 - (end & 7)); | 98 | bitmap[blocksize - i - 1] |= 0x7F00 >> (end & 7); //0..7 => 00000000..11111110 |
98 | memset(bitmap + blocksize - i, 0xFF, i); // N.B. no overflow here! | 99 | memset(bitmap + blocksize - i, 0xFF, i); // N.B. no overflow here! |
99 | } | 100 | } |
100 | 101 | ||
diff --git a/util-linux/mkfs_ext2_test.sh b/util-linux/mkfs_ext2_test.sh index 53f15d2c8..1199852fa 100755 --- a/util-linux/mkfs_ext2_test.sh +++ b/util-linux/mkfs_ext2_test.sh | |||
@@ -38,22 +38,12 @@ test_mke2fs() { | |||
38 | } | 38 | } |
39 | } | 39 | } |
40 | 40 | ||
41 | # Should start from kilobytes=60, but e2fsck complains on it: | 41 | # kilobytes=60 is the minimal allowed size |
42 | # e2fsck 1.41.4 (27-Jan-2009) | 42 | kilobytes=60 |
43 | # Pass 1: Checking inodes, blocks, and sizes | ||
44 | # Pass 2: Checking directory structure | ||
45 | # Pass 3: Checking directory connectivity | ||
46 | # Pass 4: Checking reference counts | ||
47 | # Pass 5: Checking group summary information | ||
48 | # Inode bitmap differences: +(9--11) | ||
49 | # Free inodes count wrong for group #0 (5, counted=8). | ||
50 | # Directories count wrong for group #0 (2, counted=1). | ||
51 | # Free inodes count wrong (5, counted=8). | ||
52 | # image_bb: 11/16 files (0.0% non-contiguous), 9/60 blocks | ||
53 | kilobytes=68 | ||
54 | while true; do | 43 | while true; do |
55 | test_mke2fs #|| exit 1 | 44 | test_mke2fs #|| exit 1 |
56 | : $((kilobytes++)) | 45 | : $((kilobytes++)) |
46 | test $kilobytes = 200 && break | ||
57 | done | 47 | done |
58 | exit | 48 | exit |
59 | 49 | ||