- Add a clearer error message for the case where swapon hits the

NSWAPDEV limit.
- Don't warn about devices that are not in use in 'swapoff -a'.
- Re-add behavior mistakenly removed in revision 1.44:
  If using 'swapon -a', do not warn if the device is already in use.

PR:		46633
Submitted by:	Andy Farkas <andyf@speednet.com.au> (in part)
Reviewed by:	mike (mentor)
This commit is contained in:
das 2003-02-24 08:51:31 +00:00
parent 1cc0669761
commit 9f419c5edf

View File

@ -140,7 +140,7 @@ main(int argc, char **argv)
continue;
if (strstr(fsp->fs_mntops, "noauto"))
continue;
if (swap_on_off(fsp->fs_spec, 0)) {
if (swap_on_off(fsp->fs_spec, 1)) {
stat = 1;
} else {
printf("%s: %sing %s as swap device\n",
@ -170,14 +170,20 @@ main(int argc, char **argv)
}
static int
swap_on_off(char *name, int ignoreebusy)
swap_on_off(char *name, int doingall)
{
if ((which_prog == SWAPOFF ? swapoff(name) : swapon(name)) == -1) {
switch (errno) {
case EBUSY:
if (!ignoreebusy)
if (!doingall)
warnx("%s: device already in use", name);
break;
case EINVAL:
if (which_prog == SWAPON)
warnx("%s: NSWAPDEV limit reached", name);
else if (!doingall)
warn("%s", name);
break;
default:
warn("%s", name);
break;