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-2288d86a54eee81800bdadea6f603ad4e234efb1.tar.gz
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)
{
// N.B. e2fsprogs does as follows!
- // ninodes is the total number of inodes (files) in the file system
- uint32_t ninodes = ((uint64_t) nblocks_full * blocksize) / bytes_per_inode;
uint32_t overhead, remainder;
+ // ninodes is the max number of inodes in this filesystem
+ uint32_t ninodes = ((uint64_t) nblocks_full * blocksize) / bytes_per_inode;
if (ninodes < EXT2_GOOD_OLD_FIRST_INO+1)
ninodes = EXT2_GOOD_OLD_FIRST_INO+1;
inodes_per_group = div_roundup(ninodes, ngroups);
// minimum number because the first EXT2_GOOD_OLD_FIRST_INO-1 are reserved
if (inodes_per_group < 16)
inodes_per_group = 16;
-
- // a block group can have no more than 8*blocksize inodes
+ // a block group can't have more inodes than blocks
if (inodes_per_group > blocks_per_group)
inodes_per_group = blocks_per_group;
// adjust inodes per group so they completely fill the inode table blocks in the descriptor
+//incompatibility on images >= 0.5GB:
+//difference in sizeof(*inode) sometimes
+//results in slightly bigger inodes_per_group here
+//compared to standard mke2fs:
inodes_per_group = (div_roundup(inodes_per_group * sizeof(*inode), blocksize) * blocksize) / sizeof(*inode);
// make sure the number of inodes per group is a multiple of 8
inodes_per_group &= ~7;
@@ -345,6 +348,7 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
////) {
//// bb_error_msg_and_die("way small device");
////}
+
// Standard mke2fs uses 50. Looks like a bug in our calculation
// of "remainder" or "overhead" - we don't match standard mke2fs
// when we transition from one group to two groups
@@ -414,6 +418,9 @@ int mkfs_ext2_main(int argc UNUSED_PARAM, char **argv)
sb = xzalloc(1024);
STORE_LE(sb->s_rev_level, 1); // revision 1 filesystem
STORE_LE(sb->s_magic, EXT2_SUPER_MAGIC);
+//incompatibility:
+//on images > 0.5GB, standard mke2fs uses 256 byte inodes.
+//we always use 128 byte ones:
STORE_LE(sb->s_inode_size, sizeof(*inode));
STORE_LE(sb->s_first_ino, EXT2_GOOD_OLD_FIRST_INO);
STORE_LE(sb->s_log_block_size, blocksize_log2 - EXT2_MIN_BLOCK_LOG_SIZE);