From owner-freebsd-fs@FreeBSD.ORG Sun May 1 15:48:12 2011 Return-Path: Delivered-To: fs@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 974EB1065670 for ; Sun, 1 May 2011 15:48:12 +0000 (UTC) (envelope-from jdc@koitsu.dyndns.org) Received: from qmta11.emeryville.ca.mail.comcast.net (qmta11.emeryville.ca.mail.comcast.net [76.96.27.211]) by mx1.freebsd.org (Postfix) with ESMTP id 7DD388FC17 for ; Sun, 1 May 2011 15:48:12 +0000 (UTC) Received: from omta21.emeryville.ca.mail.comcast.net ([76.96.30.88]) by qmta11.emeryville.ca.mail.comcast.net with comcast id eFTZ1g0011u4NiLABFb11p; Sun, 01 May 2011 15:35:01 +0000 Received: from koitsu.dyndns.org ([67.180.84.87]) by omta21.emeryville.ca.mail.comcast.net with comcast id eFb01g00Z1t3BNj8hFb1l1; Sun, 01 May 2011 15:35:01 +0000 Received: by icarus.home.lan (Postfix, from userid 1000) id 84BFE9B418; Sun, 1 May 2011 08:35:00 -0700 (PDT) Date: Sun, 1 May 2011 08:35:00 -0700 From: Jeremy Chadwick To: Rick Macklem Message-ID: <20110501153500.GA99593@icarus.home.lan> References: <20110501184904.S975@besplex.bde.org> <506337690.827521.1304260638431.JavaMail.root@erie.cs.uoguelph.ca> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <506337690.827521.1304260638431.JavaMail.root@erie.cs.uoguelph.ca> User-Agent: Mutt/1.5.21 (2010-09-15) Cc: rmacklem@freebsd.org, fs@freebsd.org Subject: Re: newnfs client and statfs X-BeenThere: freebsd-fs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Filesystems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 01 May 2011 15:48:12 -0000 [snip] On Sun, May 01, 2011 at 10:37:18AM -0400, Rick Macklem wrote: > > % + sbp->f_ffree = (sfp->sf_ffiles & OFF_MAX); > > > > Any masking here is logically wrong, and in practice just destroys the > > sign bit, as described above for the 0x7fffffff mask with old 32 bit > > systems. Masking with OFF_MAX has additional logic errors. OFF_MAX > > is the maximum value for an off_t, but none of the types here has > > anything to do with off_t. > > > > Ok, sf_ffiles is defined as uint64_t on the wire. Therefore there is > no sign bit. The problem is that it could be a larger positive value > than FreeBSD supports. All I wanted this code to do is make it the > largest positive value that will fit in int64_t. (I used OFF_MAX > because you suggested in a previous email that that was preferable > to 0x7fffffffffffffffLLU for nm_maxfilesize. I don't see anything > like INT64_MAX, UINT64_MAX in FreeBSD's limits.h) > Would > > if (sfp->sf_ffiles > UINT64_MAX) > sbp->f_ffree = INT64_MAX; > else > sbp->f_ffree = sfp->sf_ffiles; > > - 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? Aren't these effectively defined in as UQUAD_MAX and QUAD_MAX? These get translated/pulled in from , which varies per architecture. This looks like the translation based on looking at the respective include files per arch: i386: UQUAD_MAX == __UQUAD_MAX == __ULLONG_MAX == 0xffffffffffffffffULL i386: QUAD_MAX == __QUAD_MAX == __LLONG_MAX == 0x7fffffffffffffffLL amd64: UQUAD_MAX == __UQUAD_MAX == __ULONG_MAX == 0xffffffffffffffffUL amd64: QUAD_MAX == __QUAD_MAX == __LONG_MAX == 0x7fffffffffffffffL There are some #ifdef's in around some of these declarations which I don't understand (like __BSD_VISIBLE), but I would imagine the above declarations would do what you want. -- | Jeremy Chadwick jdc@parodius.com | | Parodius Networking http://www.parodius.com/ | | UNIX Systems Administrator Mountain View, CA, USA | | Making life hard for others since 1977. PGP 4BD6C0CB |