aboutsummaryrefslogtreecommitdiff
path: root/util-linux/mkfs_ext2.c
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2009-10-21 00:34:27 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2009-10-21 00:34:27 +0200
commit2288d86a54eee81800bdadea6f603ad4e234efb1 (patch)
tree0639a8d9a58b0e913fb4cf090a141154555231f4 /util-linux/mkfs_ext2.c
parent5e1dbd5bc3c609c73037a41546c5ead240821558 (diff)
downloadbusybox-w32-2288d86a54eee81800bdadea6f603ad4e234efb1.tar.gz
busybox-w32-2288d86a54eee81800bdadea6f603ad4e234efb1.tar.bz2
busybox-w32-2288d86a54eee81800bdadea6f603ad4e234efb1.zip
mkfs_ext2: explain why 0.5G+ images are a bit different
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
Diffstat (limited to 'util-linux/mkfs_ext2.c')
-rw-r--r--util-linux/mkfs_ext2.c15
1 files changed, 11 insertions, 4 deletions
diff --git a/util-linux/mkfs_ext2.c b/util-linux/mkfs_ext2.c
index be9e36332..de4c8b6c6 100644
--- a/util-linux/mkfs_ext2.c
+++ b/util-linux/mkfs_ext2.c
@@ -309,20 +309,23 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
309 309
310 { 310 {
311 // N.B. e2fsprogs does as follows! 311 // N.B. e2fsprogs does as follows!
312 // ninodes is the total number of inodes (files) in the file system
313 uint32_t ninodes = ((uint64_t) nblocks_full * blocksize) / bytes_per_inode;
314 uint32_t overhead, remainder; 312 uint32_t overhead, remainder;
313 // ninodes is the max number of inodes in this filesystem
314 uint32_t ninodes = ((uint64_t) nblocks_full * blocksize) / bytes_per_inode;
315 if (ninodes < EXT2_GOOD_OLD_FIRST_INO+1) 315 if (ninodes < EXT2_GOOD_OLD_FIRST_INO+1)
316 ninodes = EXT2_GOOD_OLD_FIRST_INO+1; 316 ninodes = EXT2_GOOD_OLD_FIRST_INO+1;
317 inodes_per_group = div_roundup(ninodes, ngroups); 317 inodes_per_group = div_roundup(ninodes, ngroups);
318 // minimum number because the first EXT2_GOOD_OLD_FIRST_INO-1 are reserved 318 // minimum number because the first EXT2_GOOD_OLD_FIRST_INO-1 are reserved
319 if (inodes_per_group < 16) 319 if (inodes_per_group < 16)
320 inodes_per_group = 16; 320 inodes_per_group = 16;
321 321 // a block group can't have more inodes than blocks
322 // a block group can have no more than 8*blocksize inodes
323 if (inodes_per_group > blocks_per_group) 322 if (inodes_per_group > blocks_per_group)
324 inodes_per_group = blocks_per_group; 323 inodes_per_group = blocks_per_group;
325 // adjust inodes per group so they completely fill the inode table blocks in the descriptor 324 // adjust inodes per group so they completely fill the inode table blocks in the descriptor
325//incompatibility on images >= 0.5GB:
326//difference in sizeof(*inode) sometimes
327//results in slightly bigger inodes_per_group here
328//compared to standard mke2fs:
326 inodes_per_group = (div_roundup(inodes_per_group * sizeof(*inode), blocksize) * blocksize) / sizeof(*inode); 329 inodes_per_group = (div_roundup(inodes_per_group * sizeof(*inode), blocksize) * blocksize) / sizeof(*inode);
327 // make sure the number of inodes per group is a multiple of 8 330 // make sure the number of inodes per group is a multiple of 8
328 inodes_per_group &= ~7; 331 inodes_per_group &= ~7;
@@ -345,6 +348,7 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
345 ////) { 348 ////) {
346 //// bb_error_msg_and_die("way small device"); 349 //// bb_error_msg_and_die("way small device");
347 ////} 350 ////}
351
348 // Standard mke2fs uses 50. Looks like a bug in our calculation 352 // Standard mke2fs uses 50. Looks like a bug in our calculation
349 // of "remainder" or "overhead" - we don't match standard mke2fs 353 // of "remainder" or "overhead" - we don't match standard mke2fs
350 // when we transition from one group to two groups 354 // when we transition from one group to two groups
@@ -414,6 +418,9 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
414 sb = xzalloc(1024); 418 sb = xzalloc(1024);
415 STORE_LE(sb->s_rev_level, 1); // revision 1 filesystem 419 STORE_LE(sb->s_rev_level, 1); // revision 1 filesystem
416 STORE_LE(sb->s_magic, EXT2_SUPER_MAGIC); 420 STORE_LE(sb->s_magic, EXT2_SUPER_MAGIC);
421//incompatibility:
422//on images > 0.5GB, standard mke2fs uses 256 byte inodes.
423//we always use 128 byte ones:
417 STORE_LE(sb->s_inode_size, sizeof(*inode)); 424 STORE_LE(sb->s_inode_size, sizeof(*inode));
418 STORE_LE(sb->s_first_ino, EXT2_GOOD_OLD_FIRST_INO); 425 STORE_LE(sb->s_first_ino, EXT2_GOOD_OLD_FIRST_INO);
419 STORE_LE(sb->s_log_block_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE); 426 STORE_LE(sb->s_log_block_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE);