svn commit: trunk/busybox/util-linux

vda at busybox.net vda at busybox.net
Wed Nov 29 22:47:42 UTC 2006


Author: vda
Date: 2006-11-29 14:47:42 -0800 (Wed, 29 Nov 2006)
New Revision: 16735

Log:
another -90 bytes. That #define is **evil**


Modified:
   trunk/busybox/util-linux/mkfs_minix.c


Changeset:
Modified: trunk/busybox/util-linux/mkfs_minix.c
===================================================================
--- trunk/busybox/util-linux/mkfs_minix.c	2006-11-29 22:33:47 UTC (rev 16734)
+++ trunk/busybox/util-linux/mkfs_minix.c	2006-11-29 22:47:42 UTC (rev 16735)
@@ -503,8 +503,10 @@
 
 static void setup_tables(void)
 {
+	unsigned long inodes;
+	unsigned norm_firstzone;
+	uint16_t sb_zmaps;
 	int i;
-	unsigned long inodes;
 
 	memset(super_block_buffer, 0, BLOCK_SIZE);
 	memset(boot_block_buffer, 0, 512);
@@ -539,19 +541,21 @@
 	 * dd if=/dev/zero of=test.fs count=10 bs=1024
 	 * mkfs.minix -i 200 test.fs
 	 */
-	/* This code is not insane: NORM_FIRSTZONE is not a constant, */
-	/* it uses previous value of SB_ZMAPS inside */
+	/* This code is not insane: NORM_FIRSTZONE is not a constant,
+	 * it is calculated from SB_INODES, SB_IMAPS and SB_ZMAPS */
 	i = 999;
 	SB_ZMAPS = 0;
 	do {
-		uint16_t t = div_roundup(total_blocks - NORM_FIRSTZONE + 1, BITS_PER_BLOCK);
-		if (SB_ZMAPS == t) goto got_it;
-		SB_ZMAPS = t;
+		norm_firstzone = NORM_FIRSTZONE;
+		sb_zmaps = div_roundup(total_blocks - norm_firstzone + 1, BITS_PER_BLOCK);
+		if (SB_ZMAPS == sb_zmaps) goto got_it;
+		SB_ZMAPS = sb_zmaps;
+		/* new SB_ZMAPS, need to recalc NORM_FIRSTZONE */
 	} while (--i);
 	bb_error_msg_and_die("incompatible size/inode count, try different -i N");
  got_it:
 
-	SB_FIRSTZONE = NORM_FIRSTZONE;
+	SB_FIRSTZONE = norm_firstzone;
 	inode_map = xmalloc(SB_IMAPS * BLOCK_SIZE);
 	zone_map = xmalloc(SB_ZMAPS * BLOCK_SIZE);
 	memset(inode_map, 0xff, SB_IMAPS * BLOCK_SIZE);
@@ -563,7 +567,7 @@
 	inode_buffer = xzalloc(INODE_BUFFER_SIZE);
 	printf("%ld inodes\n", (long)SB_INODES);
 	printf("%ld blocks\n", (long)SB_ZONES);
-	printf("Firstdatazone=%ld (%ld)\n", (long)SB_FIRSTZONE, (long)NORM_FIRSTZONE);
+	printf("Firstdatazone=%ld (%ld)\n", (long)SB_FIRSTZONE, (long)norm_firstzone);
 	printf("Zonesize=%d\n", BLOCK_SIZE << SB_ZONE_SIZE);
 	printf("Maxsize=%ld\n", (long)SB_MAXSIZE);
 }




More information about the busybox-cvs mailing list