aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util-linux/fsck_minix.c20
-rw-r--r--util-linux/mkfs_minix.c25
2 files changed, 25 insertions, 20 deletions
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index 049bda4cc..4c486d08e 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -174,13 +174,16 @@ static char *zone_map;
174static unsigned char *inode_count; 174static unsigned char *inode_count;
175static unsigned char *zone_count; 175static unsigned char *zone_count;
176 176
177static int bit(char *a, unsigned i) 177static int bit(const char *a, unsigned i)
178{ 178{
179 return (a[i >> 3] & (1<<(i & 7))) != 0; 179 return (a[i >> 3] & (1<<(i & 7)));
180} 180}
181 181
182#define inode_in_use(x) (bit(inode_map,(x))) 182/* setbit/clrbit are supplied by sys/param.h */
183
184/* Note: do not assume 0/1, it is 0/nonzero */
183#define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1)) 185#define zone_in_use(x) (bit(zone_map,(x)-FIRSTZONE+1))
186#define inode_in_use(x) (bit(inode_map,(x)))
184 187
185#define mark_inode(x) (setbit(inode_map,(x)),changed=1) 188#define mark_inode(x) (setbit(inode_map,(x)),changed=1)
186#define unmark_inode(x) (clrbit(inode_map,(x)),changed=1) 189#define unmark_inode(x) (clrbit(inode_map,(x)),changed=1)
@@ -1109,7 +1112,8 @@ static void check_counts(void)
1109 } 1112 }
1110 if (Inode1[i].i_nlinks != inode_count[i]) { 1113 if (Inode1[i].i_nlinks != inode_count[i]) {
1111 printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ", 1114 printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ",
1112 i, Inode1[i].i_mode, Inode1[i].i_nlinks, inode_count[i]); 1115 i, Inode1[i].i_mode, Inode1[i].i_nlinks,
1116 inode_count[i]);
1113 if (ask("Set i_nlinks to count", 1)) { 1117 if (ask("Set i_nlinks to count", 1)) {
1114 Inode1[i].i_nlinks = inode_count[i]; 1118 Inode1[i].i_nlinks = inode_count[i];
1115 changed = 1; 1119 changed = 1;
@@ -1117,7 +1121,7 @@ static void check_counts(void)
1117 } 1121 }
1118 } 1122 }
1119 for (i = FIRSTZONE; i < ZONES; i++) { 1123 for (i = FIRSTZONE; i < ZONES; i++) {
1120 if (zone_in_use(i) == zone_count[i]) 1124 if ((zone_in_use(i) != 0) == zone_count[i])
1121 continue; 1125 continue;
1122 if (!zone_count[i]) { 1126 if (!zone_count[i]) {
1123 if (bad_zone(i)) 1127 if (bad_zone(i))
@@ -1160,8 +1164,8 @@ static void check_counts2(void)
1160 } 1164 }
1161 if (Inode2[i].i_nlinks != inode_count[i]) { 1165 if (Inode2[i].i_nlinks != inode_count[i]) {
1162 printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ", 1166 printf("Inode %d (mode=%07o), i_nlinks=%d, counted=%d. ",
1163 i, Inode2[i].i_mode, Inode2[i].i_nlinks, 1167 i, Inode2[i].i_mode, Inode2[i].i_nlinks,
1164 inode_count[i]); 1168 inode_count[i]);
1165 if (ask("Set i_nlinks to count", 1)) { 1169 if (ask("Set i_nlinks to count", 1)) {
1166 Inode2[i].i_nlinks = inode_count[i]; 1170 Inode2[i].i_nlinks = inode_count[i];
1167 changed = 1; 1171 changed = 1;
@@ -1169,7 +1173,7 @@ static void check_counts2(void)
1169 } 1173 }
1170 } 1174 }
1171 for (i = FIRSTZONE; i < ZONES; i++) { 1175 for (i = FIRSTZONE; i < ZONES; i++) {
1172 if (zone_in_use(i) == zone_count[i]) 1176 if ((zone_in_use(i) != 0) == zone_count[i])
1173 continue; 1177 continue;
1174 if (!zone_count[i]) { 1178 if (!zone_count[i]) {
1175 if (bad_zone(i)) 1179 if (bad_zone(i))
diff --git a/util-linux/mkfs_minix.c b/util-linux/mkfs_minix.c
index 7257ddb87..e214d288a 100644
--- a/util-linux/mkfs_minix.c
+++ b/util-linux/mkfs_minix.c
@@ -147,9 +147,11 @@ static int bit(const char* a, unsigned i)
147 return a[i >> 3] & (1<<(i & 7)); 147 return a[i >> 3] & (1<<(i & 7));
148} 148}
149 149
150/* setbit/clrbit are supplied by sys/param.h */
151
150/* Note: do not assume 0/1, it is 0/nonzero */ 152/* Note: do not assume 0/1, it is 0/nonzero */
151#define inode_in_use(x) bit(inode_map,(x))
152#define zone_in_use(x) bit(zone_map,(x)-SB_FIRSTZONE+1) 153#define zone_in_use(x) bit(zone_map,(x)-SB_FIRSTZONE+1)
154/*#define inode_in_use(x) bit(inode_map,(x))*/
153 155
154#define mark_inode(x) setbit(inode_map,(x)) 156#define mark_inode(x) setbit(inode_map,(x))
155#define unmark_inode(x) clrbit(inode_map,(x)) 157#define unmark_inode(x) clrbit(inode_map,(x))
@@ -507,11 +509,11 @@ static void setup_tables(void)
507 509
508/* 510/*
509 * Perform a test of a block; return the number of 511 * Perform a test of a block; return the number of
510 * blocks readable/writable. 512 * blocks readable.
511 */ 513 */
512static long do_check(char *buffer, int try, unsigned current_block) 514static size_t do_check(char *buffer, size_t try, unsigned current_block)
513{ 515{
514 long got; 516 ssize_t got;
515 517
516 /* Seek to the correct loc. */ 518 /* Seek to the correct loc. */
517 msg_eol = "seek failed during testing of blocks"; 519 msg_eol = "seek failed during testing of blocks";
@@ -522,11 +524,11 @@ static long do_check(char *buffer, int try, unsigned current_block)
522 got = read(dev_fd, buffer, try * BLOCK_SIZE); 524 got = read(dev_fd, buffer, try * BLOCK_SIZE);
523 if (got < 0) 525 if (got < 0)
524 got = 0; 526 got = 0;
525 if (got & (BLOCK_SIZE - 1)) { 527 try = ((size_t)got) / BLOCK_SIZE;
526 printf("Weird values in do_check: probably bugs\n"); 528
527 } 529 if (got & (BLOCK_SIZE - 1))
528 got /= BLOCK_SIZE; 530 fprintf(stderr, "Short read at block %u\n", current_block + try);
529 return got; 531 return try;
530} 532}
531 533
532static unsigned currently_testing; 534static unsigned currently_testing;
@@ -545,7 +547,7 @@ static void alarm_intr(int alnum)
545 547
546static void check_blocks(void) 548static void check_blocks(void)
547{ 549{
548 int try, got; 550 size_t try, got;
549 /* buffer[] was the biggest static in entire bbox */ 551 /* buffer[] was the biggest static in entire bbox */
550 char *buffer = xmalloc(BLOCK_SIZE * TEST_BUFFER_BLOCKS); 552 char *buffer = xmalloc(BLOCK_SIZE * TEST_BUFFER_BLOCKS);
551 553
@@ -620,8 +622,7 @@ int mkfs_minix_main(int argc, char **argv)
620#if ENABLE_FEATURE_MINIX2 622#if ENABLE_FEATURE_MINIX2
621 version2 = 1; 623 version2 = 1;
622#else 624#else
623 bb_error_msg_and_die("%s: not compiled with minix v2 support", 625 bb_error_msg_and_die("not compiled with minix v2 support");
624 device_name);
625#endif 626#endif
626 } 627 }
627 628