Using the HP-UX libIO Library

io_token_t node;
char my_string[MAX_HW_PATH_STR];
hw_path_t hw_path;
/*initialize libIO operations */
if (io_init (O_RDONLY)! =IO_SUCCESS){
io_error ("io_init");
exit (1);
}
/* get an existing disk node */
if ((node=io_search((io_token_t)NULL, S_IOTREE, Q_SW,
"class", "disk", NULL)) == NULL) {
io_error("io_search");
exit(1);
}
if (io_query (node, S_IOTREE, "hw_path", &hw_path)
==IO_ERROR ) {
io_error ("ERROR:io_query");
exit (1);
}
if(io_hw_path_to_str(my_string,&hw_path)==IO_ERROR) {
io_error("io_hw_path_to_str");
exit(1);
}
printf("H/W Path of the legacy disk device is (%s)\n",
my_string);
/* end of libIO operations */
io_end();
}
Output
H/W Path of the legacy disk device is (1/0/0/3/0.6.0)
Note: To get an I/O node from the agile view, use S_IOTREE_EXT instead of
S_IOTREE in the type field of io_search().
Example 2
Get an I/O node of a disk device from the legacy kernel I/O data structure and
print the class name, instance number, hardware path, and driver name of that
corresponding node.
Algorithm