Using the HP-UX libIO Library

1. Initialize the libIO library.
2. Search for a disk device in the kernel data structures from legacy view.
3. Map this legacy node to corresponding agile node.
4. Print the mapping.
5. Map this agile node to corresponding node in the legacy view.
6. Print the mapping.
7. Search for a lunpath of a device in the kernel data structures from agile view.
8. Map this lunpath node to corresponding node in the agile view.
9. Print the mapping.
10. Terminate the connection.
Solution
#include <sys/libIO.h>
#include <stdio.h>
main()
{
io_token_t lun_path_node, tgt_path_node, legacy_node;
io_token_t new_node, lun_node, *token_array;
io_token_t *token_array1;
int ret=0, count=1;
hw_path_t hw_path, hw_path1;
char my_string[MAX_HW_PATH_STR];
char my_string1[MAX_HW_PATH_STR];
token_array =(io_token_t *)malloc(sizeof(io_token_t));
/* initialise libio operations */
if (io_init(O_RDONLY)!=IO_SUCCESS) {
io_error("ERROR:io_init");
exit(1) ;
}
/*IO_LEGACY_2_NEW mapping */
/*get the disk device node */
legacy_node=io_search ((io_token_t)NULL, S_IOTREE, Q_SW,
"class", "disk", NULL);
if (legacy_node==(io_token_t)NULL) {
io_error("ERROR:io_search:");
exit(1);
}
ret=io_get_mapping(legacy_node, IO_LEGACY_2_NEW, &count,
token_array);
if (ret==IO_E_BUF_TOO_SMALL) {
token_array=(io_token_t*)
malloc(count*sizeof(io_token_t));
ret=io_get_mapping(legacy_node, IO_LEGACY_2_NEW,