[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
swapon/swapoff
From: |
Alfred M. Szmidt |
Subject: |
swapon/swapoff |
Date: |
Sat, 05 Feb 2005 18:10:33 +0100 |
I find it stupid that swapon defaults to --no-signature, one could by
accident type another device other then the one intended. This
changes the default behaviour to only setup swap ifthere is a
Linux-swap signature.
Another thing I found stupid is to have swapon exit with a non-zero
exit status if no swap partitions could be found in _PATH_MNTTAB.
This changes so that it just prints a warning.
(also a bunch of stylistic fixes to error/warning messages to be more
GNUish, but no ChangeLog entry for those)
2005-02-05 Alfred M. Szmidt <ams@gnu.org>
* swapon.c (main): Just print a warning if we couldn't find
any swap partitions in _PATH_MNTTAB instead of exiting.
* swapon.c (require_signature) [SWAPOFF]: Initialise to 0.
(ignore_signature) [SWAPOFF]: Initialise to 1.
(require_signature) [!SWAPOFF]: Initialise to 1.
(ignore_signature) [!SWAPOFF]: Initialise to 0.
Index: sutils/swapon.c
===================================================================
RCS file: /cvsroot/hurd/hurd/sutils/swapon.c,v
retrieving revision 1.9
diff -u -r1.9 swapon.c
--- sutils/swapon.c 26 Jun 2002 18:19:07 -0000 1.9
+++ sutils/swapon.c 5 Feb 2005 16:55:28 -0000
@@ -1,6 +1,6 @@
/* Add/remove paging devices
- Copyright (C) 1997,98,99,2000,01,02 Free Software Foundation, Inc.
+ Copyright (C) 1997,98,99,2000,01,02,05 Free Software Foundation, Inc.
Written by Miles Bader <miles@gnu.org>
This file is part of the GNU Hurd.
@@ -35,11 +35,17 @@
#ifdef SWAPOFF
const char *argp_program_version = STANDARD_HURD_VERSION (swapoff);
+
+static int require_signature = 0;
+static int ignore_signature = 1;
#else
const char *argp_program_version = STANDARD_HURD_VERSION (swapon);
+
+static int require_signature = 1;
+static int ignore_signature = 0;
#endif
-static int ignore_signature, require_signature, quiet;
+static int quiet;
static struct argp_option options[] =
{
@@ -230,7 +236,7 @@
name);
return EINVAL;
}
- error (0, 0, "WARNING: ignoring unrecognized signature page");
+ error (0, 0, "warning: ignoring unrecognized signature page");
return EFTYPE;
case 1:
@@ -334,7 +340,7 @@
it will read the signature page (but not insist on it). */
if (! (store->flags & STORE_ENFORCED))
{
- error (0, 0, "%s: Can only page to the entire device", file);
+ error (0, 0, "%s: can only page to the entire device", file);
return EINVAL;
}
/* If we want to require the signature, we can check that it is
@@ -363,7 +369,7 @@
if (store->class != &store_device_class)
{
- error (0, 0, "%s: Can't get underlying device", file);
+ error (0, 0, "%s: can't get underlying device", file);
store_free (store);
return EINVAL;
}
@@ -386,14 +392,14 @@
else
{
if (err)
- error (12, err, "Cannot get privileged ports");
+ error (12, err, "cannot get privileged ports");
err = vm_set_default_memory_manager (host, &def_pager);
mach_port_deallocate (mach_task_self (), host);
if (err)
- error (13, err, "Cannot get default pager port");
+ error (13, err, "cannot get default pager port");
if (def_pager == MACH_PORT_NULL)
- error (14, 0, "No default pager (memory manager) is running!");
+ error (14, 0, "no default pager is running!");
}
}
@@ -496,7 +502,7 @@
f = setmntent (_PATH_MNTTAB, "r");
if (f == NULL)
- error (1, errno, "Cannot read %s", _PATH_MNTTAB);
+ error (1, errno, "cannot read %s", _PATH_MNTTAB);
else
{
int done = 0, err = 0;
@@ -508,7 +514,8 @@
err |= swaponoff (me->mnt_fsname, ONOFF);
}
if (done == 0)
- error (2, 0, "No swap partitions found in %s", _PATH_MNTTAB);
+ error (0, 0, "warning: no swap partitions found in %s",
+ _PATH_MNTTAB);
else if (err)
return 1;
}
- swapon/swapoff,
Alfred M. Szmidt <=