aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--util-linux/fsck_minix.c167
1 files changed, 74 insertions, 93 deletions
diff --git a/util-linux/fsck_minix.c b/util-linux/fsck_minix.c
index 350c95786..b90ccc5e3 100644
--- a/util-linux/fsck_minix.c
+++ b/util-linux/fsck_minix.c
@@ -206,28 +206,26 @@ enum { ROOT_INO = 1 };
206#define BITS_PER_BLOCK (BLOCK_SIZE<<3) 206#define BITS_PER_BLOCK (BLOCK_SIZE<<3)
207 207
208static char *program_version = "1.2 - 11/11/96"; 208static char *program_version = "1.2 - 11/11/96";
209static char *device_name = NULL; 209static char *device_name;
210static int IN; 210static int IN;
211static int repair = 0, automatic = 0, verbose = 0, list = 0, show = 211static int repair, automatic, verbose, list, show, warn_mode, force;
212 0, warn_mode = 0, force = 0; 212static int directory, regular, blockdev, chardev, links, symlinks, total;
213static int directory = 0, regular = 0, blockdev = 0, chardev = 0, links =
214 0, symlinks = 0, total = 0;
215 213
216static int changed = 0; /* flags if the filesystem has been changed */ 214static int changed; /* flags if the filesystem has been changed */
217static int errors_uncorrected = 0; /* flag if some error was not corrected */ 215static int errors_uncorrected; /* flag if some error was not corrected */
218static int dirsize = 16; 216static int dirsize = 16;
219static int namelen = 14; 217static int namelen = 14;
220static int version2 = 0; 218static int version2;
221static struct termios termios; 219static struct termios termios;
222static int termios_set = 0; 220static int termios_set;
223 221
224/* File-name data */ 222/* File-name data */
225enum { MAX_DEPTH = 32 }; 223enum { MAX_DEPTH = 32 };
226static int name_depth = 0; 224static int name_depth;
227// static char name_list[MAX_DEPTH][BUFSIZ + 1]; 225// static char name_list[MAX_DEPTH][BUFSIZ + 1];
228static char **name_list = NULL; 226static char **name_list;
229 227
230static char *inode_buffer = NULL; 228static char *inode_buffer;
231 229
232#define Inode (((struct minix_inode *) inode_buffer)-1) 230#define Inode (((struct minix_inode *) inode_buffer)-1)
233#define Inode2 (((struct minix2_inode *) inode_buffer)-1) 231#define Inode2 (((struct minix2_inode *) inode_buffer)-1)
@@ -251,8 +249,8 @@ static char super_block_buffer[BLOCK_SIZE];
251static char *inode_map; 249static char *inode_map;
252static char *zone_map; 250static char *zone_map;
253 251
254static unsigned char *inode_count = NULL; 252static unsigned char *inode_count;
255static unsigned char *zone_count = NULL; 253static unsigned char *zone_count;
256 254
257static void recursive_check(unsigned int ino); 255static void recursive_check(unsigned int ino);
258#ifdef CONFIG_FEATURE_MINIX2 256#ifdef CONFIG_FEATURE_MINIX2
@@ -375,12 +373,11 @@ static void check_mount(void)
375 close(fd); 373 close(fd);
376 374
377 printf("%s is mounted. ", device_name); 375 printf("%s is mounted. ", device_name);
376 cont = 0;
378 if (isatty(0) && isatty(1)) 377 if (isatty(0) && isatty(1))
379 cont = ask("Do you really want to continue", 0); 378 cont = ask("Do you really want to continue", 0);
380 else
381 cont = 0;
382 if (!cont) { 379 if (!cont) {
383 printf("check aborted.\n"); 380 printf("Check aborted\n");
384 exit(0); 381 exit(0);
385 } 382 }
386 return; 383 return;
@@ -392,7 +389,7 @@ static void check_mount(void)
392 * if an error was corrected, and returns the zone (0 for no zone 389 * if an error was corrected, and returns the zone (0 for no zone
393 * or a bad zone-number). 390 * or a bad zone-number).
394 */ 391 */
395static int check_zone_nr(unsigned short *nr, int *corrected) 392static int check_zone_nr2(uint32_t *nr, int *corrected)
396{ 393{
397 if (!*nr) 394 if (!*nr)
398 return 0; 395 return 0;
@@ -411,26 +408,13 @@ static int check_zone_nr(unsigned short *nr, int *corrected)
411 return 0; 408 return 0;
412} 409}
413 410
414#ifdef CONFIG_FEATURE_MINIX2 411static int check_zone_nr(uint16_t *nr, int *corrected)
415static int check_zone_nr2(unsigned int *nr, int *corrected)
416{ 412{
417 if (!*nr) 413 uint32_t nr32 = *nr;
418 return 0; 414 int r = check_zone_nr2(&nr32, corrected);
419 if (*nr < FIRSTZONE) 415 *nr = (uint16_t)nr32;
420 printf("Zone nr < FIRSTZONE in file `"); 416 return r;
421 else if (*nr >= ZONES)
422 printf("Zone nr >= ZONES in file `");
423 else
424 return *nr;
425 print_current_name();
426 printf("'.");
427 if (ask("Remove block", 1)) {
428 *nr = 0;
429 *corrected = 1;
430 }
431 return 0;
432} 417}
433#endif
434 418
435/* 419/*
436 * read-block reads block nr into the buffer at addr. 420 * read-block reads block nr into the buffer at addr.
@@ -445,14 +429,14 @@ static void read_block(unsigned int nr, char *addr)
445 printf("Read error: unable to seek to block in file '"); 429 printf("Read error: unable to seek to block in file '");
446 print_current_name(); 430 print_current_name();
447 printf("'\n"); 431 printf("'\n");
448 memset(addr, 0, BLOCK_SIZE);
449 errors_uncorrected = 1; 432 errors_uncorrected = 1;
433 memset(addr, 0, BLOCK_SIZE);
450 } else if (BLOCK_SIZE != read(IN, addr, BLOCK_SIZE)) { 434 } else if (BLOCK_SIZE != read(IN, addr, BLOCK_SIZE)) {
451 printf("Read error: bad block in file '"); 435 printf("Read error: bad block in file '");
452 print_current_name(); 436 print_current_name();
453 printf("'\n"); 437 printf("'\n");
454 memset(addr, 0, BLOCK_SIZE);
455 errors_uncorrected = 1; 438 errors_uncorrected = 1;
439 memset(addr, 0, BLOCK_SIZE);
456 } 440 }
457} 441}
458 442
@@ -480,14 +464,14 @@ static void write_block(unsigned int nr, char *addr)
480} 464}
481 465
482/* 466/*
483 * map-block calculates the absolute block nr of a block in a file. 467 * map_block calculates the absolute block nr of a block in a file.
484 * It sets 'changed' if the inode has needed changing, and re-writes 468 * It sets 'changed' if the inode has needed changing, and re-writes
485 * any indirect blocks with errors. 469 * any indirect blocks with errors.
486 */ 470 */
487static int map_block(struct minix_inode *inode, unsigned int blknr) 471static int map_block(struct minix_inode *inode, unsigned int blknr)
488{ 472{
489 unsigned short ind[BLOCK_SIZE >> 1]; 473 uint16_t ind[BLOCK_SIZE >> 1];
490 unsigned short dind[BLOCK_SIZE >> 1]; 474 uint16_t dind[BLOCK_SIZE >> 1];
491 int blk_chg, block, result; 475 int blk_chg, block, result;
492 476
493 if (blknr < 7) 477 if (blknr < 7)
@@ -521,9 +505,9 @@ static int map_block(struct minix_inode *inode, unsigned int blknr)
521#ifdef CONFIG_FEATURE_MINIX2 505#ifdef CONFIG_FEATURE_MINIX2
522static int map_block2(struct minix2_inode *inode, unsigned int blknr) 506static int map_block2(struct minix2_inode *inode, unsigned int blknr)
523{ 507{
524 unsigned int ind[BLOCK_SIZE >> 2]; 508 uint32_t ind[BLOCK_SIZE >> 2];
525 unsigned int dind[BLOCK_SIZE >> 2]; 509 uint32_t dind[BLOCK_SIZE >> 2];
526 unsigned int tind[BLOCK_SIZE >> 2]; 510 uint32_t tind[BLOCK_SIZE >> 2];
527 int blk_chg, block, result; 511 int blk_chg, block, result;
528 512
529 if (blknr < 7) 513 if (blknr < 7)
@@ -594,8 +578,6 @@ static void write_super_block(void)
594 die("seek failed in write_super_block"); 578 die("seek failed in write_super_block");
595 if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE)) 579 if (BLOCK_SIZE != write(IN, super_block_buffer, BLOCK_SIZE))
596 die("unable to write super-block"); 580 die("unable to write super-block");
597
598 return;
599} 581}
600 582
601static void write_tables(void) 583static void write_tables(void)
@@ -639,18 +621,15 @@ static void read_superblock(void)
639 die("seek failed"); 621 die("seek failed");
640 if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE)) 622 if (BLOCK_SIZE != read(IN, super_block_buffer, BLOCK_SIZE))
641 die("unable to read super block"); 623 die("unable to read super block");
624 namelen = 14;
625 dirsize = 16;
626 version2 = 0;
642 if (MAGIC == MINIX_SUPER_MAGIC) { 627 if (MAGIC == MINIX_SUPER_MAGIC) {
643 namelen = 14;
644 dirsize = 16;
645 version2 = 0;
646 } else if (MAGIC == MINIX_SUPER_MAGIC2) { 628 } else if (MAGIC == MINIX_SUPER_MAGIC2) {
647 namelen = 30; 629 namelen = 30;
648 dirsize = 32; 630 dirsize = 32;
649 version2 = 0;
650#ifdef CONFIG_FEATURE_MINIX2 631#ifdef CONFIG_FEATURE_MINIX2
651 } else if (MAGIC == MINIX2_SUPER_MAGIC) { 632 } else if (MAGIC == MINIX2_SUPER_MAGIC) {
652 namelen = 14;
653 dirsize = 16;
654 version2 = 1; 633 version2 = 1;
655 } else if (MAGIC == MINIX2_SUPER_MAGIC2) { 634 } else if (MAGIC == MINIX2_SUPER_MAGIC2) {
656 namelen = 30; 635 namelen = 30;
@@ -688,13 +667,20 @@ static void read_tables(void)
688 } 667 }
689 get_dirsize(); 668 get_dirsize();
690 if (show) { 669 if (show) {
691 printf("%ld inodes\n", INODES); 670 printf("%ld inodes\n"
692 printf("%ld blocks\n", ZONES); 671 "%ld blocks\n"
693 printf("Firstdatazone=%ld (%ld)\n", FIRSTZONE, NORM_FIRSTZONE); 672 "Firstdatazone=%ld (%ld)\n"
694 printf("Zonesize=%d\n", BLOCK_SIZE << ZONESIZE); 673 "Zonesize=%d\n"
695 printf("Maxsize=%ld\n", MAXSIZE); 674 "Maxsize=%ld\n"
696 printf("Filesystem state=%d\n", Super.s_state); 675 "Filesystem state=%d\n"
697 printf("namelen=%d\n\n", namelen); 676 "namelen=%d\n\n",
677 INODES,
678 ZONES,
679 FIRSTZONE, NORM_FIRSTZONE,
680 BLOCK_SIZE << ZONESIZE,
681 MAXSIZE,
682 Super.s_state,
683 namelen);
698 } 684 }
699} 685}
700 686
@@ -738,7 +724,7 @@ static struct minix_inode *get_inode(unsigned int nr)
738 } else 724 } else
739 links++; 725 links++;
740 if (!++inode_count[nr]) { 726 if (!++inode_count[nr]) {
741 printf("Warning: inode count too big.\n"); 727 printf("Warning: inode count too big\n");
742 inode_count[nr]--; 728 inode_count[nr]--;
743 errors_uncorrected = 1; 729 errors_uncorrected = 1;
744 } 730 }
@@ -785,7 +771,7 @@ static struct minix2_inode *get_inode2(unsigned int nr)
785 } else 771 } else
786 links++; 772 links++;
787 if (!++inode_count[nr]) { 773 if (!++inode_count[nr]) {
788 printf("Warning: inode count too big.\n"); 774 printf("Warning: inode count too big\n");
789 inode_count[nr]--; 775 inode_count[nr]--;
790 errors_uncorrected = 1; 776 errors_uncorrected = 1;
791 } 777 }
@@ -811,7 +797,7 @@ static void check_root2(void)
811} 797}
812#endif 798#endif
813 799
814static int add_zone(unsigned short *znr, int *corrected) 800static int add_zone(uint16_t *znr, int *corrected)
815{ 801{
816 int result; 802 int result;
817 int block; 803 int block;
@@ -828,10 +814,9 @@ static int add_zone(unsigned short *znr, int *corrected)
828 *znr = 0; 814 *znr = 0;
829 block = 0; 815 block = 0;
830 *corrected = 1; 816 *corrected = 1;
817 return 0;
831 } 818 }
832 } 819 }
833 if (!block)
834 return 0;
835 if (!zone_in_use(block)) { 820 if (!zone_in_use(block)) {
836 printf("Block %d in file `", block); 821 printf("Block %d in file `", block);
837 print_current_name(); 822 print_current_name();
@@ -845,7 +830,7 @@ static int add_zone(unsigned short *znr, int *corrected)
845} 830}
846 831
847#ifdef CONFIG_FEATURE_MINIX2 832#ifdef CONFIG_FEATURE_MINIX2
848static int add_zone2(unsigned int *znr, int *corrected) 833static int add_zone2(uint32_t *znr, int *corrected)
849{ 834{
850 int result; 835 int result;
851 int block; 836 int block;
@@ -862,10 +847,9 @@ static int add_zone2(unsigned int *znr, int *corrected)
862 *znr = 0; 847 *znr = 0;
863 block = 0; 848 block = 0;
864 *corrected = 1; 849 *corrected = 1;
850 return 0;
865 } 851 }
866 } 852 }
867 if (!block)
868 return 0;
869 if (!zone_in_use(block)) { 853 if (!zone_in_use(block)) {
870 printf("Block %d in file `", block); 854 printf("Block %d in file `", block);
871 print_current_name(); 855 print_current_name();
@@ -879,7 +863,7 @@ static int add_zone2(unsigned int *znr, int *corrected)
879} 863}
880#endif 864#endif
881 865
882static void add_zone_ind(unsigned short *znr, int *corrected) 866static void add_zone_ind(uint16_t *znr, int *corrected)
883{ 867{
884 static char blk[BLOCK_SIZE]; 868 static char blk[BLOCK_SIZE];
885 int i, chg_blk = 0; 869 int i, chg_blk = 0;
@@ -890,13 +874,13 @@ static void add_zone_ind(unsigned short *znr, int *corrected)
890 return; 874 return;
891 read_block(block, blk); 875 read_block(block, blk);
892 for (i = 0; i < (BLOCK_SIZE >> 1); i++) 876 for (i = 0; i < (BLOCK_SIZE >> 1); i++)
893 add_zone(i + (unsigned short *) blk, &chg_blk); 877 add_zone(i + (uint16_t *) blk, &chg_blk);
894 if (chg_blk) 878 if (chg_blk)
895 write_block(block, blk); 879 write_block(block, blk);
896} 880}
897 881
898#ifdef CONFIG_FEATURE_MINIX2 882#ifdef CONFIG_FEATURE_MINIX2
899static void add_zone_ind2(unsigned int *znr, int *corrected) 883static void add_zone_ind2(uint32_t *znr, int *corrected)
900{ 884{
901 static char blk[BLOCK_SIZE]; 885 static char blk[BLOCK_SIZE];
902 int i, chg_blk = 0; 886 int i, chg_blk = 0;
@@ -907,13 +891,13 @@ static void add_zone_ind2(unsigned int *znr, int *corrected)
907 return; 891 return;
908 read_block(block, blk); 892 read_block(block, blk);
909 for (i = 0; i < BLOCK_SIZE >> 2; i++) 893 for (i = 0; i < BLOCK_SIZE >> 2; i++)
910 add_zone2(i + (unsigned int *) blk, &chg_blk); 894 add_zone2(i + (uint32_t *) blk, &chg_blk);
911 if (chg_blk) 895 if (chg_blk)
912 write_block(block, blk); 896 write_block(block, blk);
913} 897}
914#endif 898#endif
915 899
916static void add_zone_dind(unsigned short *znr, int *corrected) 900static void add_zone_dind(uint16_t *znr, int *corrected)
917{ 901{
918 static char blk[BLOCK_SIZE]; 902 static char blk[BLOCK_SIZE];
919 int i, blk_chg = 0; 903 int i, blk_chg = 0;
@@ -924,13 +908,13 @@ static void add_zone_dind(unsigned short *znr, int *corrected)
924 return; 908 return;
925 read_block(block, blk); 909 read_block(block, blk);
926 for (i = 0; i < (BLOCK_SIZE >> 1); i++) 910 for (i = 0; i < (BLOCK_SIZE >> 1); i++)
927 add_zone_ind(i + (unsigned short *) blk, &blk_chg); 911 add_zone_ind(i + (uint16_t *) blk, &blk_chg);
928 if (blk_chg) 912 if (blk_chg)
929 write_block(block, blk); 913 write_block(block, blk);
930} 914}
931 915
932#ifdef CONFIG_FEATURE_MINIX2 916#ifdef CONFIG_FEATURE_MINIX2
933static void add_zone_dind2(unsigned int *znr, int *corrected) 917static void add_zone_dind2(uint32_t *znr, int *corrected)
934{ 918{
935 static char blk[BLOCK_SIZE]; 919 static char blk[BLOCK_SIZE];
936 int i, blk_chg = 0; 920 int i, blk_chg = 0;
@@ -941,12 +925,12 @@ static void add_zone_dind2(unsigned int *znr, int *corrected)
941 return; 925 return;
942 read_block(block, blk); 926 read_block(block, blk);
943 for (i = 0; i < BLOCK_SIZE >> 2; i++) 927 for (i = 0; i < BLOCK_SIZE >> 2; i++)
944 add_zone_ind2(i + (unsigned int *) blk, &blk_chg); 928 add_zone_ind2(i + (uint32_t *) blk, &blk_chg);
945 if (blk_chg) 929 if (blk_chg)
946 write_block(block, blk); 930 write_block(block, blk);
947} 931}
948 932
949static void add_zone_tind2(unsigned int *znr, int *corrected) 933static void add_zone_tind2(uint32_t *znr, int *corrected)
950{ 934{
951 static char blk[BLOCK_SIZE]; 935 static char blk[BLOCK_SIZE];
952 int i, blk_chg = 0; 936 int i, blk_chg = 0;
@@ -957,7 +941,7 @@ static void add_zone_tind2(unsigned int *znr, int *corrected)
957 return; 941 return;
958 read_block(block, blk); 942 read_block(block, blk);
959 for (i = 0; i < BLOCK_SIZE >> 2; i++) 943 for (i = 0; i < BLOCK_SIZE >> 2; i++)
960 add_zone_dind2(i + (unsigned int *) blk, &blk_chg); 944 add_zone_dind2(i + (uint32_t *) blk, &blk_chg);
961 if (blk_chg) 945 if (blk_chg)
962 write_block(block, blk); 946 write_block(block, blk);
963} 947}
@@ -1012,13 +996,13 @@ static void check_file(struct minix_inode *dir, unsigned int offset)
1012 block = map_block(dir, offset / BLOCK_SIZE); 996 block = map_block(dir, offset / BLOCK_SIZE);
1013 read_block(block, blk); 997 read_block(block, blk);
1014 name = blk + (offset % BLOCK_SIZE) + 2; 998 name = blk + (offset % BLOCK_SIZE) + 2;
1015 ino = *(unsigned short *) (name - 2); 999 ino = *(uint16_t *) (name - 2);
1016 if (ino > INODES) { 1000 if (ino > INODES) {
1017 print_current_name(); 1001 print_current_name();
1018 printf(" contains a bad inode number for file '"); 1002 printf(" contains a bad inode number for file '");
1019 printf("%.*s'.", namelen, name); 1003 printf("%.*s'.", namelen, name);
1020 if (ask(" Remove", 1)) { 1004 if (ask(" Remove", 1)) {
1021 *(unsigned short *) (name - 2) = 0; 1005 *(uint16_t *) (name - 2) = 0;
1022 write_block(block, blk); 1006 write_block(block, blk);
1023 } 1007 }
1024 ino = 0; 1008 ino = 0;
@@ -1077,13 +1061,13 @@ static void check_file2(struct minix2_inode *dir, unsigned int offset)
1077 block = map_block2(dir, offset / BLOCK_SIZE); 1061 block = map_block2(dir, offset / BLOCK_SIZE);
1078 read_block(block, blk); 1062 read_block(block, blk);
1079 name = blk + (offset % BLOCK_SIZE) + 2; 1063 name = blk + (offset % BLOCK_SIZE) + 2;
1080 ino = *(unsigned short *) (name - 2); 1064 ino = *(uint16_t *) (name - 2);
1081 if (ino > INODES) { 1065 if (ino > INODES) {
1082 print_current_name(); 1066 print_current_name();
1083 printf(" contains a bad inode number for file '"); 1067 printf(" contains a bad inode number for file '");
1084 printf("%.*s'.", namelen, name); 1068 printf("%.*s'.", namelen, name);
1085 if (ask(" Remove", 1)) { 1069 if (ask(" Remove", 1)) {
1086 *(unsigned short *) (name - 2) = 0; 1070 *(uint16_t *) (name - 2) = 0;
1087 write_block(block, blk); 1071 write_block(block, blk);
1088 } 1072 }
1089 ino = 0; 1073 ino = 0;
@@ -1179,7 +1163,7 @@ static void check_counts(void)
1179 int i; 1163 int i;
1180 1164
1181 for (i = 1; i <= INODES; i++) { 1165 for (i = 1; i <= INODES; i++) {
1182 if (!inode_in_use(i) && Inode[i].i_mode && warn_mode) { 1166 if (warn_mode && Inode[i].i_mode && !inode_in_use(i)) {
1183 printf("Inode %d mode not cleared.", i); 1167 printf("Inode %d mode not cleared.", i);
1184 if (ask("Clear", 1)) { 1168 if (ask("Clear", 1)) {
1185 Inode[i].i_mode = 0; 1169 Inode[i].i_mode = 0;
@@ -1230,7 +1214,7 @@ static void check_counts2(void)
1230 int i; 1214 int i;
1231 1215
1232 for (i = 1; i <= INODES; i++) { 1216 for (i = 1; i <= INODES; i++) {
1233 if (!inode_in_use(i) && Inode2[i].i_mode && warn_mode) { 1217 if (warn_mode && Inode2[i].i_mode && !inode_in_use(i)) {
1234 printf("Inode %d mode not cleared.", i); 1218 printf("Inode %d mode not cleared.", i);
1235 if (ask("Clear", 1)) { 1219 if (ask("Clear", 1)) {
1236 Inode2[i].i_mode = 0; 1220 Inode2[i].i_mode = 0;
@@ -1305,7 +1289,7 @@ static void alloc_name_list(void)
1305 1289
1306 name_list = xmalloc(sizeof(char *) * MAX_DEPTH); 1290 name_list = xmalloc(sizeof(char *) * MAX_DEPTH);
1307 for (i = 0; i < MAX_DEPTH; i++) 1291 for (i = 0; i < MAX_DEPTH; i++)
1308 name_list[i] = xmalloc(sizeof(char) * BUFSIZ + 1); 1292 name_list[i] = xmalloc(sizeof(char) * (BUFSIZ + 1));
1309} 1293}
1310 1294
1311#ifdef CONFIG_FEATURE_CLEAN_UP 1295#ifdef CONFIG_FEATURE_CLEAN_UP
@@ -1327,7 +1311,6 @@ static void free_name_list(void)
1327int fsck_minix_main(int argc, char **argv) 1311int fsck_minix_main(int argc, char **argv)
1328{ 1312{
1329 struct termios tmp; 1313 struct termios tmp;
1330 int count;
1331 int retcode = 0; 1314 int retcode = 0;
1332 1315
1333 alloc_name_list(); 1316 alloc_name_list();
@@ -1389,11 +1372,10 @@ int fsck_minix_main(int argc, char **argv)
1389 } 1372 }
1390 IN = open(device_name, repair ? O_RDWR : O_RDONLY); 1373 IN = open(device_name, repair ? O_RDWR : O_RDONLY);
1391 if (IN < 0){ 1374 if (IN < 0){
1392 fprintf(stderr,"unable to open device '%s'.\n",device_name); 1375 fprintf(stderr,"unable to open device '%s'\n",device_name);
1393 leave(8); 1376 leave(8);
1394 } 1377 }
1395 for (count = 0; count < 3; count++) 1378 sync(); /* paranoia? */
1396 sync();
1397 read_superblock(); 1379 read_superblock();
1398 1380
1399 /* 1381 /*
@@ -1406,12 +1388,12 @@ int fsck_minix_main(int argc, char **argv)
1406 if (!(Super.s_state & MINIX_ERROR_FS) && 1388 if (!(Super.s_state & MINIX_ERROR_FS) &&
1407 (Super.s_state & MINIX_VALID_FS) && !force) { 1389 (Super.s_state & MINIX_VALID_FS) && !force) {
1408 if (repair) 1390 if (repair)
1409 printf("%s is clean, no check.\n", device_name); 1391 printf("%s is clean, no check\n", device_name);
1410 return retcode; 1392 return retcode;
1411 } else if (force) 1393 } else if (force)
1412 printf("Forcing filesystem check on %s.\n", device_name); 1394 printf("Forcing filesystem check on %s\n", device_name);
1413 else if (repair) 1395 else if (repair)
1414 printf("Filesystem on %s is dirty, needs checking.\n", 1396 printf("Filesystem on %s is dirty, needs checking\n",
1415 device_name); 1397 device_name);
1416 1398
1417 read_tables(); 1399 read_tables();
@@ -1463,8 +1445,7 @@ int fsck_minix_main(int argc, char **argv)
1463 printf("----------------------------\n" 1445 printf("----------------------------\n"
1464 "FILE SYSTEM HAS BEEN CHANGED\n" 1446 "FILE SYSTEM HAS BEEN CHANGED\n"
1465 "----------------------------\n"); 1447 "----------------------------\n");
1466 for (count = 0; count < 3; count++) 1448 sync();
1467 sync();
1468 } else if (repair) 1449 } else if (repair)
1469 write_super_block(); 1450 write_super_block();
1470 1451