svn commit: trunk/busybox/util-linux

vda at busybox.net vda at busybox.net
Tue Feb 6 00:36:53 UTC 2007


Author: vda
Date: 2007-02-05 16:36:53 -0800 (Mon, 05 Feb 2007)
New Revision: 17783

Log:
minix utils: make a message easier to understand; small tweaks


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


Changeset:
Modified: trunk/busybox/util-linux/fsck_minix.c
===================================================================
--- trunk/busybox/util-linux/fsck_minix.c	2007-02-06 00:35:36 UTC (rev 17782)
+++ trunk/busybox/util-linux/fsck_minix.c	2007-02-06 00:36:53 UTC (rev 17783)
@@ -174,13 +174,16 @@
 static unsigned char *inode_count;
 static unsigned char *zone_count;
 
-static int bit(char *a, unsigned i)
+static int bit(const char *a, unsigned i)
 {
-	return (a[i >> 3] & (1<<(i & 7))) != 0;
+	return (a[i >> 3] & (1<<(i & 7)));
 }
 
+/* setbit/clrbit are supplied by sys/param.h */
+
+/* Note: do not assume 0/1, it is 0/nonzero */
+#define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1))
 #define inode_in_use(x) (bit(inode_map,(x)))
-#define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1))
 
 #define mark_inode(x) (setbit(inode_map,(x)),changed=1)
 #define unmark_inode(x) (clrbit(inode_map,(x)),changed=1)
@@ -1109,7 +1112,8 @@
 		}
 		if (Inode1[i].i_nlinks != inode_count[i]) {
 			printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ",
-				   i, Inode1[i].i_mode, Inode1[i].i_nlinks, inode_count[i]);
+				i, Inode1[i].i_mode, Inode1[i].i_nlinks,
+				inode_count[i]);
 			if (ask("Set i_nlinks to count", 1)) {
 				Inode1[i].i_nlinks = inode_count[i];
 				changed = 1;
@@ -1117,7 +1121,7 @@
 		}
 	}
 	for (i = FIRSTZONE; i < ZONES; i++) {
-		if (zone_in_use(i) == zone_count[i])
+		if ((zone_in_use(i) != 0) == zone_count[i])
 			continue;
 		if (!zone_count[i]) {
 			if (bad_zone(i))
@@ -1160,8 +1164,8 @@
 		}
 		if (Inode2[i].i_nlinks != inode_count[i]) {
 			printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ",
-				   i, Inode2[i].i_mode, Inode2[i].i_nlinks,
-				   inode_count[i]);
+				i, Inode2[i].i_mode, Inode2[i].i_nlinks,
+				inode_count[i]);
 			if (ask("Set i_nlinks to count", 1)) {
 				Inode2[i].i_nlinks = inode_count[i];
 				changed = 1;
@@ -1169,7 +1173,7 @@
 		}
 	}
 	for (i = FIRSTZONE; i < ZONES; i++) {
-		if (zone_in_use(i) == zone_count[i])
+		if ((zone_in_use(i) != 0) == zone_count[i])
 			continue;
 		if (!zone_count[i]) {
 			if (bad_zone(i))

Modified: trunk/busybox/util-linux/mkfs_minix.c
===================================================================
--- trunk/busybox/util-linux/mkfs_minix.c	2007-02-06 00:35:36 UTC (rev 17782)
+++ trunk/busybox/util-linux/mkfs_minix.c	2007-02-06 00:36:53 UTC (rev 17783)
@@ -147,9 +147,11 @@
 	  return a[i >> 3] & (1<<(i & 7));
 }
 
+/* setbit/clrbit are supplied by sys/param.h */
+
 /* Note: do not assume 0/1, it is 0/nonzero */
-#define inode_in_use(x) bit(inode_map,(x))
 #define zone_in_use(x)  bit(zone_map,(x)-SB_FIRSTZONE+1)
+/*#define inode_in_use(x) bit(inode_map,(x))*/
 
 #define mark_inode(x)   setbit(inode_map,(x))
 #define unmark_inode(x) clrbit(inode_map,(x))
@@ -507,11 +509,11 @@
 
 /*
  * Perform a test of a block; return the number of
- * blocks readable/writable.
+ * blocks readable.
  */
-static long do_check(char *buffer, int try, unsigned current_block)
+static size_t do_check(char *buffer, size_t try, unsigned current_block)
 {
-	long got;
+	ssize_t got;
 
 	/* Seek to the correct loc. */
 	msg_eol = "seek failed during testing of blocks";
@@ -522,11 +524,11 @@
 	got = read(dev_fd, buffer, try * BLOCK_SIZE);
 	if (got < 0)
 		got = 0;
-	if (got & (BLOCK_SIZE - 1)) {
-		printf("Weird values in do_check: probably bugs\n");
-	}
-	got /= BLOCK_SIZE;
-	return got;
+	try = ((size_t)got) / BLOCK_SIZE;
+
+	if (got & (BLOCK_SIZE - 1))
+		fprintf(stderr, "Short read at block %u\n", current_block + try);
+	return try;
 }
 
 static unsigned currently_testing;
@@ -545,7 +547,7 @@
 
 static void check_blocks(void)
 {
-	int try, got;
+	size_t try, got;
 	/* buffer[] was the biggest static in entire bbox */
 	char *buffer = xmalloc(BLOCK_SIZE * TEST_BUFFER_BLOCKS);
 
@@ -620,8 +622,7 @@
 #if ENABLE_FEATURE_MINIX2
 		version2 = 1;
 #else
-		bb_error_msg_and_die("%s: not compiled with minix v2 support",
-			device_name);
+		bb_error_msg_and_die("not compiled with minix v2 support");
 #endif
 	}
 




More information about the busybox-cvs mailing list