pstat.2 (2010 09)
p
pstat(2) pstat(2)
Example 12
Acquire path name information about an open file.
main()
{
struct pst_fileinfo2 psf;
char filename[20];
int rv, count, fd;
(void)memset(&psf,0,sizeof(psf));
(void)memset(filename,0,sizeof(filename));
fd = open("/etc/passwd", O_RDONLY);
rv = pstat_getfile2(&psf, sizeof(psf), 0, fd, getpid());
if (rv == 1) {
/*
* Ask for path name information.
*/
count = pstat_getpathname(filename, 20, &(psf.psf_fid));
if (count > 0) {
if (strncmp("/etc/passwd", filename, count) == 0) {
printf("Success\n");
} else {
printf("Error encountered\n");
}
} else if (count == 0) {
printf("path name not found in system cache\n");
} else if ((count == -1) && (errno == EOVERFLOW)){
perror("pstat_getpathname(): input buffer too small");
}
} else {
perror("pstat_getfile2");
}
close(fd);
}
Example 13
Acquire multiple path name information for a file system.
main()
{
struct pst_fileinfo2 psf;
struct pst_mpathnode mpath_buf[20];
int i, rv, count, fd;
pid_t target;
(void)memset(&psf,0,sizeof(psf));
(void)memset(&mpath_buf,0,sizeof(mpath_buf));
target = getpid();
fd = open("/etc/passwd", O_RDONLY);
rv = pstat_getfile2(&psf, sizeof(psf), 0, fd, target);
if (rv == 1) {
/*
* Ask for multiple path name information.
*/
26 Hewlett-Packard Company − 26 − HP-UX 11i Version 3: September 2010