newnfs client and statfs
Rick Macklem
rmacklem at uoguelph.ca
Sun May 1 20:47:04 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;
>
That's basically what I went with for the updated patch, except I
didn't put in the "if (tmp > (uint64_t) INT64_MAX)" since once
you divide sf_abytes by 2 or more it is guaranteed to be less than
or equal INT64_MAX.
rick
More information about the freebsd-fs
mailing list