diff options
author | mtm <mtm@FreeBSD.org> | 2008-06-23 22:17:08 +0000 |
---|---|---|
committer | mtm <mtm@FreeBSD.org> | 2008-06-23 22:17:08 +0000 |
commit | 06cbeaa6942a32291d05da26533f5a09d238894f (patch) | |
tree | d809f15133e9096f9965e54e18313122d843e8a6 /sbin/swapon/swapon.c | |
parent | 5b37d9eba744dee55431a0426bafd09eef483fea (diff) | |
download | FreeBSD-src-06cbeaa6942a32291d05da26533f5a09d238894f.zip FreeBSD-src-06cbeaa6942a32291d05da26533f5a09d238894f.tar.gz |
Add a -q flag to swapon(8) to suppress informational messages. Use it in
rc.d.
Note: errors are not affected by this flag.
Diffstat (limited to 'sbin/swapon/swapon.c')
-rw-r--r-- | sbin/swapon/swapon.c | 19 |
1 files changed, 13 insertions, 6 deletions
diff --git a/sbin/swapon/swapon.c b/sbin/swapon/swapon.c index 4fe3b0b..e2cf8ca 100644 --- a/sbin/swapon/swapon.c +++ b/sbin/swapon/swapon.c @@ -69,7 +69,7 @@ main(int argc, char **argv) char *ptr; int stat; int ch, doall; - int sflag = 0, lflag = 0, hflag = 0; + int sflag = 0, lflag = 0, hflag = 0, qflag = 0; if ((ptr = strrchr(argv[0], '/')) == NULL) ptr = argv[0]; @@ -80,7 +80,7 @@ main(int argc, char **argv) orig_prog = which_prog; doall = 0; - while ((ch = getopt(argc, argv, "AadghklmsU")) != -1) { + while ((ch = getopt(argc, argv, "AadghklmqsU")) != -1) { switch(ch) { case 'A': if (which_prog == SWAPCTL) { @@ -117,6 +117,10 @@ main(int argc, char **argv) case 'm': hflag = 'M'; break; + case 'q': + if (which_prog == SWAPON || which_prog == SWAPOFF) + qflag = 1; + break; case 's': sflag = 1; break; @@ -146,9 +150,12 @@ main(int argc, char **argv) if (swap_on_off(fsp->fs_spec, 1)) { stat = 1; } else { - printf("%s: %sing %s as swap device\n", - getprogname(), which_prog == SWAPOFF ? "remov" : "add", - fsp->fs_spec); + if (!qflag) { + printf("%s: %sing %s as swap device\n", + getprogname(), + which_prog == SWAPOFF ? "remov" : "add", + fsp->fs_spec); + } } } } @@ -203,7 +210,7 @@ usage(void) switch(orig_prog) { case SWAPON: case SWAPOFF: - fprintf(stderr, "-a | file ...\n"); + fprintf(stderr, "-aq | file ...\n"); break; case SWAPCTL: fprintf(stderr, "[-AghklmsU] [-a file ... | -d file ...]\n"); |