summaryrefslogtreecommitdiffstats
path: root/lib/libc/sys
diff options
context:
space:
mode:
authordillon <dillon@FreeBSD.org>2002-12-15 19:17:57 +0000
committerdillon <dillon@FreeBSD.org>2002-12-15 19:17:57 +0000
commitb43fb3e9200092f2885e909dc7ee85cb0871cfef (patch)
treefc6e3be9fa1b757f9ac0967a46494adcf0cc5682 /lib/libc/sys
parent2925e70a14eb46bd10c8905fd619024bb19f7f9d (diff)
downloadFreeBSD-src-b43fb3e9200092f2885e909dc7ee85cb0871cfef.zip
FreeBSD-src-b43fb3e9200092f2885e909dc7ee85cb0871cfef.tar.gz
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
Diffstat (limited to 'lib/libc/sys')
-rw-r--r--lib/libc/sys/Makefile.inc1
-rw-r--r--lib/libc/sys/swapon.263
2 files changed, 46 insertions, 18 deletions
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 4fe3d7e..257ef7a 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -131,6 +131,7 @@ MLINKS+=shmat.2 shmdt.2
MLINKS+=stat.2 fstat.2 stat.2 lstat.2
MLINKS+=statfs.2 fstatfs.2
MLINKS+=syscall.2 __syscall.2
+MLINKS+=swapon.2 swapoff.2
MLINKS+=truncate.2 ftruncate.2
MLINKS+=utimes.2 futimes.2 utimes.2 lutimes.2
MLINKS+=wait.2 wait3.2 wait.2 wait4.2 wait.2 waitpid.2
diff --git a/lib/libc/sys/swapon.2 b/lib/libc/sys/swapon.2
index a852ba0..f4f9092 100644
--- a/lib/libc/sys/swapon.2
+++ b/lib/libc/sys/swapon.2
@@ -36,14 +36,16 @@
.Dt SWAPON 2
.Os
.Sh NAME
-.Nm swapon
-.Nd add a swap device for interleaved paging/swapping
+.Nm swapon , swapoff
+.Nd control devices for interleaved paging/swapping
.Sh LIBRARY
.Lb libc
.Sh SYNOPSIS
.In unistd.h
.Ft int
.Fn swapon "const char *special"
+.Ft int
+.Fn swapoff "const char *special"
.Sh DESCRIPTION
.Fn Swapon
makes the block device
@@ -55,13 +57,22 @@ configuration time. The size of the swap area on
.Fa special
is calculated at the time the device is first made available
for swapping.
+.Pp
+The
+.Fn swapoff
+system call disables paging and swapping on the given device.
+All associated swap metadata are deallocated, and the device
+is made available for other purposes.
.Sh RETURN VALUES
If an error has occurred, a value of -1 is returned and
.Va errno
is set to indicate the error.
.Sh ERRORS
-.Fn Swapon
-succeeds unless:
+Both
+.Fn swapon
+and
+.Fn swapoff
+can fail if:
.Bl -tag -width Er
.It Bq Er ENOTDIR
A component of the path prefix is not a directory.
@@ -76,6 +87,19 @@ Search permission is denied for a component of the path prefix.
Too many symbolic links were encountered in translating the pathname.
.It Bq Er EPERM
The caller is not the super-user.
+.It Bq Er EFAULT
+.Fa Special
+points outside the process's allocated address space.
+.El
+.Pp
+Additionally,
+.Fn swapon
+can fail for the following reasons:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The system has reached the boot-time limit on the number of
+swap devices,
+.Va vm.nswapdev .
.It Bq Er ENOTBLK
.Fa Special
is not a block device.
@@ -84,11 +108,6 @@ The device specified by
.Fa special
has already
been made available for swapping
-.It Bq Er EINVAL
-The device configured by
-.Fa special
-was not
-configured into the system as a swap device.
.It Bq Er ENXIO
The major device number of
.Fa special
@@ -96,20 +115,28 @@ is out of range (this indicates no device driver exists
for the associated hardware).
.It Bq Er EIO
An I/O error occurred while opening the swap device.
-.It Bq Er EFAULT
-.Fa Special
-points outside the process's allocated address space.
+.El
+.Pp
+Lastly,
+.Fn swapoff
+can fail if:
+.Bl -tag -width Er
+.It Bq Er EINVAL
+The system is not currently swapping to
+.Fa special .
+.It Bq Er ENOMEM
+Not enough virtual memory is available to safely disable
+paging and swapping to the given device.
.El
.Sh SEE ALSO
.Xr config 8 ,
-.Xr swapon 8
-.Sh BUGS
-There is no way to stop swapping on a disk so that the pack may be
-dismounted.
-.Pp
-This call will be upgraded in future versions of the system.
+.Xr swapon 8 ,
+.Xr sysctl 8
.Sh HISTORY
The
.Fn swapon
function call appeared in
.Bx 4.0 .
+.Fn Swapoff
+appeared in
+.Fx 5.0 .
OpenPOWER on IntegriCloud