From unknown Fri Sep 12 01:59:04 2025 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-Mailer: MIME-tools 5.509 (Entity 5.509) Content-Type: text/plain; charset=utf-8 From: bug#9279 <9279@debbugs.gnu.org> To: bug#9279 <9279@debbugs.gnu.org> Subject: Status: df -h should use human_round_to_nearest in human_output_opts for more accurate results Reply-To: bug#9279 <9279@debbugs.gnu.org> Date: Fri, 12 Sep 2025 08:59:04 +0000 retitle 9279 df -h should use human_round_to_nearest in human_output_opts f= or more accurate results reassign 9279 coreutils submitter 9279 Sabuj Pattanayek severity 9279 normal thanks From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 11 02:30:05 2011 Received: (at submit) by debbugs.gnu.org; 11 Aug 2011 06:30:05 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QrOmG-0002pH-RM for submit@debbugs.gnu.org; Thu, 11 Aug 2011 02:30:02 -0400 Received: from eggs.gnu.org ([140.186.70.92]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QrOEw-00024g-F2 for submit@debbugs.gnu.org; Thu, 11 Aug 2011 01:55:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrODc-0003oR-7e for submit@debbugs.gnu.org; Thu, 11 Aug 2011 01:54:16 -0400 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on eggs.gnu.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,FREEMAIL_FROM, RCVD_IN_DNSWL_LOW, T_DKIM_INVALID, T_TO_NO_BRKTS_FREEMAIL autolearn=unavailable version=3.3.1 Received: from lists.gnu.org ([140.186.70.17]:53701) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrODc-0003oN-69 for submit@debbugs.gnu.org; Thu, 11 Aug 2011 01:54:12 -0400 Received: from eggs.gnu.org ([140.186.70.92]:60537) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrODX-0002Ac-KM for bug-coreutils@gnu.org; Thu, 11 Aug 2011 01:54:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QrODT-0003na-0c for bug-coreutils@gnu.org; Thu, 11 Aug 2011 01:54:07 -0400 Received: from mail-pz0-f44.google.com ([209.85.210.44]:38263) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QrODS-0003nM-KQ for bug-coreutils@gnu.org; Thu, 11 Aug 2011 01:54:02 -0400 Received: by pzk36 with SMTP id 36so3648406pzk.17 for ; Wed, 10 Aug 2011 22:54:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=Bzj2himmZlxEf0rkw1memBMOiI+kJMjrDJppw0ZC+A0=; b=IhVO4pjPA4LCv7AeskTBo+BXE+i1b95w9sTlfB3sMfd7Rto/LCGN1TOnmrxwXZd4aS r2FH27Bo7gcr1MiiHNgLOFb1K+oEX0XkHNwqaUdxwperhG9F9zEHeIfj8kuPdgojmcsC cGaoap3tr8nEGvncnTdvRMzTpJ+GeeSNswbbk= MIME-Version: 1.0 Received: by 10.143.20.26 with SMTP id x26mr3995029wfi.114.1313042040547; Wed, 10 Aug 2011 22:54:00 -0700 (PDT) Received: by 10.142.194.12 with HTTP; Wed, 10 Aug 2011 22:54:00 -0700 (PDT) Date: Thu, 11 Aug 2011 00:54:00 -0500 Message-ID: Subject: df -h should use human_round_to_nearest in human_output_opts for more accurate results From: Sabuj Pattanayek To: bug-coreutils@gnu.org Content-Type: text/plain; charset=ISO-8859-1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) X-Received-From: 140.186.70.17 X-Spam-Score: -5.9 (-----) X-Debbugs-Envelope-To: submit X-Mailman-Approved-At: Thu, 11 Aug 2011 02:29:59 -0400 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -5.9 (-----) Hi, We have a 37TB filesystem that shows up in the output of df -h as 38TB : Filesystem Size Used Avail Use% Mounted on blue:/sas2fs03/ 38T 24T 14T 63% /blue/sas2 df -k shows : Filesystem 1K-blocks Used Available Use% Mounted on blue:/sas2fs03/ 39741816832 25020650784 14721166048 63% /blue/sas2 39741816832 is definitely much closer to 37TB than to 38TB : % echo "39741816832 / (1024^3)" | bc -l 37.01245117187500000000 38TB would be : echo "38*1024^3" | bc -l 40802189312 (in 1K-blocks) which is >> 39741816832 (difference of 1060372480) With my suggested patch (below), I get correct output : coreutils-8.9/src% ./df -h /blue/sas2 Filesystem Size Used Avail Use% Mounted on blue:/sas2fs03/ 37T 23T 14T 63% /blue/sas2 Here's my suggested patch against the 8.9 release : --- df.c.old 2011-08-11 00:45:02.697289000 -0500 +++ df.c 2011-08-11 00:45:45.884017000 -0500 @@ -794,7 +794,7 @@ inode_format = true; break; case 'h': - human_output_opts = human_autoscale | human_SI | human_base_1024; + human_output_opts = human_round_to_nearest | human_autoscale | human_SI | human_base_1024; output_block_size = 1; break; case 'H': Thanks, Sabuj Pattanayek From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 11 11:21:42 2011 Received: (at 9279) by debbugs.gnu.org; 11 Aug 2011 15:21:42 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QrX4o-000868-Ei for submit@debbugs.gnu.org; Thu, 11 Aug 2011 11:21:42 -0400 Received: from smtp.cs.ucla.edu ([131.179.128.62]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QrX4k-00085z-TL for 9279@debbugs.gnu.org; Thu, 11 Aug 2011 11:21:40 -0400 Received: from localhost (localhost.localdomain [127.0.0.1]) by smtp.cs.ucla.edu (Postfix) with ESMTP id D474C39E80FF; Thu, 11 Aug 2011 08:20:17 -0700 (PDT) X-Virus-Scanned: amavisd-new at smtp.cs.ucla.edu Received: from smtp.cs.ucla.edu ([127.0.0.1]) by localhost (smtp.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 8n8x-xMRZVo8; Thu, 11 Aug 2011 08:20:17 -0700 (PDT) Received: from [198.18.132.116] (unknown [66.224.35.98]) by smtp.cs.ucla.edu (Postfix) with ESMTPSA id 0B13539E80DC; Thu, 11 Aug 2011 08:20:16 -0700 (PDT) Message-ID: <4E43F32B.5000307@cs.ucla.edu> Date: Thu, 11 Aug 2011 08:20:11 -0700 From: Paul Eggert User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.2.18) Gecko/20110617 Thunderbird/3.1.11 MIME-Version: 1.0 To: Sabuj Pattanayek Subject: Re: bug#9279: df -h should use human_round_to_nearest in human_output_opts for more accurate results References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Spam-Score: -2.6 (--) X-Debbugs-Envelope-To: 9279 Cc: 9279@debbugs.gnu.org X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -2.6 (--) tag 9279 notabug thanks Thanks, but df always rounds up. POSIX requires this for formats it specifies; see and look for "rounded". for other formats, I thought it better to be consistent. From debbugs-submit-bounces@debbugs.gnu.org Thu Aug 11 11:51:33 2011 Received: (at 9279-done) by debbugs.gnu.org; 11 Aug 2011 15:51:33 +0000 Received: from localhost ([127.0.0.1] helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QrXXh-0000MS-52 for submit@debbugs.gnu.org; Thu, 11 Aug 2011 11:51:33 -0400 Received: from mx.meyering.net ([82.230.74.64]) by debbugs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1QrXXd-0000MJ-Es for 9279-done@debbugs.gnu.org; Thu, 11 Aug 2011 11:51:31 -0400 Received: from rho.meyering.net (localhost.localdomain [127.0.0.1]) by rho.meyering.net (Acme Bit-Twister) with ESMTP id CEBBF6005B; Thu, 11 Aug 2011 17:50:08 +0200 (CEST) From: Jim Meyering To: Sabuj Pattanayek Subject: Re: bug#9279: df -h should use human_round_to_nearest in human_output_opts for more accurate results In-Reply-To: <4E43F32B.5000307@cs.ucla.edu> (Paul Eggert's message of "Thu, 11 Aug 2011 08:20:11 -0700") References: <4E43F32B.5000307@cs.ucla.edu> Date: Thu, 11 Aug 2011 17:50:08 +0200 Message-ID: <87ty9oymkv.fsf_-_@rho.meyering.net> Lines: 18 MIME-Version: 1.0 Content-Type: text/plain X-Spam-Score: -6.1 (------) X-Debbugs-Envelope-To: 9279-done Cc: 9279-done@debbugs.gnu.org, Paul Eggert X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.11 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: debbugs-submit-bounces@debbugs.gnu.org Errors-To: debbugs-submit-bounces@debbugs.gnu.org X-Spam-Score: -6.1 (------) Paul Eggert wrote: > Thanks, but df always rounds up. POSIX requires this for formats it specifies; > see > and look for "rounded". for other formats, I thought it better to be > consistent. Thanks for the patch. Note that the consistency argument applies not just to df, but also to du and ls. All of those tools are documented to round block counts up. If you feel ambitious, an alternative may be to extend human.c so that setting the BLOCK_SIZE envvar to say, "human-readable-round-to-nearest", makes all of those tools do what you propose. The "Block size" section of "info coreutils" describes how the BLOCK_SIZE envvar works. I'm closing this issue. If you propose to change gnulib's human.c, please start a new thread with an appropriate subject. From unknown Fri Sep 12 01:59:04 2025 Received: (at fakecontrol) by fakecontrolmessage; To: internal_control@debbugs.gnu.org From: Debbugs Internal Request Subject: Internal Control Message-Id: bug archived. Date: Fri, 09 Sep 2011 11:24:03 +0000 User-Agent: Fakemail v42.6.9 # This is a fake control message. # # The action: # bug archived. thanks # This fakemail brought to you by your local debbugs # administrator