Using the HP-UX libIO Library
5. Get the hardware path string of that node.
6. Convert the hardware path to pre-HP-UX 11i v3 hardware path data structure.
7. Convert this pre-HP-UX 11i v3 hardware path to the HP-UX 11i v3 hardware
path data structure.
8. Terminate the connection.
Solution
#include <sys/libIO.h>
#include <stdio.h>
main()
{
leg_hw_path_t leg_path;
hw_path_t new_path, hw_path, hw_path1;
io_token_t node, legtoken;
char path[MAX_HW_PATH_STR ], path1[MAX_HW_PATH_STR ];
int ret=0;
/*initialise libio operations */
if (io_init(O_RDONLY) !=IO_SUCCESS) {
io_error("ERROR:io_init");
exit(1);
}
/*get an exiting I/O node of class ext_bus */
if ((node = io_search (NULL, S_IOTREE_EXT, Q_SW,"class",
"ext_bus" , NULL)) ==(io_token_t) NULL) {
io_error("ERROR:io_search");
exit(1);
}
/* get the hw_path of driver */
if (io_query (node, S_IOTREE_EXT, "hw_path",&hw_path)
== IO_ERROR) {
io_error("ERROR:io_query");
exit(1);
}
/*get the hw_path in string format of driver */
if (io_hw_path_to_str (path, &hw_path) == IO_ERROR) {
io_error("ERROR:io_hw_path_to_str");
exit(1);
}
/* Verify the hardwarepath is of legacy or agile */
if ((ret=io_is_hwpath_legacy(path))==IO_ERROR) {
io_error("ERROR:io_is_hwpath_legacy");
exit(1);
}
if(ret==IO_HWPATH_NEW) {
if(io_new_to_legacy_hwpath(&hw_path, &leg_path )