newnfs client and statfs
Bob Friesenhahn
bfriesen at simple.dallas.tx.us
Sun May 1 17:39:13 UTC 2011
On Sun, 1 May 2011, Rick Macklem wrote:
>
> 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;
That one seems better because it preserves more of the value, but
perhaps this is better because it does not depend on
undocumented/undefined behavior (also untested):
uint64_t tmp;
tmp = sfp->sf_abytes / NFS_FABLKSIZE;
if (tmp > (uint64_t) INT64_MAX)
sbp->f_bavail = INT64_MAX;
else
sbp->f_bavail = tmp;
Bob
--
Bob Friesenhahn
bfriesen at simple.dallas.tx.us, http://www.simplesystems.org/users/bfriesen/
GraphicsMagick Maintainer, http://www.GraphicsMagick.org/
More information about the freebsd-fs
mailing list