1827696 Members
3322 Online
109967 Solutions
New Discussion

function pstat_getlv

 
Marcelo De Florio_1
Frequent Advisor

function pstat_getlv


what the meaning of dev_t in the index parameter (in pstat_getlv function) ?

MDF
Marcelo De Florio
1 REPLY 1
A. Clay Stephenson
Acclaimed Contributor

Re: function pstat_getlv

Hi Marcelo:

Rather than trying to explain, I spent less than 5 minutes throwing together a program which uses pstat_getlv in the context you describe. Normally, pstat_getlv is supplied with a buffer array of some programmer determined number of maximum number of logical volumes to return information about, the element size, the maximum no. the array will hold, and an index of 0. pstat_getlv then populates the buffer array and returns the number of lvols actually loaded.

In this context, however, you do a stat of (e.g.) /dev/vg00/lvol3 to get the st_rdev value
(that's the dev_t you were asking about). You then use that value (cast as an int) as the index value. In this case the buffer need only be able to hold 1 value. You also must set the elemcount value to 0 to tell pstat_getlv that you are operating in this special mode.

Compile this baby program and use it like this:
lvol /dev/vg00/lvol1 /dev/vg01/lvol3 ...
It will then list the node, the major device number (in dec), and the minor device number (in hex). It took me longer to explain this than it did to code the c.

Regards, Clay
If it ain't broke, I can fix that.