Operating System - Linux
1827892 Members
1895 Online
109969 Solutions
New Discussion

Confusion with libIO APIs:io_search()

 
amit mehta_2
Regular Advisor

Confusion with libIO APIs:io_search()

Hi,

Recently i found one white paper on libIO APIs for HPUX 11i V3.

http://docs.hp.com/en/oshpux11iv3.html
"Using the HP-UX libIO Library"

I'm not much of a programmer and was wondering why one of the variable(instance) in example 2 from the same doc is initialized to 2 ?

snip from the code:
if((node = io_search((io_token_t)NULL,S_IOTREE,Q_SW,"instance",&instance,"class","disk",NULL)) == NULL){
io_error("io_search error");
exit(1);
}

Beside this, Running the same program on my machine is giving me error message:

root@hpia7/LIBIO/ $ cc -lIO -o example2 ex2.c
root@hpia7/LIBIO/ $ ./example2
io_search error: No match found <====

snip from /usr/include/sys/libIO.h
/* Definitions for libIO io_errno values */

IO_E_MATCH =16,/* No match found */

~amit
1 REPLY 1
Dennis Handly
Acclaimed Contributor

Re: Confusion with libIO APIs:io_search()

>why one of the variable (instance) in example 2 from the same doc is initialized to 2?

The call to io_search is asking for instance 2 for class == "disk".
If you put instance in a loop I get:
$ a.out
class instance hardware path driver name state type
disk 0 0/1/1/0.0.0 sdisk CLAIMED DEVICE
disk 1 0/1/1/1.2.0 sdisk CLAIMED DEVICE
disk 2 0/0/2/0.0.0.0 sdisk CLAIMED DEVICE
Error:io_search: No match found.