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 Fix: Not sure if this is df(1) or libutil's humanize_number(3) to be honest. How-To-Repeat: Have a filesystem that has used 1000M. Look at it.
> 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 Since Pawel has changed df(1) to use humanize_number(3) let him ponder on this problem.
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 Set as MFC reminder and assign to committer.
Responsible Changed From-To: pjd->antoine
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"
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 Fixed in HEAD, RELENG_7 and RELENG_6. Thanks for the report!