1 .\" $NetBSD: swapctl.2,v 1.37 2010/05/31 12:16:20 njoly Exp $
3 .\" Copyright (c) 1997 Matthew R. Green
4 .\" All rights reserved.
6 .\" Redistribution and use in source and binary forms, with or without
7 .\" modification, are permitted provided that the following conditions
9 .\" 1. Redistributions of source code must retain the above copyright
10 .\" notice, this list of conditions and the following disclaimer.
11 .\" 2. Redistributions in binary form must reproduce the above copyright
12 .\" notice, this list of conditions and the following disclaimer in the
13 .\" documentation and/or other materials provided with the distribution.
15 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
16 .\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
17 .\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
18 .\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
19 .\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
20 .\" BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
21 .\" LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
22 .\" AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
23 .\" OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 .\" Copyright (c) 1980, 1991, 1993
28 .\" The Regents of the University of California. All rights reserved.
30 .\" Redistribution and use in source and binary forms, with or without
31 .\" modification, are permitted provided that the following conditions
33 .\" 1. Redistributions of source code must retain the above copyright
34 .\" notice, this list of conditions and the following disclaimer.
35 .\" 2. Redistributions in binary form must reproduce the above copyright
36 .\" notice, this list of conditions and the following disclaimer in the
37 .\" documentation and/or other materials provided with the distribution.
38 .\" 3. Neither the name of the University nor the names of its contributors
39 .\" may be used to endorse or promote products derived from this software
40 .\" without specific prior written permission.
42 .\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
43 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
44 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
45 .\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
46 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
47 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
48 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
49 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
50 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
51 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
59 .Nd modify swap configuration
66 .Fn swapctl "int cmd" "void *arg" "int misc"
70 function is used to add and delete swap devices, and modify their
75 parameter specifies the operation to be performed.
80 parameters have different meanings, depending on the
83 .Bl -enum -offset indent
89 the current number of swap devices in the system is returned.
94 parameters are ignored.
100 the current statistics for swap devices are returned in the
105 swap devices are returned.
108 parameter should point to an array of at least
110 struct swapent structures:
113 dev_t se_dev; /* device id */
114 int se_flags; /* entry flags */
115 int se_nblks; /* total blocks */
116 int se_inuse; /* blocks in use */
117 int se_priority; /* priority */
118 char se_path[PATH_MAX+1]; /* path to entry */
122 The flags are defined as
124 SWF_INUSE in use: we have swapped here
125 SWF_ENABLE enabled: we can swap here
126 SWF_BUSY busy: I/O happening here
127 SWF_FAKE fake: still being built
136 parameter is used as a pathname of a file to enable swapping to.
139 parameter is used to set the priority of this swap device.
147 parameter is used as the pathname of a file to disable swapping from.
150 parameter is ignored.
160 parameters have the same function as for the
162 case, except that they change the priority of a currently enabled swap device.
170 parameter is used as the pathname of a device to use as the dump device,
171 should the system panic.
176 .Dv SWAP_GETDUMPDEV ,
179 parameter points to a dev_t, which is filled in by the current dump device.
182 When swapping is enabled on a block device, the first portion of the disk is
183 left unused to prevent any disklabel present from being overwritten.
184 This space is allocated from the swap device when the
188 The priority of a swap device can be used to fill faster swap devices before
190 A priority of 0 is the highest, with larger numbers having lower priority.
191 For a fuller discussion on swap priority, see the
203 returns the number of swap devices, if successful.
206 command is always successful.
207 Otherwise it returns 0 on success and \-1
208 on failure, setting the global variable
210 to indicate the error.
216 A component of the path prefix is not a directory.
217 .It Bq Er ENAMETOOLONG
218 A component of a pathname exceeded
220 characters, or an entire path name exceeded
224 The named device does not exist.
227 command, the named device is not currently enabled for swapping.
229 Search permission is denied for a component of the path prefix.
231 Too many symbolic links were encountered in translating the pathname.
233 The caller is not the super-user.
235 The device specified by
237 has already been made available for swapping.
239 The device configured by
241 has no associated size, or the
245 The major device number of
247 is out of range (this indicates no device driver exists
248 for the associated hardware).
250 The block device specified by
252 is not marked as a swap partition in the disklabel.
254 An I/O error occurred while opening the swap device.
257 points outside the process' allocated address space.
264 function call appeared in
272 when the header file was also moved from
274 to its current location in
277 The current swap system was designed and implemented by
279 .Aq mrg@eterna.com.au ,
280 with help from Paul Kranenburg
284 and insights from Jason R. Thorpe
285 .Aq thorpej@NetBSD.org .