Commit Graph

35 Commits

Author SHA1 Message Date
Hiroki Sato
4139627db6 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
2013-09-05 20:50:52 +00:00
Xin LI
5428273365 Make two buffer variables static for now. It is not safe to
reference stack memory after return.

MFC after:	2 weeks
2013-07-31 07:09:35 +00:00
Xin LI
1bf9e66cbc Plug a memory leak. 2013-07-02 17:34:34 +00:00
Xin LI
0d8a14f9b1 Correct a typo in comment. 2013-07-01 21:18:39 +00:00
Xin LI
8f8de1e127 - 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
2013-06-29 22:04:04 +00:00
Hiroki Sato
d122ff71eb Fix build with gcc. 2013-06-28 16:24:14 +00:00
Hiroki Sato
cb754f614f Fix build.
Spotted by:	gjb
2013-06-28 05:09:01 +00:00
Hiroki Sato
268a55bc98 - 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)
2013-06-27 18:28:45 +00:00
Ed Schouten
1efe3c6b58 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.
2011-11-04 13:36:02 +00:00
Ed Schouten
ce458f4239 Build swapon with WARNS=6.
Don't use a variable called stat, because it collides with stat(2).
2011-10-25 17:10:15 +00:00
Maxim Sobolev
633d2bc579 Add new option -F to specify alternative location of the /etc/fstab
file.

MFC after:	1 month
2011-10-25 01:47:33 +00:00
Mike Makonnen
45a5dc937d Add a -q flag to swapon(8) to suppress informational messages. Use it in
rc.d.
Note: errors are not affected by this flag.
2008-06-23 22:17:08 +00:00
Pawel Jakub Dawidek
2e64768c87 - 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.
2008-05-20 12:24:31 +00:00
Ruslan Ermilov
8d646af581 Sync program's usage() with manpage's SYNOPSIS. 2005-02-10 09:19:34 +00:00
David Schultz
6004362e66 Don't include sys/user.h merely for its side-effect of recursively
including other headers.
2004-11-27 06:51:39 +00:00
Mark Murray
4c723140a4 Remove advertising clause from University of California Regent's license,
per letter dated July 22, 1999.

Approved by: core, imp
2004-04-09 19:58:40 +00:00
Mark Murray
16fc3635f7 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
2004-03-05 08:10:19 +00:00
David E. O'Brien
c69284ca08 Use __FBSDID() to quiet GCC 3.3 warnings. 2003-05-03 18:41:59 +00:00
David Schultz
4937798d56 - 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)
2003-02-24 08:51:31 +00:00
Mike Barcroft
9255f32701 Remove hack from rev 1.15; getbsize(3)'s original interface has been
restored.
2002-12-30 18:24:14 +00:00
Mike Barcroft
69095b0264 Make the first argument to getbsize(3) a `size_t *'. This is a hack
since getbsize(3) should have `int *' as its first parameter.
2002-12-30 05:35:06 +00:00
Matthew Dillon
a420c8119a 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>
2002-12-28 23:39:47 +00:00
Matthew Dillon
92da00bb24 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
2002-12-15 19:17:57 +00:00
Warner Losh
d476a036e2 o remove __P
o remove main prototype
2002-03-21 13:20:49 +00:00
David E. O'Brien
3d438ad61f 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?)
2002-03-20 17:55:10 +00:00
Dima Dorfman
cafefe8c1b Include missing header files which define functions for which gcc has
builtins (e.g., exit, strcmp).
2001-06-24 23:04:23 +00:00
Warner Losh
37736675d1 Add include of errno.h where needed, remove extern int errno where not.
These commits were inspired by a similar commit to netbsd.
2000-04-14 06:15:01 +00:00
Peter Wemm
7f3dea244c $Id$ -> $FreeBSD$ 1999-08-28 00:22:10 +00:00
Philippe Charnier
e798a806ce .Nm swapon -> .Nm.
Sort #includes. Add rcsid.
1998-08-03 06:35:01 +00:00
Philippe Charnier
6da7f3783b Use warn(3). 1997-06-19 14:40:41 +00:00
Warner Losh
8d64695c7c compare return value from getopt against -1 rather than EOF, per the final
posix standard on the topic.
1997-03-29 03:33:12 +00:00
Jordan K. Hubbard
7fc4a454e2 Make the noauto flag usable for swap devices too. Closes PR#1542
Submitted-By: David Leonard <d@scry.dstc.edu.au>
1996-09-06 06:01:05 +00:00
David Greenman
43e6fcd576 Take out special error message for EINVAL...we really do want it to be
"invalid argument".
1995-05-14 02:18:18 +00:00
Poul-Henning Kamp
38994f93ce Fix -Wall warnings.
Yes I have better things to do, but just now I'm waiting...
1995-02-23 07:05:01 +00:00
Rodney W. Grimes
8fae3551ec BSD 4.4 Lite sbin Sources
Note:  XNSrouted and routed NOT imported here, they shall be imported with
usr.sbin.
1994-05-26 06:35:07 +00:00