Using the HP-UX libIO Library

{
io_token_t node;
io_dev_info_t *dev_array;
int is_char=0, is_block=0, ret=0, count=1, i=0;
char dsf_path[MAXPATHLEN], blk_dsf[MAXPATHLEN];
char retrieved_chr_dsf[MAXPATHLEN];
/* initialise libio operations */
if (io_init(O_RDONLY)!=IO_SUCCESS) {
io_error("ERROR:io_init");
exit(1);
}
/* get an existing disk node */
if ((node=io_search((io_token_t)NULL, S_IOTREE_EXT, Q_SW,
"class", "disk", "driver_name", "esdisk",
NULL))==(io_token_t)NULL) {
io_error("ERROR:io_search:class:disk");
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;
/* try out io_mkdev() */
if (io_mkdev_ext(node, dev_type,0, &dev)!=IO_SUCCESS) {
io_error("ERROR:io_mkdev:options:s0");
exit(1);
}
if (dev_type==D_CHR) ret=devnm(S_IFCHR, dev, dsf_path,
sizeof(dsf_path), 1);
if (ret != 0) {
printf("devnm failed\n");
exit(1);
}
/*map the character to block device special file */
ret=io_char_to_block_dsf(dsf_path, blk_dsf);
if (ret!=IO_SUCCESS) {
io_error("ERROR:io_char_to_block_dsf");
exit(1);
} else {
printf("Character Special File Block Special
File\n");
printf("====================== ===============\n");
printf("%s %s \n \n", dsf_path, blk_dsf );
ret=io_block_to_char_dsf(blk_dsf, retrieved_chr_dsf);