PSTAT Interfaces
25
} else {
perror("pstat_getstatic");
}
}
4.23 pstat_getstream()
Synopsis:
int pstat_getstream(struct pst_stream *buf, size_t elemsize, size_t elemcount, int moduleskip,
struct pst_fid *fid);
Description:
This call provides detailed information specific to a stream. For the specified stream,
there is one instance of this context for the stream head, each module, and the driver. For each
call, data up to a maximum of elemsize bytes are returned in the structs pst_stream pointed to by
buf. The elemcount parameter specifies the number of structs pst_stream that are available at
buf. The moduleskip parameter indicates the number of modules to skip before returning
information about any modules. Head information is returned for every call. The fid parameter
uniquely identifies the file. This is obtained from calls to pstat_getfile2(). Use of this function is
limited to UID == 0 or effective UID match. Please refer pstat_getfiledetails() call for more
information on Effective UID match.
Return Value:
On success, the function returns the number of structures copied. This is at least 1 as the
head information is always returned. On failure, -1 is returned and errno is set indicating the
cause of the failure.
Errors:
• EINVAL is set If the user's size declaration isn't valid,.
• EINVAL is set if num parameter is <= 0 or moduleskip is < 0.
• EACESS is set f no effective ID match.
• EFAULT is set if buf points to an invalid address.
• ENOSTR is set if the file is neither stream type nor a stream-based socket.
• ENOENT is returned if file not found.
• ESRCH is returned if the required process is not found.
Example:
#include <sys/pstat.h>
#include <fcntl.h>
void main(void)
{
struct pst_fileinfo2 psf;
struct pst_stream psfstream[3];
int rv, count, fd;
fd = open("/dev/echo", O_RDONLY);
rv = pstat_getfile2(&psf, sizeof(psf), 0, fd, getpid());
if ((rv == 1) && (psf.psf_type == PS_TYPE_STREAMS)){
/*
* Ask for 3 structures (head + module(s) + driver).
* If there are no modules, we expect 2 structures(head, driver)
* If there is 1 module, we expect 3 structures (head, module, driver)