HP-UX Reference (11i v2 04/09) - 2 System Calls (vol 5)
p
pstat(2) pstat(2)
psfsocket.pst_type, PS_SOCK_STREAM);
} else {
printf("State changed\n");
}
} else {
perror("pstat_getsocket()");
}
} else {
perror("pstat_getfile2");
}
close(fd);
}
/*
* Example 11: Acquire pathname information about opened file
*/
main()
{
struct pst_fileinfo2 psf;
char filename[20];
int rv, count, fd;
fd = open("/etc/passwd", O_RDONLY);
rv = pstat_getfile2(&psf, sizeof(psf), 0, fd, getpid());
if (rv == 1) {
/*
* Ask for pathname 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("pathname not found in system cache\n");
} else {
perror("pstat_getpathname()");
}
} else {
perror("pstat_getfile2");
}
close(fd);
}
/*
* Example 12: Acquire multiple pathname information for a file
* system
*/
main()
{
struct pst_fileinfo2 psf;
struct pst_mpathnode mpath_buf[20];
int i, rv, count, fd;
pid_t target;
HP-UX 11i Version 2: September 2004 − 16 − Hewlett-Packard Company Section 2−−255