diff options
author | sobomax <sobomax@FreeBSD.org> | 2011-10-25 01:47:33 +0000 |
---|---|---|
committer | sobomax <sobomax@FreeBSD.org> | 2011-10-25 01:47:33 +0000 |
commit | 40cf9012a15ea5ea1f020f0afbb0c9012659549f (patch) | |
tree | 694a147829d71f1c4541a36a2562477c3ec2361d /sbin/swapon/swapon.c | |
parent | e1f2c1df247d1210f90b4261ae7b44f3882e2d55 (diff) | |
download | FreeBSD-src-40cf9012a15ea5ea1f020f0afbb0c9012659549f.zip FreeBSD-src-40cf9012a15ea5ea1f020f0afbb0c9012659549f.tar.gz |
Add new option -F to specify alternative location of the /etc/fstab
file.
MFC after: 1 month
Diffstat (limited to 'sbin/swapon/swapon.c')
-rw-r--r-- | sbin/swapon/swapon.c | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/sbin/swapon/swapon.c b/sbin/swapon/swapon.c index e2cf8ca..5e85602 100644 --- a/sbin/swapon/swapon.c +++ b/sbin/swapon/swapon.c @@ -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"); |