summaryrefslogtreecommitdiffstats
path: root/sbin/swapon
diff options
context:
space:
mode:
authormtm <mtm@FreeBSD.org>2008-06-23 22:17:08 +0000
committermtm <mtm@FreeBSD.org>2008-06-23 22:17:08 +0000
commit06cbeaa6942a32291d05da26533f5a09d238894f (patch)
treed809f15133e9096f9965e54e18313122d843e8a6 /sbin/swapon
parent5b37d9eba744dee55431a0426bafd09eef483fea (diff)
downloadFreeBSD-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')
-rw-r--r--sbin/swapon/swapon.814
-rw-r--r--sbin/swapon/swapon.c19
2 files changed, 24 insertions, 9 deletions
diff --git a/sbin/swapon/swapon.8 b/sbin/swapon/swapon.8
index 1af8d99..40dba74 100644
--- a/sbin/swapon/swapon.8
+++ b/sbin/swapon/swapon.8
@@ -28,15 +28,15 @@
.\" @(#)swapon.8 8.1 (Berkeley) 6/5/93
.\" $FreeBSD$
.\"
-.Dd April 29, 2008
+.Dd June 23, 2008
.Dt SWAPON 8
.Os
.Sh NAME
.Nm swapon , swapoff , swapctl
.Nd "specify devices for paging and swapping"
.Sh SYNOPSIS
-.Nm swapon Fl a | Ar
-.Nm swapoff Fl a | Ar
+.Nm swapon Fl aq | Ar
+.Nm swapoff Fl aq | Ar
.Nm swapctl
.Op Fl AghklmsU
.Oo
@@ -69,6 +69,10 @@ option is used, all swap devices in
will be added, unless their
.Dq noauto
option is also set.
+If the
+.Fl q
+option is used informational messages will not be
+written to standard output when a swap device is added.
.Pp
The
.Nm swapoff
@@ -80,6 +84,10 @@ option is used, all swap devices in
will be removed, unless their
.Dq noauto
option is also set.
+If the
+.Fl q
+option is used informational messages will not be
+written to standard output when a swap device is removed.
Note that
.Nm swapoff
will fail and refuse to remove a swap device if there is insufficient
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");
OpenPOWER on IntegriCloud