1.\" $NetBSD: swapctl.2,v 1.3 1997/06/20 05:47:58 mrg Exp $ 2.\" 3.\" Copyright (c) 1997 Matthew R. Green 4.\" Copyright (c) 1980, 1991, 1993 5.\" The Regents of the University of California. All rights reserved. 6.\" 7.\" Redistribution and use in source and binary forms, with or without 8.\" modification, are permitted provided that the following conditions 9.\" are met: 10.\" 1. Redistributions of source code must retain the above copyright 11.\" notice, this list of conditions and the following disclaimer. 12.\" 2. Redistributions in binary form must reproduce the above copyright 13.\" notice, this list of conditions and the following disclaimer in the 14.\" documentation and/or other materials provided with the distribution. 15.\" 3. All advertising materials mentioning features or use of this software 16.\" must display the following acknowledgement: 17.\" This product includes software developed by the University of 18.\" California, Berkeley and its contributors. 19.\" 4. Neither the name of the University nor the names of its contributors 20.\" may be used to endorse or promote products derived from this software 21.\" without specific prior written permission. 22.\" 23.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 24.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 25.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 26.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 27.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 28.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 29.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 30.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 31.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 32.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 33.\" SUCH DAMAGE. 34.\" 35.Dd June 20, 1997 36.Dt SWAPON 2 37.Os NetBSD 38.Sh NAME 39.Nm swapctl 40.Nd modify swap configuration 41.Sh SYNOPSIS 42.Fd #include <unistd.h> 43.Fd #include <vm/vm_swap.h> 44.Ft int 45.Fn swapctl "int cmd" "const void *arg" "int misc" 46.Fn swapon "const char *name" 47.Sh DESCRIPTION 48The 49.Nm 50function is used to add and delete swap devices, and modify their configuration. 51The 52.Nm swapon 53function only exists as as backwards compatibility feature until the 54next major bump of the 55.Pa libc 56major from 12. It should never be used in new code, and should be 57removed from existed code. 58.Pp 59The 60.Fa cmd 61parameter specifies the operation to be performed. THe 62.Fa arg 63and 64.Fa misc 65parameters have different meanings, depending on the 66.Fa cmd 67parameter. 68.Bl -item -offset indent 69.It 70If 71.Fa cmd 72is 73.Dv SWAP_NSWAP , 74the current number of swap devices in the system is returned. The 75.Fa arg 76and 77.Fa misc 78parameters are ignored. 79.It 80If 81.Fa cmd 82is 83.Dv SWAP_STATS , 84the current statistics for swap devices are returned in the 85.Fa arg 86parameter. No more than 87.Fa misc 88swap devices are returned. The 89.Fa arg 90parameter should point to an array of at least 91.Fa misc 92struct swapent structures: 93.Bd -literal 94struct swapent { 95 dev_t se_dev; 96 int se_flags; 97 int se_nblks; 98 int se_inuse; 99 int se_priority; 100}; 101.Ed 102.It 103If 104.Fa cmd 105is 106.Dv SWAP_ON , 107the 108.Fa arg 109parameter is used as a pathname of a file to enable swapping to. 110The 111.Fa misc 112parameter is used to set the priority of this swap device. 113.It 114If 115.Fa cmd 116is 117.Dv SWAP_OFF , 118the 119.Fa arg 120parameter is used as the pathname of a file to disable swapping from. 121The 122.Fa misc 123parameter is ignored. 124.It 125If 126.Fa cmd 127is 128.Dv SWAP_CTL , 129the 130.Fa arg 131and 132.Fa misc 133parameters have the same function as for the 134.Dv SWAP_ON 135case, except that they change the priority of a currently enable swap device. 136.El 137.Sh RETURN VALUES 138If the 139.Fa cmd 140parameter is 141.Dv SWAP_NSTATS 142or 143.Dv SWAP_STATS , 144.Fn swapctl 145returns the number of swap devices, if successful. The 146.Dv SWAP_NSTATS 147command is always successful. Otherwise it returns 0 on success and -1 148on failure, setting the global variable 149.Va errno 150to indicate the error. 151.Sh ERRORS 152.Fn swapctl 153succeeds unless: 154.Bl -tag -width Er 155.It Bq Er ENOTDIR 156A component of the path prefix is not a directory. 157.It Bq Er ENAMETOOLONG 158A component of a pathname exceeded 159.Dv NAME_MAX 160characters, or an entire path name exceeded 161.Dv PATH_MAX 162characters. 163.It Bq Er ENOENT 164The named device does not exist. For the 165.Dv SWAP_CTL 166command, the named device is not currently enabled for swapping. 167.It Bq Er EACCES 168Search permission is denied for a component of the path prefix. 169.It Bq Er ELOOP 170Too many symbolic links were encountered in translating the pathname. 171.It Bq Er EPERM 172The caller is not the super-user. 173.It Bq Er EBUSY 174The device specified by 175.Fa arg 176has already 177been made available for swapping 178.It Bq Er EINVAL 179The device configured by 180.Fa arg 181has no associated size, or the 182.Fa cmd 183was unknown. 184.It Bq Er ENXIO 185The major device number of 186.Fa arg 187is out of range (this indicates no device driver exists 188for the associated hardware). 189.It Bq Er EIO 190An I/O error occurred while opening the swap device. 191.It Bq Er EFAULT 192.Fa arg 193points outside the process's allocated address space. 194.Sh SEE ALSO 195.Xr swapctl 8 , 196.Xr config 8 197.Sh BUGS 198The 199.Dv SWAP_OFF 200command is currently unimplemented by the 201.Nx 202kernel. 203.Sh AUTHOR 204The current swap system was designed and implemented by Matthew Green 205<mrg@eterna.com.au>, with help from Paul Kranenburg <pk@NetBSD.ORG> 206and Leo Weppelman <leo@NetBSD.ORG>, and insights from Jason R. Thorpe 207<thorpej@NetBSD.ORG>. 208.Sh HISTORY 209The 210.Fn swapctl 211function call appeared in 212.Nx 1.3 . 213