Add a -q flag to swapon(8) to suppress informational messages. Use it in

rc.d.
Note: errors are not affected by this flag.
This commit is contained in:
Mike Makonnen 2008-06-23 22:17:08 +00:00
parent d9fcd86c3a
commit 45a5dc937d
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=179966
3 changed files with 25 additions and 10 deletions

View file

@ -10,7 +10,7 @@
. /etc/rc.subr
name="swap1"
start_cmd='swapon -a'
start_cmd='swapon -aq'
stop_cmd=':'
load_rc_config swap

View file

@ -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

View file

@ -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");