--- busybox.orig/util-linux/mkfs_ext2.c	Mon Oct 19 00:30:50 2009
+++ busybox/util-linux/mkfs_ext2.c	Mon Oct 19 02:16:30 2009
@@ -299,7 +299,8 @@
 	{
 		// N.B. e2fsprogs does as follows!
 		// ninodes is the total number of inodes (files) in the file system
-		uint32_t ninodes = nblocks_full / (blocksize >= 4096 ? 1 : 4096 / blocksize);
+		//uint32_t ninodes = nblocks_full / (blocksize >= 4096 ? 1 : 4096 / blocksize);
+		uint32_t ninodes = ((uint64_t) nblocks_full * blocksize) / bytes_per_inode;
 		uint32_t overhead, remainder;
 		if (ninodes < EXT2_GOOD_OLD_FIRST_INO+1)
 			ninodes = EXT2_GOOD_OLD_FIRST_INO+1;
@@ -317,12 +318,12 @@
 		inodes_per_group &= ~7;
 		itsz = div_roundup(inodes_per_group * sizeof(*inode), blocksize);
 
-		// the last block needs more attention: doesn't it too small for possible overhead?
+		// the last block needs more attention: isn't it too small for possible overhead?
 		overhead = (has_super(ngroups - 1) ? (1/*sb*/ + gdtsz) : 0) + 1/*bbmp*/ + 1/*ibmp*/ + itsz;
 		remainder = (nblocks - first_data_block) % blocks_per_group;
 		if ((1 == ngroups) && remainder && (remainder < overhead))
 			bb_error_msg_and_die("way small device");
-		if (remainder && (remainder < overhead + 50)) {
+		if (remainder && (remainder < overhead + 50/* e2fsprogs hardcoded */)) {
 //bb_info_msg("CHOP[%u]", remainder);
 			nblocks -= remainder;
 			goto retry;
@@ -461,11 +462,6 @@
 			STORE_LE(gd[i].bg_used_dirs_count, 2);
 			gd[i].bg_free_inodes_count -= EXT2_GOOD_OLD_FIRST_INO;
 		}
-//		// N.B. the following is pure heuristics!
-//		// Likely to cope with 1024-byte blocks, when first block is for boot sectors
-//		if (ngroups-1 == i) {
-//			n -= first_data_block;
-//		}
 
 		// mark preallocated blocks as allocated
 		fb = (n < blocks_per_group ? n : blocks_per_group) - overhead;
