diff options
author | scottl <scottl@FreeBSD.org> | 2013-12-30 01:16:08 +0000 |
---|---|---|
committer | scottl <scottl@FreeBSD.org> | 2013-12-30 01:16:08 +0000 |
commit | f0d9289d4bc1cea75e6ade6e0b1496020b81d254 (patch) | |
tree | 3f5b4ba557bcb5004e79798d6d96972dfe7d2e45 /sbin/fsck_ffs/main.c | |
parent | 3652e600422dfba0018864e0430f86f9fae07bbd (diff) | |
download | FreeBSD-src-f0d9289d4bc1cea75e6ade6e0b1496020b81d254.zip FreeBSD-src-f0d9289d4bc1cea75e6ade6e0b1496020b81d254.tar.gz |
Add the -R option to allow fsck_ffs to restart itself when too many critical
errors have been detected in a particular run.
Clean up the global state variables so that a restart can happen correctly.
Separate the global variables in fsck_ffs and fsdb to their own file. This
fixes header sharing with fscd.
Correctly initialize, static-ize, and remove global variables as needed in
dir.c. This fixes a problem with lost+found directories that was causing
a segfault.
Correctly initialize, static-ize, and remove global variables as needed in
suj.c.
Initialize the suj globals before allocating the disk object, not after.
Also ensure that 'preen' mode doesn't conflict with 'restart' mode
Submitted by: scottl, max
Reviewed by: max, mckusick (earlier version)
Obtained from: Netflix
MFC after: 3 days
Diffstat (limited to 'sbin/fsck_ffs/main.c')
-rw-r--r-- | sbin/fsck_ffs/main.c | 35 |
1 files changed, 31 insertions, 4 deletions
diff --git a/sbin/fsck_ffs/main.c b/sbin/fsck_ffs/main.c index 1a1c03b..08c7745 100644 --- a/sbin/fsck_ffs/main.c +++ b/sbin/fsck_ffs/main.c @@ -65,6 +65,8 @@ __FBSDID("$FreeBSD$"); #include "fsck.h" +int restarts; + static void usage(void) __dead2; static int argtoi(int flag, const char *req, const char *str, int base); static int checkfilesys(char *filesys); @@ -82,7 +84,7 @@ main(int argc, char *argv[]) sync(); skipclean = 1; inoopt = 0; - while ((ch = getopt(argc, argv, "b:Bc:CdEfFm:nprSyZ")) != -1) { + while ((ch = getopt(argc, argv, "b:Bc:CdEfFm:npRrSyZ")) != -1) { switch (ch) { case 'b': skipclean = 0; @@ -138,6 +140,9 @@ main(int argc, char *argv[]) ckclean++; break; + case 'R': + wantrestart = 1; + break; case 'r': inoopt++; break; @@ -186,8 +191,12 @@ main(int argc, char *argv[]) rlimit.rlim_cur = rlimit.rlim_max; (void)setrlimit(RLIMIT_DATA, &rlimit); } - while (argc-- > 0) - (void)checkfilesys(*argv++); + while (argc > 0) { + if (checkfilesys(*argv) == ERESTART) + continue; + argc--; + argv++; + } if (returntosingle) ret = 2; @@ -228,6 +237,8 @@ checkfilesys(char *filesys) iov = NULL; iovlen = 0; errmsg[0] = '\0'; + fsutilinit(); + fsckinit(); cdevname = filesys; if (debug && ckclean) @@ -550,8 +561,12 @@ checkfilesys(char *filesys) inostathead = NULL; if (fsmodified && !preen) printf("\n***** FILE SYSTEM WAS MODIFIED *****\n"); - if (rerun) + if (rerun) { + if (wantrestart && (restarts++ < 10) && + (preen || reply("RESTART"))) + return (ERESTART); printf("\n***** PLEASE RERUN FSCK *****\n"); + } if (chkdoreload(mntp) != 0) { if (!fsmodified) return (0); @@ -654,3 +669,15 @@ usage(void) getprogname()); exit(1); } + +void +infohandler(int sig __unused) +{ + got_siginfo = 1; +} + +void +alarmhandler(int sig __unused) +{ + got_sigalarm = 1; +} |