swapon.2 (2010 09)
s
swapon(2) swapon(2)
(TO BE OBSOLETED)
NAME
swapon() - add swap space for interleaved paging and swapping
SYNOPSIS
#include <unistd.h>
int swapon(const char *path, ...
/* [int min,
int limit,
int reserve,]
int priority */ );
Remarks
The ANSI C ", ..." construct denotes a variable length argument list whose optional and required
members are given in the associated comment (
/* */).
DESCRIPTION
The
swapon() system call makes a block device or a directory named path available to the system for
paging and swapping.
priority indicates the order in which the swap space from the device or file system is used. It has a range
of 0 (highest) to 10 (lowest). Space is taken from the lower-numbered systems first.
swapon() can be used only by users who have appropriate privileges.
If path names a block device file
swapon() makes it available to the system at the specified priority for allocation for paging and swap-
ping.
In this form,
swapon() takes only two arguments: the path to the block device file, and the priority .
The device associated with path can be a device already known to the system, defined at system
configuration time, or it can be a previously unspecified device.
If the device was already defined at system configuration time and also has a start and/or size defined for
that swap device, these values are used.
Otherwise, if a filesystem exists on the device, swap is added following the filesystem, or if no filesystem
exists, the complete device is used for swap.
See the appropriate system administrator’s manual for information on how the size of the swap area is
calculated.
If path names a directory
swapon() makes the blocks on the file system rooted at path available for paging and swapping.
The min, limit , and reserve arguments are passed and used only if the path argument names a directory.
min indicates the number of file system blocks to take from the file system when
swapon() is called.
limit indicates the maximum number of file system blocks the swap system is allowed to take from the file
system.
reserve indicates the number of file system blocks that are saved for file system use only.
For a pre-existing directory swap, a value of -1 for min, limit , reserve ,orpriority will keep the value
unchanged. This can be used to change selective values without affecting others. For example, if priority
of a pre-existing directory swap needs to be changed without affecting the values of min, limit ,orreserve ,
one can specify the new priority value and pass -1 for other arguments.
The size for the file system blocks mentioned above is the preferred file system block size. The preferred
file system block size can be obtained by the
statvfs() call. The value of min, limit ,orreserve is
rounded up to the swchunk tunable size.
ERRORS
If
swapon() fails, errno is set to one of the following values.
[EACCES] A component of the path prefix denies search permission.
[EINVAL] One of priority , min, limit ,orreserve arguments is invalid.
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1