Subject: Re: du(1) with gigabyte option.
To: Mattias Karlsson <keihan@sergei.cc>
From: James K. Lowden <jklowden@schemamania.org>
List: tech-userlevel
Date: 02/21/2003 00:09:49
On Tue, 18 Feb 2003 18:55:19 +0100, Mattias Karlsson <keihan@sergei.cc>
wrote:
> > "BLOCKSIZE=xxx du ..."  is much more portable -- easier by the points
> > above, too -- than du -g.
> 
> Yes, just thought it would be a neat feature.

It would be nice if du and friends would report decimal values instead of
power-of-two approximations.  "kilobyte" has a fixed meaning: 1000 bytes. 


http://physics.nist.gov/cuu/Units/prefixes.html
http://www-cs-staff.stanford.edu/~knuth/news99.html (see "What is a
kilobyte?")

Maybe 1024 is a reasonable approximation of 1000; it's only 2.4% off.  But
2^30 is very different from 10^9 (7.4% more).  That discrepancy is room
enough to install NetBSD on any disk manufactured in the last few years.  

ls(1) shows bytes, although I can't reconcile -s with -l:

$ ls -ls /netbsd
9232 -rwxr-xr-x  1 root  wheel  4749749 Nov 19  2000 /netbsd
$ expr 512 \* 9232 - 4749749
-22965

Apparently the kernel uses more bytes than it needs blocks for? 

Second, since -m and -g are nonportable anyway, why not let -k take an
argument?  That way, -km, -kg, -kt, etc. work (with -k retaining its
current meaning).  

--jkl