HP-UX Reference (11i v3 07/02) - 2 System Calls (vol 5)

s
swapctl(2) swapctl(2)
sr_lim (Needed for file system swap only.) Indicates the maximum number of file system
blocks the swap system is allowed to take from the file system.
sr_res (Needed for file system swap only.) Indicates the number of file system blocks that
are saved for file system use only.
For the SC_ADD command, depending on the sr_flag type, the following members of
swapres structure
need to be passed in.
SW_PRIMARY | SW_NEXTBOOT :
*sr_name, sr_priority, sr_start, sr_length
SW_DEVICE:
*sr_name, sr_priority, sr_start, sr_length
SW_FILESYS:
*sr_name, sr_priority, sr_min, sr_lim, sr_res
The SW_PRIMARY | SW_NEXTBOOT flag is used to change the primary swap configuration for the next
boot. This change will only take place after the next boot. The changed configuration will remain effective
until it is changed again using this option.
The sr_priority for the primary swap for the next boot should always be set to 1. Other priority values are
considered invalid.
A value of -1 for sr_start implies a presence of a file system on the swap device and swap area to start
immediately after that.
The length of the device swap to be configured should at least be swchunk
kilobytes in size. The length is
always rounded down to be a multiple of
swchunk.
A VxVM or LVM-based logical volume should be created with contiguous layout to be configured as a pri-
mary swap device. For LVM-based systems only the logical volumes within the root volume group can be
configured as a primary swap device.
For a pre-existing directory swap, a value of -1 for sr_min, sr_lim, sr_res,orsr_priority 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 sr_min, sr_lim,orsr_res,
one can specify the new priority value and pass -1 for other arguments.
The size for the le 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 SC_REMOVE Command
For the SC_REMOVE command, arg parameter is a pointer to the swapres structure with the following
members:
swapctl_flags_t sr_flag
char * sr_name
int64_t sr_start
int64_t sr_length
where the fields are as follows:
sr_flag The sr_flag is SW_PRIMARY | SW_NEXTBOOT .
*sr_name Pathname of the resource that is being removed.
sr_start Starting offset that was specified with the SC_ADD command.
sr_length Length of swap device that was specified with the SC_ADD command.
The sr_name, sr_start, and sr_length should be the same values that were used with the SC_ADD com-
mand. The sr_flag indicates that the swap resource that is marked as primary swap for the next boot be
removed. This will only work if the primary swap device was configured using the SC_ADD command.
Devices that have been configured for swap by methods other than swapctl() can not be altered by the
SC_REMOVE command.
Swap resources that have been activated for the current boot cannot be removed until the system boot.
When using the SC_ADD and SC_REMOVE commands, the calling process fails if the appropriate privileges
do not exist for the operation.
HP-UX 11i Version 3: February 2007 2 Hewlett-Packard Company 467