2 * unix.c - The unix-specific code for e2fsck
4 * Copyright (C) 1993, 1994, 1995, 1996, 1997 Theodore Ts'o.
7 * This file may be redistributed under the terms of the GNU Public
36 #include <sys/ioctl.h>
39 #include "et/com_err.h"
42 #include "../version.h"
44 /* Command line options */
45 static int blocksize = 0;
46 static int swapfs = 0;
47 static int normalize_swapfs = 0;
48 static int cflag = 0; /* check disk */
49 static int show_version_only = 0;
51 static int verbose = 0;
53 static int replace_bad_blocks = 0;
54 static char *bad_blocks_file = 0;
56 static int possible_block_sizes[] = { 1024, 2048, 4096, 8192, 0};
58 static int root_filesystem = 0;
59 static int read_only_root = 0;
61 e2fsck_t e2fsck_global_ctx; /* Try your very best not to use this! */
63 static void usage(e2fsck_t ctx)
66 _("Usage: %s [-panyrcdfvstFSV] [-b superblock] [-B blocksize]\n"
67 "\t\t[-I inode_buffer_blocks] [-P process_inode_size]\n"
68 "\t\t[-l|-L bad_blocks_file] [-C fd] device\n"),
71 fprintf(stderr, _("\nEmergency help:\n"
72 " -p Automatic repair (no questions)\n"
73 " -n Make no changes to the filesystem\n"
74 " -y Assume \"yes\" to all questions\n"
75 " -c Check for bad blocks\n"
76 " -f Force checking even if filesystem is marked clean\n"));
79 " -b superblock Use alternative superblock\n"
80 " -B blocksize Force blocksize when looking for superblock\n"
81 " -l bad_blocks_file Add to badblocks list\n"
82 " -L bad_blocks_file Set badblocks list\n"
88 static void show_stats(e2fsck_t ctx)
90 ext2_filsys fs = ctx->fs;
91 int inodes, inodes_used, blocks, blocks_used;
93 int num_files, num_links;
96 dir_links = 2 * ctx->fs_directory_count - 1;
97 num_files = ctx->fs_total_count - dir_links;
98 num_links = ctx->fs_links_count - dir_links;
99 inodes = fs->super->s_inodes_count;
100 inodes_used = (fs->super->s_inodes_count -
101 fs->super->s_free_inodes_count);
102 blocks = fs->super->s_blocks_count;
103 blocks_used = (fs->super->s_blocks_count -
104 fs->super->s_free_blocks_count);
106 frag_percent = (10000 * ctx->fs_fragmented) / inodes_used;
107 frag_percent = (frag_percent + 5) / 10;
110 printf(_("%s: %d/%d files (%0d.%d%% non-contiguous), %d/%d blocks\n"),
111 ctx->device_name, inodes_used, inodes,
112 frag_percent / 10, frag_percent % 10,
113 blocks_used, blocks);
117 * This is a bit ugly. But I think there will nearly always be more
118 * than one "thing" to report about, so I won't try writing complex
119 * code to handle one/two/many forms of all words.
120 * Some languages (Italian, at least) never uses the plural form
121 * of foreign words, so in real life this could not be a problem.
122 * md@linux.it - 2000-1-15
125 printf (_("\n%8d inodes used (%d%%)\n"), inodes_used,
126 (inodes_used != 1), 100 * inodes_used / inodes);
127 printf (_("%8d non-contiguous inodes (%0d.%d%%)\n"),
128 ctx->fs_fragmented, frag_percent / 10, frag_percent % 10);
129 printf (_(" # of inodes with ind/dind/tind blocks: %d/%d/%d\n"),
130 ctx->fs_ind_count, ctx->fs_dind_count, ctx->fs_tind_count);
131 printf (_("%8d blocks used (%d%%)\n"
132 "%8d bad blocks\n"), blocks_used,
133 100 * blocks_used / blocks, ctx->fs_badblocks_count);
134 printf (_("\n%8d regular files\n"
136 "%8d character device files\n"
137 "%8d block device files\n"
140 "%8d symbolic links (%d fast symbolic links)\n"
144 ctx->fs_regular_count,
145 ctx->fs_directory_count,
146 ctx->fs_chardev_count,
147 ctx->fs_blockdev_count,
149 ctx->fs_links_count - dir_links,
150 ctx->fs_symlinks_count,
151 ctx->fs_fast_symlinks_count,
152 ctx->fs_sockets_count,
153 ctx->fs_total_count - dir_links);
155 printf ("\n%8d inode%s used (%d%%)\n", inodes_used,
156 (inodes_used != 1) ? "s" : "",
157 100 * inodes_used / inodes);
158 printf ("%8d non-contiguous inodes (%0d.%d%%)\n",
159 ctx->fs_fragmented, frag_percent / 10, frag_percent % 10);
160 printf (" # of inodes with ind/dind/tind blocks: %d/%d/%d\n",
161 ctx->fs_ind_count, ctx->fs_dind_count, ctx->fs_tind_count);
162 printf ("%8d block%s used (%d%%)\n"
163 "%8d bad block%s\n", blocks_used,
164 (blocks_used != 1) ? "s" : "",
165 100 * blocks_used / blocks, ctx->fs_badblocks_count,
166 ctx->fs_badblocks_count != 1 ? "s" : "");
167 printf ("\n%8d regular file%s\n"
169 "%8d character device file%s\n"
170 "%8d block device file%s\n"
173 "%8d symbolic link%s (%d fast symbolic link%s)\n"
177 ctx->fs_regular_count,
178 (ctx->fs_regular_count != 1) ? "s" : "",
179 ctx->fs_directory_count,
180 (ctx->fs_directory_count != 1) ? "ies" : "y",
181 ctx->fs_chardev_count,
182 (ctx->fs_chardev_count != 1) ? "s" : "",
183 ctx->fs_blockdev_count,
184 (ctx->fs_blockdev_count != 1) ? "s" : "",
186 (ctx->fs_fifo_count != 1) ? "s" : "",
187 ctx->fs_links_count - dir_links,
188 ((ctx->fs_links_count - dir_links) != 1) ? "s" : "",
189 ctx->fs_symlinks_count,
190 (ctx->fs_symlinks_count != 1) ? "s" : "",
191 ctx->fs_fast_symlinks_count,
192 (ctx->fs_fast_symlinks_count != 1) ? "s" : "",
193 ctx->fs_sockets_count, (ctx->fs_sockets_count != 1) ? "s" : "",
194 ctx->fs_total_count - dir_links,
195 ((ctx->fs_total_count - dir_links) != 1) ? "s" : "");
199 static void check_mount(e2fsck_t ctx)
202 int mount_flags, cont, fd;
204 retval = ext2fs_check_if_mounted(ctx->filesystem_name, &mount_flags);
206 com_err("ext2fs_check_if_mount", retval,
207 _("while determining whether %s is mounted."),
208 ctx->filesystem_name);
211 if (!(mount_flags & EXT2_MF_MOUNTED))
214 #if (defined(__linux__) && defined(HAVE_MNTENT_H))
216 * If the root is mounted read-only, then /etc/mtab is
217 * probably not correct; so we won't issue a warning based on
220 fd = open(MOUNTED, O_RDWR);
228 if (ctx->options & E2F_OPT_READONLY) {
229 printf(_("Warning! %s is mounted.\n"), ctx->filesystem_name);
233 printf(_("%s is mounted. "), ctx->filesystem_name);
234 if (!isatty(0) || !isatty(1))
235 fatal_error(ctx, _("Cannot continue, aborting.\n\n"));
236 printf(_("\n\n\007\007\007\007WARNING!!! "
237 "Running e2fsck on a mounted filesystem may cause\n"
238 "SEVERE filesystem damage.\007\007\007\n\n"));
239 cont = ask_yn(_("Do you really want to continue"), -1);
241 printf (_("check aborted.\n"));
248 * This routine checks to see if a filesystem can be skipped; if so,
249 * it will exit with E2FSCK_OK. Under some conditions it will print a
250 * message explaining why a check is being forced.
252 static void check_if_skip(e2fsck_t ctx)
254 ext2_filsys fs = ctx->fs;
255 const char *reason = NULL;
257 if (force || bad_blocks_file || cflag || swapfs)
260 if (fs->super->s_state & EXT2_ERROR_FS)
261 reason = _("contains a file system with errors");
262 else if ((fs->super->s_state & EXT2_VALID_FS) == 0)
263 reason = _("was not cleanly unmounted");
264 else if ((fs->super->s_max_mnt_count >= 0) &&
265 (fs->super->s_mnt_count >=
266 (unsigned) fs->super->s_max_mnt_count))
267 reason = _("has reached maximal mount count");
268 else if (fs->super->s_checkinterval &&
269 time(0) >= (fs->super->s_lastcheck +
270 fs->super->s_checkinterval))
271 reason = _("has gone too long without being checked");
273 printf(_("%s %s, check forced.\n"), ctx->device_name, reason);
276 printf(_("%s: clean, %d/%d files, %d/%d blocks\n"), ctx->device_name,
277 fs->super->s_inodes_count - fs->super->s_free_inodes_count,
278 fs->super->s_inodes_count,
279 fs->super->s_blocks_count - fs->super->s_free_blocks_count,
280 fs->super->s_blocks_count);
286 * For completion notice
292 struct percent_tbl e2fsck_tbl = {
293 5, { 0, 70, 90, 92, 95, 100 }
296 "==============================================================="
297 "===============================================================";
298 static char spaces[] =
302 static float calc_percent(struct percent_tbl *tbl, int pass, int curr,
309 if (pass > tbl->max_pass || max == 0)
311 percent = ((float) curr) / ((float) max);
312 return ((percent * (tbl->table[pass] - tbl->table[pass-1]))
313 + tbl->table[pass-1]);
316 extern void e2fsck_clear_progbar(e2fsck_t ctx)
318 if (!(ctx->flags & E2F_FLAG_PROG_BAR))
321 printf("%s\r", spaces + (sizeof(spaces) - 80));
322 ctx->flags &= ~E2F_FLAG_PROG_BAR;
325 static int e2fsck_update_progress(e2fsck_t ctx, int pass,
326 unsigned long cur, unsigned long max)
328 static const char spinner[] = "\\|/-";
334 static int dpywidth = 0;
339 if (ctx->progress_fd) {
340 sprintf(buf, "%d %lu %lu\n", pass, cur, max);
341 write(ctx->progress_fd, buf, strlen(buf));
343 if (ctx->flags & E2F_FLAG_PROG_SUPPRESS)
346 dpywidth = 66 - strlen(ctx->device_name);
347 dpywidth = 8 * (dpywidth / 8);
350 * Calculate the new progress position. If the
351 * percentage hasn't changed, then we skip out right
354 percent = calc_percent(&e2fsck_tbl, pass, cur, max);
355 if (ctx->progress_last_percent == (int) 10 * percent)
357 ctx->progress_last_percent = (int) 10 * percent;
360 * If we've already updated the spinner once within
361 * the last 1/8th of a second, no point doing it
364 gettimeofday(&tv, NULL);
365 tick = (tv.tv_sec << 3) + (tv.tv_usec / (1000000 / 8));
366 if ((tick == ctx->progress_last_time) &&
367 (cur != max) && (cur != 0))
369 ctx->progress_last_time = tick;
372 * Advance the spinner, and note that the progress bar
373 * will be on the screen
375 ctx->progress_pos = (ctx->progress_pos+1) & 3;
376 ctx->flags |= E2F_FLAG_PROG_BAR;
378 i = ((percent * dpywidth) + 50) / 100;
379 printf("%s: |%s%s", ctx->device_name,
380 bar + (sizeof(bar) - (i+1)),
381 spaces + (sizeof(spaces) - (dpywidth - i + 1)));
382 if (percent == 100.0)
385 fputc(spinner[ctx->progress_pos & 3], stdout);
386 printf(" %4.1f%% \r", percent);
387 if (percent == 100.0)
388 e2fsck_clear_progbar(ctx);
394 #define PATH_SET "PATH=/sbin"
396 static void reserve_stdio_fds(void)
401 fd = open("/dev/null", O_RDWR);
405 fprintf(stderr, _("ERROR: Couldn't open "
415 static void signal_progress_on(int sig)
417 e2fsck_t ctx = e2fsck_global_ctx;
422 ctx->progress = e2fsck_update_progress;
423 ctx->progress_fd = 0;
426 static void signal_progress_off(int sig)
428 e2fsck_t ctx = e2fsck_global_ctx;
433 e2fsck_clear_progbar(ctx);
438 static errcode_t PRS(int argc, char *argv[], e2fsck_t *ret_ctx)
443 extern void *mallwatch;
445 char *oldpath = getenv("PATH");
452 retval = e2fsck_allocate_context(&ctx);
458 /* Update our PATH to include /sbin */
462 newpath = (char *) malloc(sizeof (PATH_SET) + 1 +
465 fatal_error(ctx, "Couldn't malloc() newpath");
466 strcpy (newpath, PATH_SET);
467 strcat (newpath, ":");
468 strcat (newpath, oldpath);
473 setbuf(stdout, NULL);
474 setbuf(stderr, NULL);
475 initialize_ext2_error_table();
478 ctx->program_name = *argv;
480 ctx->program_name = "e2fsck";
481 while ((c = getopt (argc, argv, "panyrcC:B:dfvtFVM:b:I:P:l:L:N:Ss")) != EOF)
484 ctx->progress = e2fsck_update_progress;
485 ctx->progress_fd = atoi(optarg);
489 ctx->options |= E2F_OPT_PREEN;
490 ctx->options &= ~(E2F_OPT_YES|E2F_OPT_NO);
493 ctx->options |= E2F_OPT_NO;
494 ctx->options &= ~(E2F_OPT_YES|E2F_OPT_PREEN);
497 ctx->options |= E2F_OPT_YES;
498 ctx->options &= ~(E2F_OPT_PREEN|E2F_OPT_NO);
501 #ifdef RESOURCE_TRACK
502 if (ctx->options & E2F_OPT_TIME)
503 ctx->options |= E2F_OPT_TIME2;
505 ctx->options |= E2F_OPT_TIME;
507 fprintf(stderr, _("The -t option is not "
508 "supported on this version of e2fsck.\n"));
513 ctx->options |= E2F_OPT_CHECKBLOCKS;
516 /* What we do by default, anyway! */
519 ctx->use_superblock = atoi(optarg);
522 blocksize = atoi(optarg);
525 ctx->inode_buffer_blocks = atoi(optarg);
528 ctx->process_inode_size = atoi(optarg);
531 replace_bad_blocks++;
533 bad_blocks_file = (char *) malloc(strlen(optarg)+1);
534 if (!bad_blocks_file)
536 "Couldn't malloc bad_blocks_file");
537 strcpy(bad_blocks_file, optarg);
540 ctx->options |= E2F_OPT_DEBUG;
552 show_version_only = 1;
556 mallwatch = (void *) strtol(optarg, NULL, 0);
560 ctx->device_name = optarg;
563 normalize_swapfs = 1;
570 if (show_version_only)
572 if (optind != argc - 1)
574 if ((ctx->options & E2F_OPT_NO) && !bad_blocks_file &&
576 ctx->options |= E2F_OPT_READONLY;
577 ctx->filesystem_name = argv[optind];
579 int fd = open(ctx->filesystem_name, O_RDONLY, 0);
582 com_err("open", errno,
583 _("while opening %s for flushing"),
584 ctx->filesystem_name);
587 if ((retval == ext2fs_sync_device(fd, 1))) {
588 com_err("ext2fs_sync_device", retval,
589 _("while trying to flush %s"),
590 ctx->filesystem_name);
596 if (cflag || bad_blocks_file) {
597 fprintf(stderr, _("Incompatible options not "
598 "allowed when byte-swapping.\n"));
604 * Set up signal action
606 memset(&sa, 0, sizeof(struct sigaction));
608 sa.sa_flags = SA_RESTART;
610 e2fsck_global_ctx = ctx;
611 sa.sa_handler = signal_progress_on;
612 sigaction(SIGUSR1, &sa, 0);
613 sa.sa_handler = signal_progress_off;
614 sigaction(SIGUSR2, &sa, 0);
619 static const char *my_ver_string = E2FSPROGS_VERSION;
620 static const char *my_ver_date = E2FSPROGS_DATE;
622 int main (int argc, char *argv[])
624 errcode_t retval = 0;
625 int exit_value = FSCK_OK;
629 struct ext2_super_block *sb;
630 const char *lib_ver_date;
633 struct problem_context pctx;
634 int flags, run_result;
636 clear_problem_context(&pctx);
644 setlocale(LC_MESSAGES, "");
645 bindtextdomain(NLS_CAT_NAME, LOCALEDIR);
646 textdomain(NLS_CAT_NAME);
648 my_ver = ext2fs_parse_version_string(my_ver_string);
649 lib_ver = ext2fs_get_library_version(0, &lib_ver_date);
650 if (my_ver > lib_ver) {
651 fprintf( stderr, _("Error: ext2fs library version "
656 retval = PRS(argc, argv, &ctx);
658 com_err("e2fsck", retval,
659 _("while trying to initialize program"));
664 #ifdef RESOURCE_TRACK
665 init_resource_track(&ctx->global_rtrack);
668 if (!(ctx->options & E2F_OPT_PREEN) || show_version_only)
669 fprintf (stderr, _("e2fsck %s, %s for EXT2 FS %s, %s\n"),
670 my_ver_string, my_ver_date, EXT2FS_VERSION,
673 if (show_version_only) {
674 fprintf(stderr, _("\tUsing %s, %s\n"),
675 error_message(EXT2_ET_BASE), lib_ver_date);
681 if (!(ctx->options & E2F_OPT_PREEN) &&
682 !(ctx->options & E2F_OPT_NO) &&
683 !(ctx->options & E2F_OPT_YES)) {
684 if (!isatty (0) || !isatty (1))
686 _("need terminal for interactive repairs"));
688 ctx->superblock = ctx->use_superblock;
691 io_ptr = unix_io_manager;
693 io_ptr = test_io_manager;
694 test_io_backing_manager = unix_io_manager;
697 if ((ctx->options & E2F_OPT_READONLY) == 0)
698 flags |= EXT2_FLAG_RW;
700 if (ctx->superblock && blocksize) {
701 retval = ext2fs_open(ctx->filesystem_name, flags,
702 ctx->superblock, blocksize, io_ptr, &fs);
703 } else if (ctx->superblock) {
704 for (i=0; possible_block_sizes[i]; i++) {
705 retval = ext2fs_open(ctx->filesystem_name, flags,
707 possible_block_sizes[i],
713 retval = ext2fs_open(ctx->filesystem_name, flags,
715 if (!ctx->superblock && !(ctx->options & E2F_OPT_PREEN) &&
716 ((retval == EXT2_ET_BAD_MAGIC) ||
717 ((retval == 0) && ext2fs_check_desc(fs)))) {
718 if (!fs || (fs->group_desc_count > 1)) {
719 printf(_("%s trying backup blocks...\n"),
720 retval ? _("Couldn't find ext2 superblock,") :
721 _("Group descriptors look bad..."));
722 ctx->superblock = get_backup_sb(fs);
729 com_err(ctx->program_name, retval, _("while trying to open %s"),
730 ctx->filesystem_name);
731 if (retval == EXT2_ET_REV_TOO_HIGH) {
732 printf(_("The filesystem revision is apparently "
733 "too high for this version of e2fsck.\n"
734 "(Or the filesystem superblock "
736 fix_problem(ctx, PR_0_SB_CORRUPT, &pctx);
737 } else if (retval == EXT2_ET_SHORT_READ)
738 printf(_("Could this be a zero-length partition?\n"));
739 else if ((retval == EPERM) || (retval == EACCES))
740 printf(_("You must have %s access to the "
741 "filesystem or be root\n"),
742 (ctx->options & E2F_OPT_READONLY) ?
744 else if (retval == ENXIO)
745 printf(_("Possibly non-existent or swap device?\n"));
747 else if (retval == EROFS)
748 printf(_("Disk write-protected; use the -n option "
749 "to do a read-only\n"
750 "check of the device.\n"));
753 fix_problem(ctx, PR_0_SB_CORRUPT, &pctx);
759 if (sb->s_rev_level > E2FSCK_CURRENT_REV) {
760 com_err(ctx->program_name, EXT2_ET_REV_TOO_HIGH,
761 _("while trying to open %s"),
762 ctx->filesystem_name);
764 fatal_error(ctx, _("Get a newer version of e2fsck!"));
768 * Set the device name, which is used whenever we print error
769 * or informational messages to the user.
771 if (ctx->device_name == 0 &&
772 (sb->s_volume_name[0] != 0)) {
773 char *cp = malloc(sizeof(sb->s_volume_name)+1);
775 strncpy(cp, sb->s_volume_name,
776 sizeof(sb->s_volume_name));
777 cp[sizeof(sb->s_volume_name)] = 0;
778 ctx->device_name = cp;
781 if (ctx->device_name == 0)
782 ctx->device_name = ctx->filesystem_name;
785 * Make sure the ext3 superblock fields are consistent.
787 retval = e2fsck_check_ext3_journal(ctx);
789 com_err(ctx->program_name, retval,
790 _("while checking ext3 journal for %s"),
792 ext2fs_close(ctx->fs);
797 * Check to see if we need to do ext3-style recovery. If so,
798 * do it, and then restart the fsck.
800 if (sb->s_feature_incompat & EXT3_FEATURE_INCOMPAT_RECOVER) {
801 if (ctx->options & E2F_OPT_READONLY) {
802 printf(_("Warning: skipping journal recovery "
803 "because doing a read-only filesystem "
805 io_channel_flush(ctx->fs->io);
807 retval = e2fsck_run_ext3_journal(ctx);
809 com_err(ctx->program_name, retval,
810 _("while recovering ext3 journal of %s"),
814 ext2fs_close(ctx->fs);
821 * Check for compatibility with the feature sets. We need to
822 * be more stringent than ext2fs_open().
824 if ((sb->s_feature_compat & ~EXT2_LIB_FEATURE_COMPAT_SUPP) ||
825 (sb->s_feature_incompat & ~EXT2_LIB_FEATURE_INCOMPAT_SUPP)) {
826 com_err(ctx->program_name, EXT2_ET_UNSUPP_FEATURE,
827 "(%s)", ctx->device_name);
830 if (sb->s_feature_ro_compat & ~EXT2_LIB_FEATURE_RO_COMPAT_SUPP) {
831 com_err(ctx->program_name, EXT2_ET_RO_UNSUPP_FEATURE,
832 "(%s)", ctx->device_name);
835 #ifdef ENABLE_COMPRESSION
836 if (sb->s_feature_incompat & EXT2_FEATURE_INCOMPAT_COMPRESSION)
837 com_err(ctx->program_name, 0,
838 _("Warning: compression support is experimental.\n"));
842 * If the user specified a specific superblock, presumably the
843 * master superblock has been trashed. So we mark the
844 * superblock as dirty, so it can be written out.
846 if (ctx->superblock &&
847 !(ctx->options & E2F_OPT_READONLY))
848 ext2fs_mark_super_dirty(fs);
851 * Don't overwrite the backup superblock and block
852 * descriptors, until we're sure the filesystem is OK....
854 fs->flags |= EXT2_FLAG_MASTER_SB_ONLY;
856 ehandler_init(fs->io);
859 set_latch_flags(PR_LATCH_RELOC, PRL_LATCHED, 0);
860 check_super_block(ctx);
861 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
865 read_bad_blocks_file(ctx, bad_blocks_file, replace_bad_blocks);
868 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
871 if (normalize_swapfs) {
872 if ((fs->flags & EXT2_FLAG_SWAP_BYTES) ==
873 ext2fs_native_flag()) {
874 fprintf(stderr, _("%s: Filesystem byte order "
875 "already normalized.\n"), ctx->device_name);
881 if (ctx->flags & E2F_FLAG_SIGNAL_MASK)
886 * Mark the system as valid, 'til proven otherwise
888 ext2fs_mark_valid(fs);
890 retval = ext2fs_read_bb_inode(fs, &fs->badblocks);
892 com_err(ctx->program_name, retval,
893 _("while reading bad blocks inode"));
895 printf(_("This doesn't bode well,"
896 " but we'll try to go on...\n"));
899 run_result = e2fsck_run(ctx);
900 e2fsck_clear_progbar(ctx);
901 if (run_result == E2F_FLAG_RESTART) {
902 printf(_("Restarting e2fsck from the beginning...\n"));
903 retval = e2fsck_reset_context(ctx);
905 com_err(ctx->program_name, retval,
906 _("while resetting context"));
912 if (run_result & E2F_FLAG_SIGNAL_MASK)
914 if (run_result & E2F_FLAG_CANCEL)
915 ext2fs_unmark_valid(fs);
918 mtrace_print("Cleanup");
920 if (ext2fs_test_changed(fs)) {
921 exit_value = FSCK_NONDESTRUCT;
922 if (!(ctx->options & E2F_OPT_PREEN))
923 printf(_("\n%s: ***** FILE SYSTEM WAS MODIFIED *****\n"),
925 if (root_filesystem && !read_only_root) {
926 printf(_("%s: ***** REBOOT LINUX *****\n"),
928 exit_value = FSCK_REBOOT;
931 if (ext2fs_test_valid(fs))
932 fs->flags &= ~EXT2_FLAG_MASTER_SB_ONLY;
934 exit_value = FSCK_UNCORRECTED;
935 if (!(ctx->options & E2F_OPT_READONLY)) {
936 if (ext2fs_test_valid(fs)) {
937 if (!(sb->s_state & EXT2_VALID_FS))
938 exit_value = FSCK_NONDESTRUCT;
939 sb->s_state = EXT2_VALID_FS;
941 sb->s_state &= ~EXT2_VALID_FS;
943 sb->s_lastcheck = time(NULL);
944 ext2fs_mark_super_dirty(fs);
948 e2fsck_write_bitmaps(ctx);
950 #ifdef RESOURCE_TRACK
951 if (ctx->options & E2F_OPT_TIME)
952 print_resource_track(NULL, &ctx->global_rtrack);
957 e2fsck_free_context(ctx);