Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 1 May 2011 12:44:52 -0400 (EDT)
From:      Rick Macklem <rmacklem@uoguelph.ca>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        rmacklem@freebsd.org, fs@freebsd.org
Subject:   Re: newnfs client and statfs
Message-ID:  <1211771823.830180.1304268292625.JavaMail.root@erie.cs.uoguelph.ca>
In-Reply-To: <20110502015700.Q2013@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help

> 
> >> - 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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1211771823.830180.1304268292625.JavaMail.root>