HP-UX Reference (11i v2 07/12) - 2 System Calls (vol 5)

p
pstat(2) pstat(2)
open file for a specified process. For the specified process, there is one instance of this con-
text for each open file descriptor. For each instance requested, data, up to a maximum of
elemsize bytes, is returned in the structs
pst_fileinfo pointed to by buf. The
elemcount parameter specifies the number of
structs pst_fileinfo that are
available at
buf to be filled in. The
index parameter specifies the starting index within
the 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()
, described
above, 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 a psf_offset and
psf_offset64 ele-
ment. The
psf_offset element can correctly store 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.
pstat_getfile2()
Returns information specific to a particular open file for a specified process. For the
specified process, there is one instance of this context for each open file descriptor. For
each instance requested, data, up to a maximum of
elemsize bytes, is 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 to be filled in. 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.
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 pst_fileinfo2 structure contains both a
psf_offset and psf_offset64
element. The psf_offset element can correctly store 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.
pstat_getfiledetails()
Returns detailed information specific to a particular open file. For a specified opened file,
there is only one instance of this context. For each call, data, up to a maximum of
elem-
size
bytes, is returned in the struct pst_filedetails
pointed to by buf. The
fid parameter uniquely identifies the file. This fid is obtained from calls to
pstat_getfile(), pstat_getproc(),orpstat_getprocvm()
. The
pst_filedetails structure contains information equivalent to the stat(2) call. Use of
this function is limited to UID==0 or effective UID match. Effective UID match occurs
when the effective or real UID of the calling thread matches the effective or real UID of the
target process and the target process has NOT done a set[u/g]id.
The structure members psfd_mode, psfd_ino, psfd_dev, psfd_uid, psfd_gid,
psfd_atime , psfd_mtime , psfd_ctime will have meaningful values for regular
files, character or block special files, and pipes. The value of the member psfd_nlink
will be set to number of links to the file. The member psfd_rdev will have meaningful
value for character or block special files, while the psfd_size is valid for regular files.
The members psfd_hi_fileid, psfd_lo_fileid, psfd_hi_nodeid
, and
psfd_lo_nodeid are unique ids representing the opened file. These ids together are
used to match the corresponding ids returned from the pstat_getfile2(). This call
does not work for sockets other than AF_UNIX family type.
pstat_getipc()
Returns information about System V IPC subsystem. There is one global instance of this
278 Hewlett-Packard Company 5 HP-UX 11i Version 2: December 2007 Update