Using the HP-UX libIO Library

1. Initialize the libIO library.
2. Search for the disk device in the legacy kernel I/O data structures.
3. Get the class name, instance number, hardware path, and driver name(s) of
this disk device and print it.
4. Terminate the connection.
Solution
#include <sys/libIO.h>
#include <stdio.h>
main()
{
io_token_t node;
char my_string[MAX_HW_PATH_STR];
hw_path_t hw_path;
char state[MAX_NAME_LEN];
char driver_name[MAX_NAME_LEN];
char class_name[MAX_NAME_LEN];
char type[MAX_NAME_LEN];
int instance=2;
/*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,
"instance", &instance, "class", "disk", NULL))
==NULL) {
io_error (io_search);
exit(1);
}
if (io_query_batch(node, S_IOTREE, "hw_path", &hw_path,
"instance", &instance, "type", type,"driver_name",
driver_name, "state", state, NULL) ==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(" class instance hardware path driver name
state type \n" );
printf(" disk %d %s %s %s %s \n ",