swapctl.2 (2010 09)
s
swapctl(2) swapctl(2)
[EIO] Unable to read or write to the kernel registry services (see krs(5)).
[EFAULT] Specifies that the structure pointed to by the arg parameter or swt_ent field of
swaptable_t struct, or one of the fields sr_name or ste_path is outside the allo-
cated address space.
[EINVAL] Invalid input parameter passed in.
[EINVAL] Indicates that the LVM device passed in for
SC_ADD is not early boot accessible or
is a non-contiguous logical volume
[EINVAL] The path used with the
SC_REMOVE command is not a swap resource.
[EINVAL] The range indicated by the sr_start and sr_length fields for the
SC_ADD command
is outside the resource specified.
[ELOOP] Indicates that the pathname used with the
SC_ADD or SC_REMOVE commands has
too many symbolic links to correctly translate the pathname.
[ENAMETOOLONG]
Indicates that the length or path used with the
SC_ADD or SC_REMOVE command
exceeds the maximum allowed with
{_POSIX_NO_TRUNC}
in effect.
[ENOENT] Indicates that a invalid pathname was specified with either the
SC_ADD or
SC_REMOVE commands.
[ENOENT] Indicates that the primary swap was not set using the
SC_ADD command when
using with the SC_LIST command to list primary swap.
[ENOTBLK] Indicates that the path used with the
SC_ADD command for adding device swap is
not a block device file.
[ENOTDIR] Indicates that the path used with the
SC_ADD command for adding file system
swap is not a directory.
[ENXIO] The device associated with sr_name could not be opened.
[EPERM] Indicates that insufficient privileges do not exist for the operation.
[EROFS] Indicates that a read-only file system was specified by the path for the
SC_ADD
command.
EXAMPLES
The following example adds, lists and removes a primary swap device for next boot:
#include <sys/swap.h>
#include <stdio.h>
int main() {
int rv;
swapres_t swp;
swaptable_t swt;
swapent_t swent;
char path[1024] = "/dev/disk/disk12 ";
char ret_path[1024];
bzero(ret_path, 1024);
/* add a new primary swap for next boot */
swp.sr_flag = SW_PRIMARY | SW_NEXTBOOT;
swp.sr_name = path;
swp.sr_start = 0;
swp.sr_length = 0; /* 0 len implies, use the entire dev */
swp.sr_priority = 1;
rv = swapctl(SC_ADD, (void *)&swp);
if (rv) {
perror("swapctl/SC_ADD failed");
4 Hewlett-Packard Company − 4 − HP-UX 11i Version 3: September 2010