Author: sobomax
Date: Tue Oct 25 01:47:33 2011
New Revision: 226712
URL: http://svn.freebsd.org/changeset/base/226712

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

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

Modified: head/sbin/swapon/swapon.8
==============================================================================
--- head/sbin/swapon/swapon.8   Tue Oct 25 01:46:42 2011        (r226711)
+++ head/sbin/swapon/swapon.8   Tue Oct 25 01:47:33 2011        (r226712)
@@ -35,8 +35,14 @@
 .Nm swapon , swapoff , swapctl
 .Nd "specify devices for paging and swapping"
 .Sh SYNOPSIS
-.Nm swapon Fl aq | Ar
-.Nm swapoff Fl aq | Ar
+.Nm swapon
+.Oo Fl F Ar fstab
+.Oc
+.Fl aq | Ar
+.Nm swapoff
+.Oo Fl F Ar fstab
+.Oc
+.Fl aq | Ar
 .Nm swapctl
 .Op Fl AghklmsU
 .Oo
@@ -99,6 +105,18 @@ must move swapped pages out of the devic
 lead to high system loads for a period of time, depending on how
 much data has been swapped out to that device.
 .Pp
+Other options supported by both
+.Nm swapon
+and
+.Nm swapoff
+are as follows:
+.Bl -tag -width indent
+.It Fl F Ar fstab
+Specify the
+.Pa fstab
+file to use.
+.El
+.Pp
 The
 .Nm swapctl
 utility exists primarily for those familiar with other

Modified: head/sbin/swapon/swapon.c
==============================================================================
--- head/sbin/swapon/swapon.c   Tue Oct 25 01:46:42 2011        (r226711)
+++ head/sbin/swapon/swapon.c   Tue Oct 25 01:47:33 2011        (r226712)
@@ -70,6 +70,7 @@ main(int argc, char **argv)
        int stat;
        int ch, doall;
        int sflag = 0, lflag = 0, hflag = 0, qflag = 0;
+       const char *etc_fstab;
 
        if ((ptr = strrchr(argv[0], '/')) == NULL)
                ptr = argv[0];
@@ -80,7 +81,8 @@ main(int argc, char **argv)
        orig_prog = which_prog;
        
        doall = 0;
-       while ((ch = getopt(argc, argv, "AadghklmqsU")) != -1) {
+       etc_fstab = NULL;
+       while ((ch = getopt(argc, argv, "AadghklmqsUF:")) != -1) {
                switch(ch) {
                case 'A':
                        if (which_prog == SWAPCTL) {
@@ -132,6 +134,9 @@ main(int argc, char **argv)
                                usage();
                        }
                        break;
+               case 'F':
+                       etc_fstab = optarg;
+                       break;
                case '?':
                default:
                        usage();
@@ -140,6 +145,8 @@ main(int argc, char **argv)
        argv += optind;
 
        stat = 0;
+       if (etc_fstab != NULL)
+               setfstab(etc_fstab);
        if (which_prog == SWAPON || which_prog == SWAPOFF) {
                if (doall) {
                        while ((fsp = getfsent()) != NULL) {
@@ -210,7 +217,7 @@ usage(void)
        switch(orig_prog) {
        case SWAPON:
        case SWAPOFF:
-           fprintf(stderr, "-aq | file ...\n");
+           fprintf(stderr, "[-F fstab] -aq | file ...\n");
            break;
        case SWAPCTL:
            fprintf(stderr, "[-AghklmsU] [-a file ... | -d file ...]\n");
_______________________________________________
svn-src-head@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-src-head
To unsubscribe, send any mail to "svn-src-head-unsubscr...@freebsd.org"

Reply via email to