Commit Graph

43 Commits

Author SHA1 Message Date
kre 5747acc12f Fix a typo in a newly added comment.
Someone please tell me why these things become obvious only after
the code has been committed!

NFC
2023-03-01 15:18:18 +00:00
kre 5a71a00fea When processing swapon -a (or swapctl -A, or swapctl -U) ignore lines in
fstab that have nothing to do with swapping (fs_type is neither "sw" nor "dp")
before running getfsspecname() on the fs_spec field of the line.

This avoids entries like this:

NAME=OFTEN_UNCONNECTED   /local/archived ffs     rw,log,noauto    0 0

in fstab from generating spurious error messages when the wedge named
is not currently connected to the system - that is the drive on which the
wedge exists is not connected, or not powered on.   "noauto" handles that
for some other uses, the "0"s in fs_freq and fs_passno work for other uses,
but swap{on,ctl} never look at those fields (not for this purpose).

Non "sw"/"dp" lines were being ignored anyway, but not until (a little) later.
2023-03-01 15:15:56 +00:00
andvar e82c4d9bb4 fix various typos, mainly in comments. 2022-04-04 19:33:44 +00:00
mrg 28d34520d5 don't stop processing /etc/fstab when one entry fails, both for
add and remove loops.  now when you add a new swap file and run
"swapctl -A" it won't give up after the existing one gives EBUSY
and move on to the rest.
2015-10-11 23:58:16 +00:00
dsl 249ad9a058 Explicitly include sys/ioctl.h 2013-01-01 19:01:10 +00:00
mlelstv 153341a17d Allow named wedges to be used on command line, also fix name lookup
for the dump device.
2012-12-26 10:15:28 +00:00
christos 5727fadda2 use getfsspecname() 2012-04-07 04:52:20 +00:00
joerg b79356001b static + __dead 2011-08-27 18:57:50 +00:00
apb 29d1bfefcb Make the exit status from "swapctl -A" and "swapctl -U" tri-state:
0 for success; 1 for error; and 2 when no devices of the appropriate type
are defined in fstab(5).  Previously, "no apropriate devices" was
indistinguishable from "error".
2009-09-24 16:15:20 +00:00
christos 118c87a6fe fix dev_t format. 2008-12-28 20:17:11 +00:00
mrg c2b95373bf remove clause #3 from my license where there are no other
copyright holders involved.
2008-05-29 14:51:25 +00:00
martin 0a4f0b6f07 As discussed on tech-userlevel: enhance the -A/-U commands to take a -t
auto flag, which queries all local harddisks for swap partitions/
wedges and adds/removes them as swap device, a -f option to use the
first found swap device as dump device, and a -o option to only
auto-configure the dump device, but leave swap alone.

Add a -n option to make swapctl only say what it would do, but not
change any system state.
2006-08-27 21:07:39 +00:00
wiz d728febe7a Sort options. Sync usage with man page. 2006-08-23 20:59:09 +00:00
martin b99b0d9adb Allow unsetting the dump device via "swapctl -D none".
For -l (list swap partitions) and -z (list dump device) return a usefull
error status, so scripts can easily decide if swap or dump are configured.
2006-08-22 14:08:36 +00:00
christos 85a5de064c Remove some const. This is better than using __UNCONST at the second
argument of swapctl.
2005-06-12 16:24:20 +00:00
xtraeme f7f1785232 Kill __P(), use ANSI function declarations, constify; WARNS=3.
Reviewed by mrg@.
2005-02-09 05:51:38 +00:00
lukem 04eb493802 support RESCUEDIR (for mount_nfs and umount) 2005-01-10 20:53:48 +00:00
cjep 7ef0be1b58 Fix usage string (i.e. add information about -z). Fixes PR#25865 from
Kouichirou Hiratsuka.
2004-06-08 08:13:16 +00:00
mrg 9bf440d20b support "-g" and "-m" as well as "-k" and "-h". swapctl & swaplist code
from Martin Weber, adapted for pstat by myself.
2003-12-20 13:31:42 +00:00
mrg 5fd013c40d add a "-h" (humanize_number(3)) option to swapctl(8) and pstat(8), from
Martin Weber in PR#23805.

ps: now we only need someone to do ls(1) :-)
2003-12-20 11:22:25 +00:00
fvdl 34951ed447 The 3rd argument to swapctl() is an int, don't pass NULL in it. 2003-10-21 02:32:54 +00:00
agc c2a3b5ec84 Add NetBSD RCS Ids. 2003-06-23 11:53:35 +00:00
drochner b4f44c1118 print something sensible on -z if no dump device is set 2002-09-18 10:18:17 +00:00
jdolecek d1f10f9f74 Support 'dp' as mount option for 'sw' fstype, so it DTRT for entries like:
/dev/wd0b none swap sw,dp 0 0
2002-06-21 09:04:16 +00:00
pooka 633273af12 Add word "WARNING" when complaining about swap being world-read/writeable
to clarify that this was not an error condition and that swap was indeed
added despite the problem.
2001-11-26 15:23:38 +00:00
cgd 8a986b2e96 convert to use getprogname() 2001-02-19 22:48:57 +00:00
lukem ddbba91107 fix incorrect comment; -d does work! 2000-11-17 12:35:09 +00:00
mrg f44b54e376 support new `swapctl -z' that shows the dump device. 2000-11-17 11:43:41 +00:00
itojun ddf8cb2acb warnx?/errx? audit. don't pass variable/function return value alone.
use with "%s".  from openbsd.
2000-07-07 12:29:09 +00:00
mrg 90bc324a8d use <sys/swap.h>. should have happened years ago. 2000-04-13 08:29:56 +00:00
soren 89c5a767f8 Fix doubled 'the's. 2000-03-13 22:55:05 +00:00
lukem 655afb7cd6 * add support for -U, which is the opposite of -A (i.e, it unconfigures
all swap devices in /etc/fstab).
* fix description of -D
2000-03-05 11:35:22 +00:00
mrg ae3b9e217c add a -D line to usage(). 1999-04-26 01:02:25 +00:00
mrg bdadd56346 add a new fstab type "dp" for the user-specified dump device.
change swapctl -A to see this and add it via swapctl(2).  also
add a new swapctl -D <device> to change the dump device on the
fly.
1999-02-23 17:00:53 +00:00
mycroft 0e3ffd8405 const poisoning. 1998-07-26 20:23:15 +00:00
mrg 2fe3f46005 make swapctl exit with non-zero if -A and nothing swapped on 1998-02-10 03:14:32 +00:00
mrg 74f573d85d remove advertising clause from all my licenses. 1997-10-10 05:39:47 +00:00
lukem 0a96848668 * fix .Nm usage
* prototype main() for WARNS=1
1997-09-15 11:21:59 +00:00
mikel 8b691f3aee add comparisons to NULL implicit in my last changes 1997-07-11 03:36:27 +00:00
thorpej 2ea04e4383 Add a "-t blk|noblk" device type option to swapctl -A. This allows the
user to specify "only add block devices" or "only add non-block devices".
This is useful during early system startup where swapping may be needed
before swap files are available (e.g. if fsck'ing large file systems).
1997-06-25 23:18:10 +00:00
mikel 6b2081e1f5 include <err.h> for err*() and warn*() prototypes
cast long to int for use by printf("%d",..)
add parens for gcc -Wall
1997-06-24 05:22:38 +00:00
thorpej 0d769d1d10 Totally rework the command parsing, eliminating a few walk-offs of
bogus pointers, etc.
1997-06-15 03:47:53 +00:00
mrg 01a7eafbaa swapctl program for new swap code. 1997-06-12 13:14:11 +00:00