summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorTobias Weingartner <weingart@cvs.openbsd.org>1999-05-22 21:27:22 +0000
committerTobias Weingartner <weingart@cvs.openbsd.org>1999-05-22 21:27:22 +0000
commitf2013a9ab25ae64f742b9d4c69dfc3976be77d70 (patch)
treefd5168fa6ab5aebd58c2d449dba09f6769df24f0 /lib
parentaf195c04fc180f2d000f8f2f84a83b7d706a4fde (diff)
Add swapctl(2), and crank shlib minor.
Diffstat (limited to 'lib')
-rw-r--r--lib/libc/shlib_version2
-rw-r--r--lib/libc/sys/Makefile.inc4
-rw-r--r--lib/libc/sys/swapctl.2227
3 files changed, 230 insertions, 3 deletions
diff --git a/lib/libc/shlib_version b/lib/libc/shlib_version
index 8c2fe1de0cf..deb0e308e38 100644
--- a/lib/libc/shlib_version
+++ b/lib/libc/shlib_version
@@ -1,2 +1,2 @@
major=21
-minor=1
+minor=2
diff --git a/lib/libc/sys/Makefile.inc b/lib/libc/sys/Makefile.inc
index 59cac8d9641..2d88002a700 100644
--- a/lib/libc/sys/Makefile.inc
+++ b/lib/libc/sys/Makefile.inc
@@ -1,4 +1,4 @@
-# $OpenBSD: Makefile.inc,v 1.28 1999/02/01 08:13:01 d Exp $
+# $OpenBSD: Makefile.inc,v 1.29 1999/05/22 21:27:21 weingart Exp $
# $NetBSD: Makefile.inc,v 1.35 1995/10/16 23:49:07 jtc Exp $
# @(#)Makefile.inc 8.1 (Berkeley) 6/17/93
@@ -50,7 +50,7 @@ ASM= accept.o access.o acct.o adjtime.o bind.o chdir.o chflags.o chmod.o \
setegid.o seteuid.o setgid.o setgroups.o setitimer.o setpgid.o \
setpriority.o setrlimit.o setsid.o setsockopt.o settimeofday.o \
setuid.o shmat.o shmctl.o shmdt.o shmget.o shutdown.o sigaction.o \
- sigaltstack.o socket.o socketpair.o stat.o statfs.o swapon.o \
+ sigaltstack.o socket.o socketpair.o stat.o statfs.o swapon.o swapctl.o \
symlink.o sync.o sysarch.o umask.o undelete.o unlink.o unmount.o \
utimes.o vadvise.o wait4.o write.o writev.o xfspioctl.o __semctl.o \
__syscall.o __sysctl.o
diff --git a/lib/libc/sys/swapctl.2 b/lib/libc/sys/swapctl.2
new file mode 100644
index 00000000000..e899bff9537
--- /dev/null
+++ b/lib/libc/sys/swapctl.2
@@ -0,0 +1,227 @@
+.\" $NetBSD: swapctl.2,v 1.10 1998/08/29 17:11:09 mrg Exp $
+.\"
+.\" Copyright (c) 1997 Matthew R. Green
+.\" Copyright (c) 1980, 1991, 1993
+.\" The Regents of the University of California. All rights reserved.
+.\"
+.\" Redistribution and use in source and binary forms, with or without
+.\" modification, are permitted provided that the following conditions
+.\" are met:
+.\" 1. Redistributions of source code must retain the above copyright
+.\" notice, this list of conditions and the following disclaimer.
+.\" 2. Redistributions in binary form must reproduce the above copyright
+.\" notice, this list of conditions and the following disclaimer in the
+.\" documentation and/or other materials provided with the distribution.
+.\" 3. All advertising materials mentioning features or use of this software
+.\" must display the following acknowledgement:
+.\" This product includes software developed by the University of
+.\" California, Berkeley and its contributors.
+.\" 4. Neither the name of the University nor the names of its contributors
+.\" may be used to endorse or promote products derived from this software
+.\" without specific prior written permission.
+.\"
+.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
+.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
+.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
+.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
+.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
+.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
+.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
+.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
+.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
+.\" SUCH DAMAGE.
+.\"
+.Dd June 20, 1997
+.Dt SWAPCTL 2
+.Os NetBSD
+.Sh NAME
+.Nm swapctl
+.Nd modify swap configuration
+.Sh SYNOPSIS
+.Fd #include <unistd.h>
+.Fd #include <sys/swap.h>
+.Ft int
+.Fn swapctl "int cmd" "const void *arg" "int misc"
+.Sh DESCRIPTION
+The
+.Nm
+function is used to add and delete swap devices, and modify their
+configuration.
+.Pp
+The
+.Fa cmd
+parameter specifies the operation to be performed. The
+.Fa arg
+and
+.Fa misc
+parameters have different meanings, depending on the
+.Fa cmd
+parameter.
+.Bl -item -offset indent
+.It
+If
+.Fa cmd
+is
+.Dv SWAP_NSWAP ,
+the current number of swap devices in the system is returned. The
+.Fa arg
+and
+.Fa misc
+parameters are ignored.
+.It
+If
+.Fa cmd
+is
+.Dv SWAP_STATS ,
+the current statistics for swap devices are returned in the
+.Fa arg
+parameter. No more than
+.Fa misc
+swap devices are returned. The
+.Fa arg
+parameter should point to an array of at least
+.Fa misc
+struct swapent structures:
+.Bd -literal
+struct swapent {
+ dev_t se_dev; /* device id */
+ int se_flags; /* entry flags */
+ int se_nblks; /* total blocks */
+ int se_inuse; /* blocks in use */
+ int se_priority; /* priority */
+ char se_path[PATH_MAX+1]; /* path to entry */
+};
+.Ed
+.Pp
+The flags are defined as
+.Bd -literal
+ SWF_INUSE in use: we have swapped here
+ SWF_ENABLE enabled: we can swap here
+ SWF_BUSY busy: I/O happening here
+ SWF_FAKE fake: still being built
+.Ed
+.It
+If
+.Fa cmd
+is
+.Dv SWAP_ON ,
+the
+.Fa arg
+parameter is used as a pathname of a file to enable swapping to.
+The
+.Fa misc
+parameter is used to set the priority of this swap device.
+.It
+If
+.Fa cmd
+is
+.Dv SWAP_OFF ,
+the
+.Fa arg
+parameter is used as the pathname of a file to disable swapping from.
+The
+.Fa misc
+parameter is ignored.
+.It
+If
+.Fa cmd
+is
+.Dv SWAP_CTL ,
+the
+.Fa arg
+and
+.Fa misc
+parameters have the same function as for the
+.Dv SWAP_ON
+case, except that they change the priority of a currently enabled swap device.
+.El
+.Pp
+When swapping is enabled on a block device, the first portion of the disk is
+left unused to prevent any disklable present from being overwritten. This
+space is allocated from the swap device when the
+.Dv SWAP_ON
+command is used.
+.Sh RETURN VALUES
+If the
+.Fa cmd
+parameter is
+.Dv SWAP_NSWAP
+or
+.Dv SWAP_STATS ,
+.Fn swapctl
+returns the number of swap devices, if successful. The
+.Dv SWAP_NSWAP
+command is always successful. Otherwise it returns 0 on success and -1
+on failure, setting the global variable
+.Va errno
+to indicate the error.
+.Sh ERRORS
+.Fn swapctl
+succeeds unless:
+.Bl -tag -width Er
+.It Bq Er ENOTDIR
+A component of the path prefix is not a directory.
+.It Bq Er ENAMETOOLONG
+A component of a pathname exceeded
+.Dv NAME_MAX
+characters, or an entire path name exceeded
+.Dv PATH_MAX
+characters.
+.It Bq Er ENOENT
+The named device does not exist. For the
+.Dv SWAP_CTL
+command, the named device is not currently enabled for swapping.
+.It Bq Er EACCES
+Search permission is denied for a component of the path prefix.
+.It Bq Er ELOOP
+Too many symbolic links were encountered in translating the pathname.
+.It Bq Er EPERM
+The caller is not the super-user.
+.It Bq Er EBUSY
+The device specified by
+.Fa arg
+has already been made available for swapping.
+.It Bq Er EINVAL
+The device configured by
+.Fa arg
+has no associated size, or the
+.Fa cmd
+was unknown.
+.It Bq Er ENXIO
+The major device number of
+.Fa arg
+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 arg
+points outside the process' allocated address space.
+.Sh SEE ALSO
+.Xr swapctl 8 ,
+.Xr config 8
+.Sh BUGS
+The
+.Dv SWAP_OFF
+command is currently unimplemented by the
+.Nx
+kernel.
+.Sh AUTHOR
+The current swap system was designed and implemented by Matthew Green
+<mrg@eterna.com.au>, with help from Paul Kranenburg <pk@NetBSD.ORG>
+and Leo Weppelman <leo@NetBSD.ORG>, and insights from Jason R. Thorpe
+<thorpej@NetBSD.ORG>.
+.Sh HISTORY
+The
+.Fn swapctl
+function call appeared in
+.Nx 1.3 .
+The
+.Fa se_path
+member was added to
+.Va struct swapent
+in
+.Nx 1.4 ,
+when the header file was also moved from
+.Pa <vm/vm_swap.h> .