[Toybox] [PATCH] fix human_readable output for du
Rob Landley
rob at landley.net
Sat Aug 8 19:09:52 PDT 2015
On 08/08/2015 12:40 PM, enh wrote:
> ping.
>
> On Sat, Jan 17, 2015 at 6:18 PM, enh <enh at google.com> wrote:
>> this was the du patch. the documentation of the BSD function is
>> https://www.freebsd.org/cgi/man.cgi?query=humanize_number&sektion=3&n=1
>> and even just between dd and du a fair number of those flags are used.
Ouch.
>> i didn't know whether you'd prefer i fix all the -h'es (and add the
>> missing ones) or just worry about them one at a time. i guess i should
>> have just gone ahead and looked at df and ls in the meantime :-)
In the long run it looks like the right thing to do is implement the
darn bsd-compatible human_readable() function in lib/portability.c (or
at least the compatible subset of which we actually use), with a compile
time probe to use the libc one if it's there, on the theory that we may
eventually build under bsd, and bionic might want to implement this
itself someday.
Basically this is horrible but the _problem_ is probably what's
horrible, not the solution. If we can someday push this into posix we
can stop implementing our own. Given that the BSD version _exists_ and
it isn't immediately obvious how to improve on it, not being compatible
with it seems silly.
That said, I'm applying this patch now because you have test cases and
users who tell you when it's wrong, and I don't, so I defer to your
expertise here.
(For a definition of "apply" that involves a lot of failed hunk fixups.
I really need to just spend a month on the test suite at some point.)
Um, the new du -h and the ubuntu du -h produce very different output:
$ diff -u <(du -h toys) <(./du -h toys)--- /dev/fd/63 2015-08-08
21:07:06.034754585 -0500
+++ /dev/fd/62 2015-08-08 21:07:06.034754585 -0500
@@ -1,7 +1,7 @@
16K toys/example
36K toys/android
-988K toys/pending
-420K toys/posix
-420K toys/other
-84K toys/lsb
+1.0M toys/pending
+430K toys/posix
+430K toys/other
+86K toys/lsb
2.0M toys
Looks like one of those power of 2 vs power of 10 things?
(All I checked for dd is that it compiled, because pending. I did half a
cleanup of that once but lost it in a mercurial version upgrade that
trashed my repo so I had to restore from a backup and copy stuff over by
hand...)
Rob
1439086192.0
More information about the Toybox
mailing list