From e1f2c1df247d1210f90b4261ae7b44f3882e2d55 Mon Sep 17 00:00:00 2001 From: sobomax Date: Tue, 25 Oct 2011 01:46:42 +0000 Subject: Add new option -c to specify alternatve location of the /etc/fstab file. MFC after: 1 month --- sbin/fsck/fsck.8 | 5 +++++ sbin/fsck/fsck.c | 13 +++++++++++-- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/sbin/fsck/fsck.8 b/sbin/fsck/fsck.8 index d3f1d4a..3fa113a 100644 --- a/sbin/fsck/fsck.8 +++ b/sbin/fsck/fsck.8 @@ -41,6 +41,7 @@ .Op Fl B | F .Op Fl T Ar fstype : Ns Ar fsoptions .Op Fl t Ar fstype +.Op Fl c Ar fstab .Oo Ar special | node Oc ... .Sh DESCRIPTION The @@ -117,6 +118,10 @@ Check if the .Dq clean flag is set in the superblock and skip file system checks if file system was properly dismounted and marked clean. +.It Fl c Ar fstab +Specify the +.Pa fstab +file to use. .It Fl d Debugging mode. Just print the commands without executing them. diff --git a/sbin/fsck/fsck.c b/sbin/fsck/fsck.c index 24c4e13..5e27010 100644 --- a/sbin/fsck/fsck.c +++ b/sbin/fsck/fsck.c @@ -96,6 +96,7 @@ main(int argc, char *argv[]) int i, rval = 0; const char *vfstype = NULL; char globopt[3]; + const char *etc_fstab; globopt[0] = '-'; globopt[2] = '\0'; @@ -103,7 +104,8 @@ main(int argc, char *argv[]) TAILQ_INIT(&selhead); TAILQ_INIT(&opthead); - while ((i = getopt(argc, argv, "BCdvpfFnyl:t:T:")) != -1) + etc_fstab = NULL; + while ((i = getopt(argc, argv, "BCdvpfFnyl:t:T:c:")) != -1) switch (i) { case 'B': if (flags & CHECK_BACKGRD) @@ -160,6 +162,10 @@ main(int argc, char *argv[]) vfstype = optarg; break; + case 'c': + etc_fstab = optarg; + break; + case '?': default: usage(); @@ -169,6 +175,9 @@ main(int argc, char *argv[]) argc -= optind; argv += optind; + if (etc_fstab != NULL) + setfstab(etc_fstab); + if (argc == 0) return checkfstab(flags, isok, checkfs); @@ -571,7 +580,7 @@ static void usage(void) { static const char common[] = - "[-Cdfnpvy] [-B | -F] [-T fstype:fsoptions] [-t fstype]"; + "[-Cdfnpvy] [-B | -F] [-T fstype:fsoptions] [-t fstype] [-c fstab]"; (void)fprintf(stderr, "usage: %s %s [special | node] ...\n", getprogname(), common); -- cgit v1.1