swapctl(2) swapctl(2)
NAME
swapctl - manage swap space
SYNOPSIS
#include <sys/stat.h>
#include <sys/swap.h>
int swapctl(int cmd, void *arg);
DESCRIPTION
swapctl() adds, deletes, or returns information about swap resources.
cmd specifies one of the following options contained in sys/swap.h:
SCADD /* add a resource for swapping */
SCLIST /* list the resources for swapping */
SCREMOVE /* remove a resource for swapping */
SCGETNSWP /* return number of swap resources */
When SCADD or SCREMOVE is specified, arg is a pointer to a swapres
structure containing the following members:
char *srname; /* pathname of resource */
offt srstart; /* offset to start of swap area */
offt srlength; /* length of swap area */
srstart and srlength are specified in 512-byte blocks.
When SCLIST is specified, arg is a pointer to a swaptable structure
containing the following members:
int swtn; /* number of swapents following */
struct swapent swtent[]; /* array of swtn swapents */
A swapent structure contains the following members:
char *stepath; /* name of the swap file */
offt stestart; /* starting block for swapping */
offt stelength; /* length of swap area */
long stepages; /* number of pages for swapping */
long stefree; /* number of stepages free */
long steflags; /* STINDEL bit set if swap file */
/* is now being deleted */
SCLIST causes swapctl() to return at most swtn entries. The result
of swapctl() is the number actually returned. The STINDEL bit is
turned on in steflags if the swap file is in the process of being
deleted.
When SCGETNSWP is specified, swapctl() returns as its value the
number of swap resources in use. arg is ignored for this operation.
Page 1 Reliant UNIX 5.44 Printed 11/98
swapctl(2) swapctl(2)
The SCADD and SCREMOVE functions will fail if the calling process
does not have appropriate privileges.
Under the following conditions, the function swapctl() fails and sets
errno to:
EEXIST Part of the range specified by srstart and srlength is
already being used for swapping on the specified
resource (SCADD).
EFAULT arg, srname, or stepath points outside the allocated
address space for the process.
EINVAL The specified function value is not valid, the path
specified is not a swap resource (SCREMOVE), part of
the range specified by srstart and srlength lies out-
side the resource specified (SCADD), or the specified
swap area is less than one page (SCADD).
EISDIR The path specified for SCADD is a directory.
ELOOP Too many symbolic links were encountered in translating
the pathname provided to SCADD or SCREMOVE.
ENAMETOOLONG The length of a component of the path specified for
SCADD or SCREMOVE exceeds NAMEMAX characters or the
length of the path exceeds PATHMAX characters.
ENOENT The pathname specified for SCADD or SCREMOVE does not
exist.
ENOMEM An insufficient number of struct swapent structures were
provided to SCLIST, or there were insufficient system
storage resources available during an SCADD or
SCREMOVE, or the system would not have enough swap
space after an SCREMOVE.
ENOSYS The pathname specified for SCADD or SCREMOVE is not a
file or block special file.
ENOTDIR Pathname provided to SCADD or SCREMOVE contained a
component in the path prefix that was not a directory.
EPERM The process does not have appropriate privileges.
EROFS The pathname specified for SCADD is a read-only file
system.
Page 2 Reliant UNIX 5.44 Printed 11/98
swapctl(2) swapctl(2)
RESULT
Upon successful completion, the function swapctl() returns a value of
0 for SCADD or SCREMOVE, the number of struct swapent entries actu-
ally returned for SCLIST, or the number of swap resources in use for
SCGETNSWP. Upon failure, the function swapctl() returns a value of -1
and sets errno to indicate an error.
Page 3 Reliant UNIX 5.44 Printed 11/98