Using the HP-UX libIO Library
dsf_array=(char *)malloc(MAXPATHLEN );
/* initialize libio operations */
if (io_init(O_RDONLY)!=IO_SUCCESS) {
io_error("ERROR:io_init");
exit(1);
}
/* get an existing disk I/O node */
if ((node = io_search ((io_token_t)NULL, S_IOTREE_EXT,
Q_SW, "class", "disk", NULL)) == (io_token_t)NULL) {
io_error ("ERROR:io_search:class:disk");
exit (1);
}
/* ascertain the type of device */
if (io_query(node, S_IOTREE_EXT, "is_char", &is_char)
==IO_SUCCESS) {
dev_type = D_CHR;
} else if (io_query(node, S_IOTREE_EXT, "is_block",
&is_block) == IO_SUCCESS) dev_type = D_BLK;
/* try out io_mkdev() */
if (io_mkdev_ext(node, dev_type,0, &dev)!=IO_SUCCESS) {
io_error("ERROR:io_mkdev:options:s0");
exit(1);
}
if (dev_type == D_CHR) {
ret=devnm(S_IFCHR,dev,dsf_path, sizeof(dsf_path), 1);
if (ret != 0) {
printf("devnm failed \n");
exit(1);
}
ret=io_new_to_legacy_dsfs(dsf_path,dsf_array,&count);
if(ret == IO_ERROR)
io_error("ERROR: io_new_to_legacy_dsfs ");
exit(1);
} else {
printf("\nPersistent Special File Legacy Special
File(s)\n");
printf("=====================
==================\n");
printf("%s %s \n \n", dsf_path, dsf_array);
}
}
/*terminate libio operations */
io_end();
}