PSTAT Interfaces
8
context of open files for the specified process: it is a 32-bit quantity constructed of the pst_idx
field of the ‘owning’ process, obtained via pstat_getproc(), as the most significant 16 bits, and
the index of open files within the process as the least significant 16 bits. Example:
index = ((pst_idx << 16) | (file_index & 0xffff));
As a shortcut, information for a single file within the specified process may be obtained
by setting elemcount to zero and setting the least significant 16 bits to the file descriptor number.
The most significant 16 bits are still set to the pst_idx field from the pst_status structure for the
process. The pst_fileinfo structure contains both psf_offset and psf_offset64 elements. The
psf_offset element can correctly store only a 32-bit value, whereas the psf_offset64 element can
store a 64-bit value. pstat_getfile() will fill in both psf_offset and psf_offset64 if the value can be
correctly stored in both elements. If the offset is too large to be correctly stored in psf_offset,
then psf_offset will contain a –1. No error will be set in this case.
Return Value:
This call returns –1 on failure or number of instances copied to buf on success.
Errors:
• ENOENT is set if the specified file is not found or closed.
• EINVAL is set if elemcount is not zero and index is less than zero.
• EINVAL is set if the user’s size declaration is invalid.
• ESRCH is the specified process is not found.
4.6 pstat_getfile2()
Synopsis:
int pstat_getfile2(struct pst_fileinfo2 *buf, size_t elemsize, size_t elemcount, int index,
pid_t pid);
Description:
This call returns information about open files for a specified process. For the specified
process, there is one instance of this context for each open file descriptor. For each instance,
data up to a maximum of elemsize bytes are returned in the structs pst_fileinfo2 pointed to by
buf. The elemcount parameter specifies the number of structs pst_fileinfo2 that are available at
buf. The index parameter specifies the starting index within the context of open files for the
specified process: It is the file descriptor number with which to begin. The pid parameter
specifies the process ID (IDentification number).
As a shortcut, information for a single file within the specified process may be obtained
by setting elemcount to zero and setting the index to the file descriptor number. The target PID
should be specified in the pid argument. The pst_fileinfo2 structure contains both psf_offset and
psf_offset64 element. The psf_offset element can correctly store only a 32-bit value, whereas the
psf_offset64 element can store a 64-bit value. pstat_getfile2() will fill in both psf_offset and
psf_offset64 if the value can be correctly stored in both elements. If the offset is too large to be
correctly stored in psf_offset , then psf_offset will contain a -1. No error will be set in this case.
Return Value:
This call returns –1 on failure or number of instances copied to buf on success.
Errors:
• ENOENT is set if the specified file is not found or closed.
• EINVAL is set if elemcount is not zero and index is less than zero.
• EINVAL is set if the user’s size declaration is invalid.
• ESRCH is the specified process is not found.