Home | History | Annotate | only in /src/sbin/swapctl
History log of /src/sbin/swapctl
RevisionDateAuthorComments
 1.5 27-Aug-2006  martin 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.
 1.4 27-Jun-2005  christos Move WARNS=3 to the Makefile.inc, and add a little const to the remaining
programs that did not compile before.
 1.3 09-Feb-2005  xtraeme Kill __P(), use ANSI function declarations, constify; WARNS=3.

Reviewed by mrg@.
 1.2 12-Jun-1997  mrg link to swapon.
 1.1 12-Jun-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 12-Jun-1997  mrg swapctl program for new swap code.
 1.46 08-Jul-2024  pgoyette s/point mount/mount point/
 1.45 04-Feb-2024  mrg branches: 1.45.2;
update my email address.
 1.44 18-Mar-2014  riastradh Merge riastradh-drm2 to HEAD.
 1.43 20-Jul-2013  wiz Use Mt for email addresses.
 1.42 01-Jun-2011  jruoho branches: 1.42.4; 1.42.10; 1.42.14;
Clarify placement of commas. From Snader_LB on freenode/#netbsd-code.
 1.41 24-Sep-2009  apb 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".
 1.40 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.39 02-Aug-2007  he branches: 1.39.10; 1.39.12; 1.39.14; 1.39.16;
Re-phrase description of -A option, as per suggestion from Jukka Salmi
at netbsd-users@ and with a slight tweak by myself -- at the end the last
dump device will remain as the single active dump device.
Fix a nearby typo.
Bump date.
 1.38 02-Sep-2006  wiz Sort sections. Fix typo. Start sentence with upper-case letter.
 1.37 27-Aug-2006  martin Add a caveats section describing potential problems with autoconfigured
swap partitons.
 1.36 27-Aug-2006  martin 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.
 1.35 23-Aug-2006  wiz Sort options. Sync usage with man page.
 1.34 23-Aug-2006  wiz Sort sections. Fix typos.
 1.33 22-Aug-2006  martin Only one -D synopsis line
 1.32 22-Aug-2006  martin 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.
 1.31 08-Jun-2004  wiz Drop trailing whitespace.
 1.30 08-Jun-2004  cjep Add options for swapon in the Synopsis section. Closes PR#25866 from
Kouichirou Hiratsuka.
 1.29 21-Dec-2003  mrg branches: 1.29.2;
bump date for previous
 1.28 20-Dec-2003  mrg support "-g" and "-m" as well as "-k" and "-h". swapctl & swaplist code
from Martin Weber, adapted for pstat by myself.
 1.27 20-Dec-2003  mrg 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) :-)
 1.26 25-Feb-2003  wiz .Nm does not need a dummy argument ("") before punctuation or
for correct formatting of the SYNOPSIS any longer.
 1.25 24-Jan-2003  hubertf Mention that the mount point for a remote swap file must exist as a directory.
Sanity checked by salo.
 1.24 01-Oct-2002  wiz New sentence, new line. Use some more mdoc.
 1.23 08-Feb-2002  ross Generate <>& symbolically. I'm avoiding .../dist/... directories for now.
 1.22 16-Nov-2001  wiz Sort sections, use standard section headers.
 1.21 01-Oct-2001  wiz Remove swapoff mention, per misc/14120.
Some whitespace, section name, section order fixes while I'm here.
 1.20 05-Jun-2001  wiz Drop arguments of .Os.
 1.19 11-Apr-2001  mrg add a section on swap priorities. document the round robin scheme.
fixes half of PR#12610.
 1.18 17-Nov-2000  mrg support new `swapctl -z' that shows the dump device.
 1.17 05-Mar-2000  lukem * add support for -U, which is the opposite of -A (i.e, it unconfigures
all swap devices in /etc/fstab).
* fix description of -D
 1.16 13-Jan-2000  ad swapctl(SWAP_OFF, ...) now works.
 1.15 23-Feb-1999  mrg 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.
 1.14 22-May-1998  msaitoh sort entries and delete extra periods in SEE also section.
 1.13 10-Feb-1998  mrg make swapctl exit with non-zero if -A and nothing swapped on
 1.12 26-Jan-1998  ross Typo corrections.
 1.11 11-Nov-1997  mrg add missing .Nm sections.
 1.10 23-Oct-1997  mrg oops; forgot to update the license here.
 1.9 20-Oct-1997  enami branches: 1.9.2;
Fix .Nm usage.
 1.8 15-Sep-1997  lukem * fix .Nm usage
* prototype main() for WARNS=1
 1.7 03-Aug-1997  mikel note that swapoff is unsupported; from Brian Grayson in PR misc/3930
 1.6 26-Jun-1997  perry move -t option to stand on its own and change a bit.
add a WARNINGS about the dangers of running without swap or only using
swap files if you have local disk to fsck.
 1.5 25-Jun-1997  thorpej 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).
 1.4 15-Jun-1997  mrg note what N in priority=N means.
 1.3 15-Jun-1997  mrg make option lists much clearer.
 1.2 15-Jun-1997  mrg document nfsmntpt option, re-arrange a little.
 1.1 12-Jun-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 12-Jun-1997  mrg swapctl program for new swap code.
 1.9.2.2 11-Nov-1997  mrg pull up from trunk: add missing .Nm sections.
 1.9.2.1 23-Oct-1997  mrg pull up from trunk: oops; forgot to update the license here.
 1.29.2.1 13-Jun-2004  jdc Pull up revision 1.30 (requested by cjep in ticket #460).

Add options for swapon in the Synopsis section. Closes PR#25866 from
Kouichirou Hiratsuka.
 1.39.16.2 02-Aug-2007  he Re-phrase description of -A option, as per suggestion from Jukka Salmi
at netbsd-users@ and with a slight tweak by myself -- at the end the last
dump device will remain as the single active dump device.
Fix a nearby typo.
Bump date.
 1.39.16.1 02-Aug-2007  he file swapctl.8 was added on branch matt-mips64 on 2007-08-02 18:53:47 +0000
 1.39.14.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.39.12.1 04-Jun-2008  yamt sync with head
 1.39.10.1 02-Jun-2008  mjf Sync with HEAD.
 1.42.14.1 23-Jul-2013  riastradh sync with HEAD
 1.42.10.1 20-Aug-2014  tls Rebase to HEAD as of a few days ago.
 1.42.4.1 22-May-2014  yamt sync with head.

for a reference, the tree before this commit was tagged
as yamt-pagecache-tag8.

this commit was splitted into small chunks to avoid
a limitation of cvs. ("Protocol error: too many arguments")
 1.45.2.1 02-Aug-2025  perseant Sync with HEAD
 1.43 01-Mar-2023  kre 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
 1.42 01-Mar-2023  kre 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.
 1.41 04-Apr-2022  andvar fix various typos, mainly in comments.
 1.40 11-Oct-2015  mrg 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.
 1.39 01-Jan-2013  dsl Explicitly include sys/ioctl.h
 1.38 26-Dec-2012  mlelstv Allow named wedges to be used on command line, also fix name lookup
for the dump device.
 1.37 07-Apr-2012  christos branches: 1.37.2;
use getfsspecname()
 1.36 27-Aug-2011  joerg branches: 1.36.2;
static + __dead
 1.35 24-Sep-2009  apb 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".
 1.34 28-Dec-2008  christos fix dev_t format.
 1.33 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.32 27-Aug-2006  martin branches: 1.32.18; 1.32.20; 1.32.22;
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.
 1.31 23-Aug-2006  wiz Sort options. Sync usage with man page.
 1.30 22-Aug-2006  martin 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.
 1.29 12-Jun-2005  christos Remove some const. This is better than using __UNCONST at the second
argument of swapctl.
 1.28 09-Feb-2005  xtraeme Kill __P(), use ANSI function declarations, constify; WARNS=3.

Reviewed by mrg@.
 1.27 10-Jan-2005  lukem support RESCUEDIR (for mount_nfs and umount)
 1.26 08-Jun-2004  cjep Fix usage string (i.e. add information about -z). Fixes PR#25865 from
Kouichirou Hiratsuka.
 1.25 20-Dec-2003  mrg branches: 1.25.2;
support "-g" and "-m" as well as "-k" and "-h". swapctl & swaplist code
from Martin Weber, adapted for pstat by myself.
 1.24 20-Dec-2003  mrg 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) :-)
 1.23 21-Oct-2003  fvdl The 3rd argument to swapctl() is an int, don't pass NULL in it.
 1.22 23-Jun-2003  agc Add NetBSD RCS Ids.
 1.21 18-Sep-2002  drochner print something sensible on -z if no dump device is set
 1.20 21-Jun-2002  jdolecek Support 'dp' as mount option for 'sw' fstype, so it DTRT for entries like:
/dev/wd0b none swap sw,dp 0 0
 1.19 26-Nov-2001  pooka 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.
 1.18 19-Feb-2001  cgd convert to use getprogname()
 1.17 17-Nov-2000  lukem fix incorrect comment; -d does work!
 1.16 17-Nov-2000  mrg support new `swapctl -z' that shows the dump device.
 1.15 07-Jul-2000  itojun warnx?/errx? audit. don't pass variable/function return value alone.
use with "%s". from openbsd.
 1.14 13-Apr-2000  mrg branches: 1.14.4;
use <sys/swap.h>. should have happened years ago.
 1.13 13-Mar-2000  soren Fix doubled 'the's.
 1.12 05-Mar-2000  lukem * add support for -U, which is the opposite of -A (i.e, it unconfigures
all swap devices in /etc/fstab).
* fix description of -D
 1.11 26-Apr-1999  mrg add a -D line to usage().
 1.10 23-Feb-1999  mrg 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.
 1.9 26-Jul-1998  mycroft const poisoning.
 1.8 10-Feb-1998  mrg make swapctl exit with non-zero if -A and nothing swapped on
 1.7 10-Oct-1997  mrg remove advertising clause from all my licenses.
 1.6 15-Sep-1997  lukem * fix .Nm usage
* prototype main() for WARNS=1
 1.5 11-Jul-1997  mikel add comparisons to NULL implicit in my last changes
 1.4 25-Jun-1997  thorpej 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).
 1.3 24-Jun-1997  mikel include <err.h> for err*() and warn*() prototypes
cast long to int for use by printf("%d",..)
add parens for gcc -Wall
 1.2 15-Jun-1997  thorpej Totally rework the command parsing, eliminating a few walk-offs of
bogus pointers, etc.
 1.1 12-Jun-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 12-Jun-1997  mrg swapctl program for new swap code.
 1.14.4.1 27-Jul-2000  itojun pullup (approved by releng-1-5)
printf-like format pedant. do not pass string variable alone. use "%s".
from openbsd.

/cvsroot/basesrc/sbin/swapctl/swapctl.c 1.14 -> 1.15
/cvsroot/basesrc/sbin/ping6/ping6.c 1.15 -> 1.16
/cvsroot/basesrc/sbin/disklabel/disklabel.c 1.84 -> 1.85
/cvsroot/basesrc/sbin/ccdconfig/ccdconfig.c 1.30 -> 1.31
 1.25.2.1 13-Jun-2004  jdc Pull up revision 1.26 (requested by cjep in ticket #460).

Fix usage string (i.e. add information about -z). Fixes PR#25865 from
Kouichirou Hiratsuka.
 1.32.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.32.20.1 04-Jun-2008  yamt sync with head
 1.32.18.2 17-Jan-2009  mjf Sync with HEAD.
 1.32.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.36.2.2 23-Jan-2013  yamt sync with head
 1.36.2.1 17-Apr-2012  yamt sync with head
 1.37.2.1 25-Feb-2013  tls resync with head
 1.6 29-May-2008  mrg remove clause #3 from my license where there are no other
copyright holders involved.
 1.5 22-Aug-2006  martin branches: 1.5.18; 1.5.20; 1.5.22;
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.
 1.4 09-Feb-2005  xtraeme Kill __P(), use ANSI function declarations, constify; WARNS=3.

Reviewed by mrg@.
 1.3 20-Dec-2003  mrg 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) :-)
 1.2 10-Oct-1997  mrg remove advertising clause from all my licenses.
 1.1 12-Jun-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 12-Jun-1997  mrg swapctl program for new swap code.
 1.5.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.5.20.1 04-Jun-2008  yamt sync with head
 1.5.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.19 11-Dec-2023  mlelstv Avoid overflow of totals.
 1.18 31-May-2016  pgoyette Minor formatting change in swapctl -l as noted in my PR bin/51155
 1.17 06-Apr-2009  lukem redo previous to fix amd64 build
 1.16 06-Apr-2009  lukem fix sign-compare issue
 1.15 29-May-2008  mrg branches: 1.15.4;
remove clause #3 from my license where there are no other
copyright holders involved.
 1.14 22-Aug-2006  martin branches: 1.14.18; 1.14.20; 1.14.22;
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.
 1.13 09-Feb-2005  xtraeme Kill __P(), use ANSI function declarations, constify; WARNS=3.

Reviewed by mrg@.
 1.12 20-Dec-2003  mrg support "-g" and "-m" as well as "-k" and "-h". swapctl & swaplist code
from Martin Weber, adapted for pstat by myself.
 1.11 20-Dec-2003  mrg 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) :-)
 1.10 23-Jun-2003  agc Add NetBSD RCS Ids.
 1.9 19-Aug-2000  soren Add space in summary printf.
 1.8 08-Oct-1998  mrg branches: 1.8.10;
print the strerror if swapctl fails.
 1.7 29-Aug-1998  mrg <vm/vm_swap.h> -> <sys/swap.h>
 1.6 29-Aug-1998  mrg add a `char se_path[PATH_MAX]' member to struct swapent, that
the pathname of the swap device is saved into. add a char *swd_path
member to struct swapdev, that contains a copy of the pathname
(using malloc(9)). rename swapctl(2)'s SWAP_STATS to SWAP_OSTATS,
and add a new SWAP_STATS command (number). make swapctl(SWAP_STATS,
...) [new version] copy the path out. if COMPAT_13, also include
support for SWAP_OSTATS. also fix a minor bug in swapctl(2).

the point of this is that swapfiles are now shown in `swapctl -l'.
 1.5 17-Jun-1998  ross Fix this to correctly do swapctl -l for regions > 2^31 bytes.
We include <inttypes.h> in case at some point in the future we do things
the SUSV2 way and originate the 64-bit scalar defs there.
 1.4 10-Oct-1997  mrg branches: 1.4.2;
remove advertising clause from all my licenses.
 1.3 21-Jul-1997  mrg free() what you malloc().
 1.2 25-Jun-1997  mikel include <err.h> for err*() and warn*() prototypes
fix some printf() formats to take long args instead of int
 1.1 12-Jun-1997  mrg branches: 1.1.1;
Initial revision
 1.1.1.1 12-Jun-1997  mrg swapctl program for new swap code.
 1.4.2.1 25-Sep-1998  cgd Pull up part of rev 1.6 ("test correct return value", mrg)
 1.8.10.1 03-Sep-2000  soren Pull up rev 1.9:
> date: 2000/08/19 21:31:58; author: soren; state: Exp; lines: +2 -2
> Add space in summary printf.
 1.14.22.1 23-Jun-2008  wrstuden Sync w/ -current. 34 merge conflicts to follow.
 1.14.20.1 04-Jun-2008  yamt sync with head
 1.14.18.1 02-Jun-2008  mjf Sync with HEAD.
 1.15.4.1 13-May-2009  jym Sync with HEAD.

Third (and last) commit. See http://mail-index.netbsd.org/source-changes/2009/05/13/msg221222.html

RSS XML Feed