From ceri@submonkey.net  Wed Aug 30 13:11:40 2006
Return-Path: <ceri@submonkey.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id 048F516A4DD
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 30 Aug 2006 13:11:40 +0000 (UTC)
	(envelope-from ceri@submonkey.net)
Received: from shrike.submonkey.net (cpc2-cdif2-0-0-cust107.cdif.cable.ntl.com [81.104.168.108])
	by mx1.FreeBSD.org (Postfix) with ESMTP id 7AC1043D49
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 30 Aug 2006 13:11:39 +0000 (GMT)
	(envelope-from ceri@submonkey.net)
Received: from ceri by shrike.submonkey.net with local (Exim 4.63 (FreeBSD))
	(envelope-from <ceri@submonkey.net>)
	id 1GIPqz-000FME-Mx
	for FreeBSD-gnats-submit@freebsd.org; Wed, 30 Aug 2006 14:11:37 +0100
Message-Id: <E1GIPqz-000FME-Mx@shrike.submonkey.net>
Date: Wed, 30 Aug 2006 14:11:37 +0100
From: Ceri Davies <ceri@FreeBSD.org>
Sender: Ceri Davies <ceri@submonkey.net>
Reply-To: Ceri Davies <ceri@FreeBSD.org>
To: FreeBSD-gnats-submit@freebsd.org
Cc:
Subject: df(1) can forget to print the unit with -h
X-Send-Pr-Version: 3.113
X-GNATS-Notify:

>Number:         102694
>Category:       bin
>Synopsis:       df(1) can forget to print the unit with -h
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    antoine
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Wed Aug 30 13:20:22 GMT 2006
>Closed-Date:    Sun Apr 20 16:47:33 UTC 2008
>Last-Modified:  Sun Apr 20 16:47:33 UTC 2008
>Originator:     Ceri Davies
>Release:        FreeBSD 6.1-STABLE i386
>Organization:
Submonkey
>Environment:
System: FreeBSD shrike.private.submonkey.net 6.1-STABLE FreeBSD 6.1-STABLE #48: Thu Aug 24 06:19:32 BST 2006 root@shrike.private.submonkey.net:/usr/obj/usr/src/sys/SHRIKE i386


	
>Description:

	The unit is missing from the Used column here:

	{ceri@shrike}-{~} % df -h /usr/ports
	Filesystem     Size    Used   Avail Capacity  Mounted on
	/dev/ad1s1a    1.1G    1000    104M    91%    /usr/ports
	{ceri@shrike}-{~} % df -k /usr/ports
	Filesystem  1K-blocks    Used  Avail Capacity  Mounted on
	/dev/ad1s1a   1190120 1023920 106696    91%    /usr/ports

>How-To-Repeat:
	
	Have a filesystem that has used 1000M.  Look at it.

>Fix:

	Not sure if this is df(1) or libutil's humanize_number(3)
	to be honest.

>Release-Note:
>Audit-Trail:

From: Ricardo Nabinger Sanchez <rnsanchez@wait4.org>
To: bug-followup@FreeBSD.org
Cc: ceri@FreeBSD.org
Subject: Re: bin/102694: df(1) can forget to print the unit with -h
Date: Fri, 6 Oct 2006 23:36:34 -0300

 > Not sure if this is df(1) or libutil's humanize_number(3)
 > to be honest.
 
 I was looking at it and was able to reproduce it and found what's going on.
 
 What happens is that, for numbers close to the next scale (1000<= x <1024),
 the scaled number is big for the 6-char buffer, which in fact is told be be
 6-1 bytes.  From the source:
 
 humanize_number(buf, sizeof(buf) - (bytes < 0 ? 0 : 1),
 	    bytes, "", HN_AUTOSCALE, flags);
 
 That "sizeof(buf) - (bytes < 0 ? 0 : 1)" causes humanize_number to think that
 the buffer has only 5 chars, thus producing:
 
 	[ ][1][0][0][0][\0]
 
 If one remove that restriction, the unit comes back:
 
 	[1][0][0][0][M][\0]
 
 The drawback is that it no longer scales "humanly" for numbers >= 1024, going
 up to 9999 (ugly).
 
 I spent a good time trying to figure out a clean and effective solution, but
 the best I got was to not use humanize_number, and scale the number locally.
 
 If that is good enough, I can clean up my code and send a patch.
 
 Regards.
 
 -- 
 Ricardo Nabinger Sanchez     <rnsanchez@{gmail.com,wait4.org}>
 Powered by FreeBSD
 
   "Left to themselves, things tend to go from bad to worse."
Responsible-Changed-From-To: freebsd-bugs->pjd 
Responsible-Changed-By: glebius 
Responsible-Changed-When: Sat Oct 21 09:32:03 UTC 2006 
Responsible-Changed-Why:  
Since Pawel has changed df(1) to use humanize_number(3) let him ponder 
on this problem. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=102694 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/102694: commit references a PR
Date: Sat,  8 Mar 2008 21:56:07 +0000 (UTC)

 antoine     2008-03-08 21:55:59 UTC
 
   FreeBSD src repository
 
   Modified files:
     lib/libutil          humanize_number.c 
   Log:
   Merge changes from NetBSD on humanize_number.c, 1.8 -> 1.13
   Significant changes:
   - rev. 1.11: Use PRId64 instead of a cast to long long and %lld to print
   an int64_t.
   - rev. 1.12: Fix a bug that humanize_number() produces "1000" where it
   should be "1.0G" or "1.0M".  The bug reported by Greg Troxel.
   
   PR:             118461
   PR:             102694
   Approved by:    rwatson (mentor)
   Obtained from:  NetBSD
   MFC after:      1 month
   
   Revision  Changes    Path
   1.3       +10 -5     src/lib/libutil/humanize_number.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->patched 
State-Changed-By: linimon 
State-Changed-When: Sat Mar 29 01:51:18 UTC 2008 
State-Changed-Why:  
Set as MFC reminder and assign to committer. 


Responsible-Changed-From-To: pjd->antoine 
Responsible-Changed-By: linimon 
Responsible-Changed-When: Sat Mar 29 01:51:18 UTC 2008 
Responsible-Changed-Why:  

http://www.freebsd.org/cgi/query-pr.cgi?pr=102694 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/102694: commit references a PR
Date: Sun, 20 Apr 2008 16:29:05 +0000 (UTC)

 antoine     2008-04-20 16:29:01 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_7)
     lib/libutil          humanize_number.c 
   Log:
   MFC to RELENG_7:
     Merge changes from NetBSD on humanize_number.c, 1.8 -> 1.13
     Significant changes:
     - rev. 1.11: Use PRId64 instead of a cast to long long and %lld to print
     an int64_t.
     - rev. 1.12: Fix a bug that humanize_number() produces "1000" where it
     should be "1.0G" or "1.0M".  The bug reported by Greg Troxel.
   
     PR:             118461
     PR:             102694
     Approved by:    rwatson (mentor)
     Obtained from:  NetBSD
     MFC after:      1 month
   
   Revision  Changes    Path
   1.2.10.1  +10 -5     src/lib/libutil/humanize_number.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: bin/102694: commit references a PR
Date: Sun, 20 Apr 2008 16:32:25 +0000 (UTC)

 antoine     2008-04-20 16:32:20 UTC
 
   FreeBSD src repository
 
   Modified files:        (Branch: RELENG_6)
     lib/libutil          humanize_number.c 
   Log:
   MFC to RELENG_6:
     Merge changes from NetBSD on humanize_number.c, 1.8 -> 1.13
     Significant changes:
     - rev. 1.11: Use PRId64 instead of a cast to long long and %lld to print
     an int64_t.
     - rev. 1.12: Fix a bug that humanize_number() produces "1000" where it
     should be "1.0G" or "1.0M".  The bug reported by Greg Troxel.
   
     PR:             118461
     PR:             102694
     Approved by:    rwatson (mentor)
     Obtained from:  NetBSD
     MFC after:      1 month
   
   Revision  Changes    Path
   1.2.2.1   +10 -5     src/lib/libutil/humanize_number.c
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: patched->closed 
State-Changed-By: antoine 
State-Changed-When: Sun Apr 20 16:46:48 UTC 2008 
State-Changed-Why:  
Fixed in HEAD, RELENG_7 and RELENG_6. 
Thanks for the report! 

http://www.freebsd.org/cgi/query-pr.cgi?pr=102694 
>Unformatted:
