*nix Documentation Project
·  Home
 +   man pages
·  Linux HOWTOs
·  FreeBSD Tips
·  *niX Forums

  man pages->OpenBSD man pages -> swapctl (2)              



NAME    [Toc]    [Back]

     swapctl - modify swap configuration

SYNOPSIS    [Toc]    [Back]

     #include <unistd.h>
     #include <sys/swap.h>

     swapctl(int cmd, const void *arg, int misc);

DESCRIPTION    [Toc]    [Back]

     The swapctl() function is used to add and  delete  swap  devices, and modify
     their configuration.

     The  cmd  parameter specifies the operation to be performed.
The arg and
     misc parameters have different meanings,  depending  on  the
cmd parameter.

           If  cmd  is SWAP_NSWAP, the current number of swap devices in the
           system is returned.  The arg and misc  parameters  are

           If  cmd is SWAP_STATS, the current statistics for swap
devices are
           returned in the arg parameter.  No more than misc swap
devices are
           returned.   The arg parameter should point to an array
of at least
           misc struct swapent structures:

           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[MAXPATHLEN];    /* path to entry */

           The flags are defined as

                   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

           If cmd is SWAP_ON, the arg  parameter  is  used  as  a
pathname of a
           file  to  enable  swapping  to.  The misc parameter is
used to set the
           priority of this swap device.

           If cmd is SWAP_OFF, the arg parameter is used  as  the
pathname of a
           file  to disable swapping from.  The misc parameter is

           If cmd is SWAP_CTL, the arg and misc  parameters  have
the same function
  as for the SWAP_ON case, except that they change
the priority
           of a currently enabled swap device.

     When swapping is enabled on a block device, the  first  portion of the disk
     is  left  unused to prevent any disklabel present from being
     This space is  allocated  from  the  swap  device  when  the
SWAP_ON command is

RETURN VALUES    [Toc]    [Back]

     If  the cmd parameter is SWAP_NSWAP or SWAP_STATS, swapctl()
returns the
     number of swap devices, if successful.  The SWAP_NSWAP  command is always
     successful.   Otherwise  it  returns  0 on success and -1 on
failure, setting
     the global variable errno to indicate the error.

ERRORS    [Toc]    [Back]

     swapctl() succeeds unless:

     [ENOTDIR]     A component of the path prefix is not a directory.

                   A  component  of  a pathname exceeded NAME_MAX
characters, or
                   an entire path name exceeded PATH_MAX  characters.

     [ENOENT]       The  named  device  does  not exist.  For the
SWAP_CTL command,
                   the named device is not currently enabled  for

     [EACCES]      Search permission is denied for a component of
the path

     [ELOOP]       Too many symbolic links  were  encountered  in
translating the

     [EPERM]       The caller is not the superuser.

     [EBUSY]        The  device specified by arg has already been
made available
                   for swapping.

     [EINVAL]      The device configured by arg has no associated
size, or the
                   cmd was unknown.

     [ENXIO]       The major device number of arg is out of range
(this indicates
 no device driver exists for the  associated hardware).

     [EIO]          An  I/O error occurred while opening the swap

     [EFAULT]      arg points outside the process' allocated  address space.

SEE ALSO    [Toc]    [Back]

     config(8), swapctl(8)

HISTORY    [Toc]    [Back]

     The  swapctl()  function  call  appeared in NetBSD 1.3.  The
se_path member
     was added to struct swapent in NetBSD 1.4, when  the  header
file was also
     moved from <vm/vm_swap.h>.

AUTHORS    [Toc]    [Back]

     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.

OpenBSD     3.6                           June      20,      1997
[ Back ]
 Similar pages
Name OS Title
amconfig IRIX check or modify availmon configuration values
swab Tru64 Swap bytes
swab IRIX swap bytes
removeSwap IRIX removes the indicated swap element
swab FreeBSD swap adjacent bytes
swap IRIX swap administrative interface
mkswap Linux set up a Linux swap area
swapctl IRIX manage swap space
swab NetBSD swap adjacent bytes
swab OpenBSD swap adjacent bytes
Copyright © 2004-2005 DeniX Solutions SRL
newsletter delivery service