|
pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3)
As per the man page, pstat_getdisk() call returns the number of instances, which could be 0 upon successful completion, otherwise a value of -1 is returned.
Please have a look at this sample program ->
#include <stdio.h>
#include <sys/pstat.h>
int main()
{
int j = 0, ret;
struct pst_diskinfo sDiskData;
while(1)
{
ret = pstat_getdisk(&sDiskData, sizeof(sDiskData), 1, j);
if(ret<0)
{
printf("\nReturned with code %d \n",ret);
break;
}
printf("\n Ret Code : %d , Device Name : %s%d",ret,sDiskData.psd_drv_name.psd_name,sDiskData.psd_instance);
j++;
}
return 0;
}
On HP-UX 11.11 and 11.23, the call pstat_getdisk() returns series of ‘1’s then single ‘0’ and finally ‘-1’ and the program terminates successfully.
On HP-UX 11.31 the call pstat_getdisk() returns series of ‘1’s followed by series of ‘0’s and never returns ‘-1’, so the same program never terminates.
The workaround would be to replace the condition
if(ret<0)
with
if(ret==0)
But, will this call always returns ‘1’s followed by ‘0’s or there can be a case in which the call will return ‘0’ in between?
In another way, can we get an invalid index in between or all the valid disks are in sequence only?
Last edited by sandiworld; 10-25-2007 at 11:32 AM..
|