From owner-freebsd-current@FreeBSD.ORG Sat Nov 15 14:13:34 2003 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id BC60316A4CE for ; Sat, 15 Nov 2003 14:13:34 -0800 (PST) Received: from stork.mail.pas.earthlink.net (stork.mail.pas.earthlink.net [207.217.120.188]) by mx1.FreeBSD.org (Postfix) with ESMTP id D6F9E43F3F for ; Sat, 15 Nov 2003 14:13:33 -0800 (PST) (envelope-from tlambert2@mindspring.com) Received: from user-2ivfj2j.dialup.mindspring.com ([165.247.204.83] helo=mindspring.com) by stork.mail.pas.earthlink.net with asmtp (SSLv3:RC4-MD5:128) (Exim 3.33 #1) id 1AL8eH-0007PS-00; Sat, 15 Nov 2003 14:12:12 -0800 Message-ID: <3FB6A47D.76F3DAE9@mindspring.com> Date: Sat, 15 Nov 2003 14:11:09 -0800 From: Terry Lambert X-Mailer: Mozilla 4.79 [en] (Win98; U) X-Accept-Language: en MIME-Version: 1.0 To: Peter Edwards References: <20031113020400.GA44619@xor.obsecurity.org> <20031113074425.GC39616@cirb503493.alcatel.com.au> <20031113085418.GA47995@xor.obsecurity.org> <3FB4E8A1.6090402@openet-telecom.com> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-ELNK-Trace: b1a02af9316fbb217a47c185c03b154d40683398e744b8a462ba592e919fa4587217bf2f4b518f10350badd9bab72f9c350badd9bab72f9c350badd9bab72f9c cc: Peter Jeremy cc: Kris Kennaway cc: ticso@cicely.de cc: current@freebsd.org Subject: Re: Who needs these silly statfs changes... X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 15 Nov 2003 22:13:34 -0000 Peter Edwards wrote: > >>>On Wed, Nov 12, 2003 at 06:04:00PM -0800, Kris Kennaway wrote: > >>>>...my sparc machine reports that my i386 nfs server has 15 exabytes of > >>>>free space! [ ... ] > The NFS protocols have unsigned fields where statfs has signed > equivalents: NFS can't represent negative available disk space ( Without > the knowledge of the underlying filesystem on the server, negative free > space is a little nonsensical anyway, I suppose) > > The attached patch stops the NFS server assigning negative values to > unsigned fields in the statfs response, and works against my local > solaris box. Seem reasonable? I disagree. The intent of the negative number from df is to subtract the amount used from the total amount available, in order to get the amount remaining. When this results in a negative number, what it's saying is that you are using up space from the free reserve. This is an artifact of implementation on the server, and should not be second-guessed by the client. The problem in this case is on the client, not the server, in not doing the conversion as an unsigned operation. The place for the subtraction to occur is in the "df" program. In other words, the statfs->f_bavail should be recalculated locally from the values of statfs->f_blocks and statfs->f_bfree, not used directly out of the (unsigned) NFS values... or the values should be converted to signed values coming out of NFS prior to their sign extension to the size type. On a slightly related note, the standards mandated interfaces say that the values should be fsblkcnt_t, which must be an unsigned integer type. This coordinates well with my point of the sign conversion on legacy interface needing to happen at presentation time. Also, if you read the ISO C99 standard, you'll see that on an ILP32 system, there is no way to legitimately define an integer type in excess of 32 bits, unless long is larger than 32 bits (see section 3.6), so defining these things as 64 bits without compiler changes is wrong anyway. -- Terry