newnfs client and statfs
Rick Macklem
rmacklem at uoguelph.ca
Sun May 1 16:44:53 UTC 2011
>
> >> - except there isn't a UINT64_MAX, INT64_MAX defined in sys/*.h as
> >> far as I can see. How do I express these constants? Do I have to
> >> convert 0x7ffffffffffffff to decimal and use that?
>
> UINT64_MAX, etc., are defined in <sys/stdint.h>, which doesn't even
> need
> to be included explicitly, since it is (bogusly) standard namespace
> pollution in <sys/systm.h>. This namespace pollution gives the bizarre
> situation that you have to include <sys/limits.h> to get the limits
> for
> basic types, but you get the limits for the fix-with types whether you
> want them or not, except in rare cases where <sys/systm.h> is not
> needed
> for other reasons.
>
Ok, now I see them (in machine/include/_stdint.h). Appologies for the
noise. I grep'd sys/sys and couldn't find anything called (U)INT64_MAX.
Now, remembering that sf_abytes is uint64_t per the RFCs, what do people
think of either of these?
if (sfp->sf_abytes > INT64_MAX)
sbp->f_bavail = INT64_MAX;
else
sbp->f_bavail = sfp->sf_abytes / NFS_FABLKSIZE;
Or should I try and do the division to see if the large
value in sf_abytes will fit in INT64_MAX after the division? Something
like:
int64_t tmp;
tmp = sfp->sf_abytes;
tmp /= NFS_FABLKSIZE;
if (tmp < 0)
sbp->f_bavail = INT64_MAX;
else
sbp->f_bavail = tmp;
Neither tested, of course, rick
More information about the freebsd-fs
mailing list