summaryrefslogtreecommitdiffstats
path: root/sbin/fsck_ffs/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'sbin/fsck_ffs/main.c')
-rw-r--r--sbin/fsck_ffs/main.c35
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;
+}
OpenPOWER on IntegriCloud