Using the HP-UX libIO Library
}
/*get an existing disk node from legacy view */
if ((node=io_search((io_token_t)NULL, S_IOTREE, Q_SW,
"class", "disk", NULL)) == (io_token_t)NULL) {
io_error("ERROR:io_search");
exit(1);
}
/* ascertain the type of device */
if (io_query(node, S_IOTREE, "is_char", &is_char)
==IO_SUCCESS) {
dev_type = D_CHR;
} else if(io_query(node, S_IOTREE, "is_block", &is_block)
== IO_SUCCESS)
dev_type = D_BLK;
/*get the dev_t */
if (io_mkdev(node, dev_type, "s0", &dev)!=IO_SUCCESS) {
io_error("ERROR:io_mkdev");
exit(1);
}
/* get the major num and minor number */
printf("\nLegacy view");
printf("\n===========");
printf(" \nThe major num : %d minor num : %d\n",
major(dev), minor(dev));
/* get an existing disk node in agile view */
if ((node=io_search((io_token_t)NULL, S_IOTREE_EXT,
Q_SW, "class", "disk", NULL))==(io_token_t)NULL) {
io_error("ERROR:io_search");
exit(1);
}
/*ascertain the type of device */
if (io_query(node, S_IOTREE_EXT, "is_char", &is_char)
==IO_SUCCESS) {
dev_type = D_CHR;
} else if (io_query(node, S_IOTREE_EXT, "is_block",
&is_block)==IO_SUCCESS) dev_type = D_BLK;
/*get the dev_t*/
if (io_mkdev_ext(node, dev_type, 0, &dev) !=IO_SUCCESS) {
io_error("ERROR: io_mkdev_ext: options: 0");
exit(1);
}
printf("\nAgile view ");
printf("\n==============");
printf("\nThe major num : %d minor num : %d\n",