Author: sobomax
Date: Tue Oct 25 01:46:42 2011
New Revision: 226711
URL: http://svn.freebsd.org/changeset/base/226711

Log:
  Add new option -c to specify alternatve location of the /etc/fstab
  file.
  
  MFC after:    1 month

Modified:
  head/sbin/fsck/fsck.8
  head/sbin/fsck/fsck.c

Modified: head/sbin/fsck/fsck.8
==============================================================================
--- head/sbin/fsck/fsck.8       Tue Oct 25 00:34:39 2011        (r226710)
+++ head/sbin/fsck/fsck.8       Tue Oct 25 01:46:42 2011        (r226711)
@@ -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.

Modified: head/sbin/fsck/fsck.c
==============================================================================
--- head/sbin/fsck/fsck.c       Tue Oct 25 00:34:39 2011        (r226710)
+++ head/sbin/fsck/fsck.c       Tue Oct 25 01:46:42 2011        (r226711)
@@ -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);
_______________________________________________
[email protected] mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "[email protected]"

Reply via email to