PSTAT Interfaces

24
perror("pstat_getsocket()");
}
} else {
perror("pstat_getfile2");
}
close(fd);
}
4.21 pstat_getstable()
Synopsis:
int pstat_getstable(struct pst_stable *buf, size_t elemsize, size_t elemcount, int index);
Description:
Returns information contained in the system's stable storage area. There is one instance
of this context. Data up to a maximum of elemsize bytes are returned in the struct pst_stable
pointed to by buf. The elemcount parameter must be 1. The index parameter must be 0.
Return Value:
On success, the call returns 1. On failure, value of -1 is returned and errno is set
indicating the cause of the failure.
Errors:
EINVAL is set if elemcount is not 1 or index is not 0.
EINVAL is set if the user's size declaration isn't valid.
ENOSYS is set if stable storage is not supported.
EFAULT is set if buf points to an invalid address.
4.22 pstat_getstatic()
Synopsis:
int pstat_getstatic(struct pst_static *buf, size_t elemsize, size_t elemcount, int index);
Description:
This call returns static system information -- data that will remain the same (at least) until
reboot. It also provides the current sizes of all pstat data structures. There is one instance of this
context. Data up to a maximum of elemsize bytes are returned in the struct pst_static pointed to
by buf. The elemcount parameter must be 1. The index parameter must be 0.
Return Value:
On success, the call returns 1. On failure, value of -1 is returned and errno is set
indicating the cause of the failure.
Errors:
EINVAL is set if elemcount is not 1 or index is not 0.
If the user's size declaration isn't valid, EINVAL is set.
If buf points to an invalid address, EFAULT is set.
Example:
#include <sys/pstat.h>
void main(void)
{
struct pst_static pst;
if (pstat_getstatic(&pst, sizeof(pst), (size_t)1, 0) != -1) {
printf("page size is %d bytes\n", pst.page_size);