Operating System - Linux
1753880 Members
7366 Online
108809 Solutions
New Discussion

Re: pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3)

 
SOLVED
Go to solution
Laurent Menase
Honored Contributor

Re: pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3)

Hi,


When the return value is not the size requested, then it means the end of the list had been reached.
This MUST be the real end loop test.
Laurent Menase
Honored Contributor

Re: pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3)

while(1)
{
ret = pstat_getdisk(&sDiskData[0], sizeof(sDiskData[0]), SDISKTABSIZE, j);
if(ret<0)
{
perror("erreur");
printf("\nReturned with code %d with j=%d\n",ret,j);
break;
}
/* Process the data */
....
/* */
if(ret!=SDISKTABSIZE) break;
}
Hein van den Heuvel
Honored Contributor

Re: pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3)

Laurent,

I think 'sandiworld' agrees that the program should stop when 0 is returned, as you indicated in your first reply.

The original problem, which was believed to be correct, is now in fact proven to be broken. It only seemed to work.

The question then became why does 1 element work differently from more than 1 (since 11.31). Surely that's more curiosity than an serious question.

I just looked at it again, and it turns out that the difference is even more subbtle.

When pstat_getdisk is called in a loop, with ever increasing index, then it returns 0 indicating nothing was returned once the index is beyond the number of instances.
It is seen as asking for 'next' not a specific instance.

When it is called with an index not one higher that the prior, and larger than the number of instances, then the return code equals the index specified minus the actual number of instances.

So when we use more than 1 element to return, the program seen not seen asking for next but seen as askign for a specific start point returning the negtive value if the start point is beyond max instances. So that's the difference between 1 and more than 1

I would suggest, but don't really care, that in the case of an index larger than the number of instances the function should perhaps always return -1, not a variable number, and set errno to 22 (EINVAL).

Does anybody have idea why pstat_getdisk() call works with 2 elements and does not work with 1 element for HPUX 11.31?

Dennis>> It works perfectly fine on 11.31. You need to stop your loop on <= 0.
:
Returned with code 0

Right... but supposedly that's different from how the older versions worked. The woudl eventually return a negative number. 11.31 keeps returning 0. That's not bad, just different.

>>Hein: i, i, ret,sDiskData...
>That should be: j, i, ...

Of course. Sorry.

Cheers!
Hein.
Laurent Menase
Honored Contributor

Re: pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3)

In fact the error was in the program not on the os.
Even on 11.23 the first failing get returns 0.
only the next one is failing with an error.
The difference of behavior is just out of spec.
It is in a grey zone.

sandiworld
New Member

Re: pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3)

Thanks a lot everybody for your precious comments.
So it is for sure that pstat_getdisk() always returns 0 at the end of the list only and not in between. Am I right ?
Is this always a guaranteed operation and we can break the loop on <= 0 condition?
Laurent Menase
Honored Contributor

Re: pstat_getdisk() call doesn’t work properly in HPUX 11.31 (11i V3)

Yes It is the way it must be done.
even on 11.23 and before