History log of /freebsd-10-stable/sbin/swapon/
Revision Date Author Comments
(<<< Hide modified files)
(Show modified files >>>)
316097 28-Mar-2017 amdmi3

MFC r315242: Fix late and noauto with geli swap

With the following in /etc/fstab:

/dev/gpt/swap.eli none swap sw,late 0 0

swap will not be enabled, with `swapon -aL' complaining:

swapon: Invalid option: late

This happens because swap_on_geli_args() which parses geli arguments
out of all mount options does not expect late or noauto among them.
Fix this by explicitly allowing these arguments.

Reviewed by: jilles
Approved by: jilles
Differential Revision: D9835

308886 20-Nov-2016 jilles

MFC r307755: swapoff: Remove only late devices with -aL.

Currently, '/etc/rc.d/swaplate stop' removes all swap devices. This can be
very slow and may not even be possible if there is a lot of swap space in
use. However, removing swap devices is only needed for late swap devices
that may depend on daemons that subsequent shutdown steps stop. Normal swap
devices such as hard disk partitions will remain available throughout the
shutdown process and need not be removed.

In swapoff, interpret -aL to remove late swap devices only, and use this in
etc/rc.d/swaplate. The meaning of -aL in swapon remains unchanged (add all
swap devices, both normal and late).

PR: 187081

308866 19-Nov-2016 jilles

MFC r306585: swapon(8): Update to reality: swapoff ignores -L and the late
option in fstab.

296742 12-Mar-2016 ngie

MFC r295121:

Delete argsize to fix a -Wunused-but-set-variable warning with gcc 4.9

The variable isn't actually checked -- just the end result which gets
returned from the function

292311 16-Dec-2015 ngie

MFC r292005:

Call va_end on ap when vsnprintf fails in run_cmd(..) to clean up
the variable state

Reported by: cppcheck
Sponsored by: EMC / Isilon Storage Division

272960 11-Oct-2014 hrs

MFC r272885:
Do not add late flag when file= is specified because it has a bad
side-effect. The specified file should exist before the fstab line.

259871 25-Dec-2013 pluknet

MFC r258469:

- Purge one more reference to ad(4)[1].
- NSWAPDEV limit has gone.

Noticed by: Sergey V. Dyatko [1]

259820 24-Dec-2013 jilles

MFC r259677: swapon: Fix buffer overflow when configuring swap on GBDE.

PR: bin/184950

256281 10-Oct-2013 gjb

Copy head (r256279) to stable/10 as part of the 10.0-RELEASE cycle.

Approved by: re (implicit)
Sponsored by: The FreeBSD Foundation


255267 05-Sep-2013 hrs

Style clean-ups.

Reviewed by: md5


255265 05-Sep-2013 hrs

Enable "late" option when a file= option is specified in /etc/fstab.
The file= option requires rw mount where the backing store exists but
it does not work because rc.d/swap runs before rc.d/fsck.
Reported by: wblock


253834 31-Jul-2013 delphij

Make two buffer variables static for now. It is not safe to
reference stack memory after return.

MFC after: 2 weeks


252514 02-Jul-2013 delphij

Plug a memory leak.


252480 01-Jul-2013 delphij

Correct a typo in comment.


252388 29-Jun-2013 delphij

- Modify swapon(8) so that it uses most of geli(8) defaults for swap,
which is presently: AES-XTS, no authentication. Create provider
with pagesize as sectorsize by default.
- Rewrite parsing code for geli(8)-backed swap options, now options
are required to be exact match, and unrecognized options will trigger
a warning.
- Don't initialize GELI device if it's already initialized. This
restores previous behavior.
- Don't duplicate file descriptor when working with geli(8) and
gbde(8) as there is no need to communicate with the utility other
than exit status.
- When calling swap_on_off_* routines, which_prog can only be SWAP_ON
or SWAP_OFF. Eliminate unneeded case branches by replacing switch
with if's.
- Plug a few memory leaks.

Reviewed by: hrs (but bugs are mine)
MFC after: 1 week
X-MFC-with: r252310, r252332, r252345


252345 28-Jun-2013 hrs

Fix build with gcc.


252332 28-Jun-2013 hrs

Fix build.

Spotted by: gjb


252310 27-Jun-2013 hrs

- Add vnode-backed swap space specification support. This is enabled when
device names "md" or "md[0-9]*" and a "file" option are specified in
/etc/fstab like this:

md none swap sw,file=/swap.bin 0 0

- Add GBDE/GELI encrypted swap space specification support, which
rc.d/encswap supported. The /etc/fstab lines are like the following:

/dev/ada1p1.bde none swap sw 0 0
/dev/ada1p2.eli none swap sw 0 0

.eli devices accepts aalgo, ealgo, keylen, and sectorsize as options.

swapctl(8) can understand an encrypted device in the command line
like this:

# swapctl -a /dev/ada2p1.bde

- "-L" flag is added to support "late" option to defer swapon until
rc.d/mountlate runs.

- rc.d script change:

rc.d/encswap -> removed
rc.d/addswap -> just display a warning message if $swapfile is defined
rc.d/swap1 -> renamed to rc.d/swap
rc.d/swaplate -> newly added to support "late" option

These changes alleviate a race condition between device creation/removal
and swapon/swapoff.

MFC after: 1 week
Reviewed by: wblock (manual page)


227081 04-Nov-2011 ed

Add missing static keywords for global variables to tools in sbin/.

These tools declare global variables without using the static keyword,
even though their use is limited to a single C-file, or without placing
an extern declaration of them in the proper header file.


226742 25-Oct-2011 ed

Build swapon with WARNS=6.

Don't use a variable called stat, because it collides with stat(2).


226712 25-Oct-2011 sobomax

Add new option -F to specify alternative location of the /etc/fstab
file.

MFC after: 1 month


202532 17-Jan-2010 ed

Raise WARNS for various tools where possible.

Submitted by: Marius Nünnerich <marius@nuenneri.ch>


198236 19-Oct-2009 ru

Switch the default WARNS level for sbin/ to 6.

Submitted by: Ulrich Spörlein


179966 23-Jun-2008 mtm

Add a -q flag to swapon(8) to suppress informational messages. Use it in
rc.d.
Note: errors are not affected by this flag.


179154 20-May-2008 pjd

- Change the meaning of -h flag from giving the output in megabytes to
giving the output in a human-readable form. This behaviour is consistent
with most of system tools.
- Add -m and -g options to give output in megabytes and gigabytes
respectively.


141611 10-Feb-2005 ru

Sync program's usage() with manpage's SYNOPSIS.


140415 18-Jan-2005 ru

Sort sections.


138129 27-Nov-2004 das

Don't include sys/user.h merely for its side-effect of recursively
including other headers.


128073 09-Apr-2004 markm

Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp


126643 05-Mar-2004 markm

Make NULL a (void*)0 whereever possible, and fix the warnings(-Werror)
that this provokes. "Wherever possible" means "In the kernel OR NOT
C++" (implying C).

There are places where (void *) pointers are not valid, such as for
function pointers, but in the special case of (void *)0, agreement
settles on it being OK.

Most of the fixes were NULL where an integer zero was needed; many
of the fixes were NULL where ascii <nul> ('\0') was needed, and a
few were just "other".

Tested on: i386 sparc64


114589 03-May-2003 obrien

Use __FBSDID() to quiet GCC 3.3 warnings.


111654 28-Feb-2003 keramida

Spell "utilities" correctly.


111470 25-Feb-2003 ru

More fixes.

Submitted by: Andy Farkas <andyf@speednet.com.au>
Reviewed by: das


111453 24-Feb-2003 ru

mdoc(7) police: Tidy up.


111425 24-Feb-2003 das

Clarify about NSWAPDEV, add a DIAGNOSTICS section pointing to
swapon(2), and correct HISTORY.

Reviewed by: mike (mentor)


111424 24-Feb-2003 das

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


108459 30-Dec-2002 mike

Remove hack from rev 1.15; getbsize(3)'s original interface has been
restored.


108425 30-Dec-2002 mike

Make the first argument to getbsize(3) a `size_t *'. This is a hack
since getbsize(3) should have `int *' as its first parameter.


108375 28-Dec-2002 dillon

Add 'swapctl' - as a hardlink to swapon/swapoff, and augment swapon with
swapctl functionality. The idea is to create a swapctl command that is
fairly close to the OpenBSD and NetBSD version. FreeBSD does not implement
swap priority (and it would be a mistake if we did) so we didn't bother with
that part of it.

Submitted by: Eirik Nygaard <eirikn@bluezone.no>
Augmented by: dillon (extensively)
Reviewed by: David Schultz <dschultz@uclink.Berkeley.EDU>


107913 15-Dec-2002 dillon

This is David Schultz's swapoff code which I am finally able to commit.
This should be considered highly experimental for the moment.

Submitted by: David Schultz <dschultz@uclink.Berkeley.EDU>
MFC after: 3 weeks


102231 21-Aug-2002 trhodes

s/filesystem/file system/g as discussed on -developers


99503 06-Jul-2002 charnier

The .Nm utility.


92883 21-Mar-2002 imp

o remove __P
o remove main prototype


92806 20-Mar-2002 obrien

Remove 'register' keyword.
It does not help modern compilers, and some may take some hit from it.
(I also found several functions that listed *every* of its 10 local vars with
"register" -- just how many free registers do people think machines have?)


87325 04-Dec-2001 obrien

Default to WARNS=2.
Binary builds that cannot handle this must explicitly set WARNS=0.

Reviewed by: mike


79758 15-Jul-2001 dd

Set WARNS=2 on programs which compile cleanly.

Submitted by: Mike Barcroft <mike@q9media.com>


79530 10-Jul-2001 ru

mdoc(7) police: removed HISTORY info from the .Os call.


78732 24-Jun-2001 dd

Include missing header files which define functions for which gcc has
builtins (e.g., exit, strcmp).


75385 10-Apr-2001 ru

vnconfig(8) -> mdconfig(8).


74815 26-Mar-2001 ru

- Backout botched attempt to introduce MANSECT feature.
- MAN[1-9] -> MAN.


74531 20-Mar-2001 ru

Set the default manual section for sbin/ to 8.


68960 20-Nov-2000 ru

mdoc(7) police: use the new features of the Nm macro.


59216 14-Apr-2000 imp

Add include of errno.h where needed, remove extern int errno where not.

These commits were inspired by a similar commit to netbsd.


57578 28-Feb-2000 gsutter

correct wording in BUGS section; it's not possible to dismount swap
devices, but it's certainly possible to make use of them.

PR: 17013
Submitted by: Giorgos Keramidas <keramida@ceid.upatras.gr>


51669 26-Sep-1999 nik

Mention /dev/vn0b and /dev/vntab. ascii -> ASCII transform had
already happened in an earlier commit.

PR: docs/13645
Submitted by: Stephen Roznowski <sjr@home.com>


51457 20-Sep-1999 phantom

Correct spelling : ascii -> ASCII

PR: docs/13702
Submitted by: Stephen J. Roznowski <sjr@home.com>
Reviewed by: mpp


50476 28-Aug-1999 peter

$Id$ -> $FreeBSD$


47260 17-May-1999 jkoshy

Refer to current names for swap partitions in the `FILES' section.

PR: docs/11709
Submitted by: Matthew D. Fuller <fullermd@over-yonder.net>


38039 03-Aug-1998 charnier

.Nm swapon -> .Nm.
Sort #includes. Add rcsid.


32967 01-Feb-1998 steve

Revert last commit and SEE ALSO pstat(8) instead.

Submitted by: Bruce Evans


32774 25-Jan-1998 steve

SEE ALSO swapinfo(8).

PR: 5447
Submitted by: Craig Leres <leres@ee.lbl.gov>


28771 26-Aug-1997 imp

.Xr vnconfig 8. This was suggested by Dworkin Muller <dworkin@village.org>
when he tried to figure out how to swap to a file and had to ask me for
help.


26740 19-Jun-1997 charnier

Use warn(3).


24359 29-Mar-1997 imp

compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.


22990 22-Feb-1997 peter

Revert $FreeBSD$ to $Id$


21673 14-Jan-1997 jkh

Make the long-awaited change from $Id$ to $FreeBSD$

This will make a number of things easier in the future, as well as (finally!)
avoiding the Id-smashing problem which has plagued developers for so long.

Boy, I'm glad we're not using sup anymore. This update would have been
insane otherwise.


18480 23-Sep-1996 wosch

add missing comma(s) in .Xr macros


18073 06-Sep-1996 jkh

Make the noauto flag usable for swap devices too. Closes PR#1542
Submitted-By: David Leonard <d@scry.dstc.edu.au>


8502 14-May-1995 dg

Take out special error message for EINVAL...we really do want it to be
"invalid argument".


6661 23-Feb-1995 phk

Fix -Wall warnings.

Yes I have better things to do, but just now I'm waiting...


6513 17-Feb-1995 jkh

fstab is in section 5, not section 8.
Obtained from: NetBSD


1855 05-Aug-1994 wollman

Convert to our man installation style. Also fixed long-standing bug
in `fastboot'/`fasthalt' in which the interpreter would hang around
after `reboot' or `halt' is run, causing an irritating ``Killed'' message.


1559 26-May-1994 rgrimes

This commit was generated by cvs2svn to compensate for changes in r1558,
which included commits to RCS files with non-trunk default branches.