Using the HP-UX libIO Library
Output
Persistent Special File Legacy Special File(s)
======================= =================
/dev/rdisk/disk14 /dev/rdsk/c4t2d0;
Example 3
Get a legacy special file from a legacy disk device, and find the corresponding
persistent special file.
Algorithm
1. Initialize the libIO library.
2. Get a legacy special file from an I/O node.
3. Get the persistent special file from the legacy special file.
4. Terminate the connection.
Solution
#include <stdio.h>
#include <sys/fcntl.h>
#include <sys/stat.h>
#include <sys/libIO.h>
main()
{
char options[3];
io_token_t node=(io_token_t)NULL;
int dev_type=D_CHR, is_char=0, is_block=0, ret=0;
dev_t dev;
char dsf_path[1024], retrieved_new_dsf[1024];
/*initialize libio operations */
if (io_init(O_RDONLY) != IO_SUCCESS) {
io_error("ERROR:io_init");
exit(1);
}
/*get an existing legacy disk device */
if ((node = io_search ((io_token_t)NULL, S_IOTREE, 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, "is_char", &is_char)
==IO_SUCCESS) {
dev_type = D_CHR;