Using the HP-UX libIO Library
int io_block_to_raw(dev_t bdev, dev_t *rdev);
io_raw_to_block()
The routine returns the character dev_t of a block dev_t. The synopsis of the
function is:
int io_raw_to_block(dev_t rdev, dev_t *bdev);
Examples
Example 1
Build a dev_t from an I/O node of a disk device for partition 0 of the disk in the
legacy and agile views. Print the major number and minor number of this dev_t.
Algorithm
1. Initialize the libIO library.
2. Search for a disk device in the kernel data structures in the legacy view.
3. Get the device type from the node.
4. Build the dev_t of the node.
5. Search for a disk device in the kernel data structures in agile view.
6. Get the device type from the node.
7. Build the dev_t of the node.
8. Print the major number and minor number of the dev_t.
9. Terminate the connection.
Solution
#include<sys/libIO.h>
#include<sys/mknod.h>
#include<stdio.h>
main()
{
io_token_t node;
int dev_type;
int is_char=0 ,is_block=0;
dev_t dev ;
/*initialize libio operations */
if (io_init(O_RDONLY)!=IO_SUCCESS){
io_error(io_init);
exit(1);