Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 21 Jan 2011 16:14:40 +1100 (EST)
From:      Bruce Evans <brde@optusnet.com.au>
To:        Garrett Cooper <gcooper@freebsd.org>
Cc:        freebsd-arch@freebsd.org
Subject:   Re: Weed-whacking sysctl(8)
Message-ID:  <20110121153528.P2616@besplex.bde.org>
In-Reply-To: <AANLkTi=sJznis%2BE4wWiCE7FYhNmCA_JL6-0MtGW9wGbX@mail.gmail.com>
References:  <mit.lcs.mail.freebsd-arch/AANLkTimMsy9J5Ohj0pifZ%2B9L4_mFq5z2FwUhG8y5%2B3Kh@mail.gmail.com> <mit.lcs.mail.freebsd-arch/201101191559.07713.jhb@freebsd.org> <mit.lcs.mail.freebsd-arch/20110120190703.H11630@besplex.bde.org> <201101201830.p0KIUFx9067555@hergotha.csail.mit.edu> <AANLkTinaEz7oB=bfYEKwHjvNSMmdq4H3g=Puy3focJ9o@mail.gmail.com> <4D38A476.10709@bsdimp.com> <AANLkTi=sJznis%2BE4wWiCE7FYhNmCA_JL6-0MtGW9wGbX@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.

--0-1396774578-1295586880=:2616
Content-Type: TEXT/PLAIN; charset=X-UNKNOWN; format=flowed
Content-Transfer-Encoding: QUOTED-PRINTABLE

On Thu, 20 Jan 2011, Garrett Cooper wrote:

> On Thu, Jan 20, 2011 at 1:09 PM, Warner Losh <imp@bsdimp.com> wrote:
>> On 01/20/2011 11:43, Garrett Cooper wrote:
>>> <off-topic>
>>> Tunables support mixed-case units incorrectly as well, i.e.
>>> 1. 'g' / 'G' -> =A0'giga'
>>> 2. 'm' / 'M' -> =A0'mega'
>>> 3. 'k' / 'K' -> =A0'kilo'
>>> Something that Bruce brought up in another email thread with me.
>>> </off-topic>
>>
>> No. =A0'k' is the proper SI prefix for kilo. =A0And all the SI prefixes =
are
>> powers of ten only, but that's another can of worms.
>>
>> http://physics.nist.gov/cuu/Units/prefixes.html
>
> 1. 'g' doesn't map to anything.
> 2. 'm' is incorrect ('milli' vs 'mega').
> 3. 'K' doesn't map to anything.
>
> That's what I meant.

Same can.  There is a significant shortage of letters, and significant
confusion between prefixes for powers of 10 and powers of 2, and
significant need for both, but scientificize^Wde^Whumanize_number()
is of such quality that it wastes a letter for an alias for every
supported "prefix".  (I'm looking at the possibly-old man page on
ref9-amd64, where "suffix" is still spelled "prefix" and the aliases
are of course undocumented.  Garrett started fixing this.)

'K' is the most broken in the man page.  SI 'k' comflicts with
computerspeak 'K' least among the prefixes (I think all others are
capitals in both SI and computerspeak), but the man page says that the
"prefix" for 1024 and 1000 is 'k' and doesn't mention its undocumented
alias 'K'.  OTOH, humanize_number() actually agrees with both SI and
computerspeak according to df output, since the suffix is 'k' for
powers of 10 format (df -H) and 'K' for powers of 2 format (df -h).

Bugs noticed while testing this:
- inode counts are printed in power of 10 even with df -h.  This is actuall=
y
   documented.  You can see the difference if their suffix is k, but not if
   it is M or larger.
- verbose names (mostly for nfs mounts) cause the output to not fit in 80
   columns even with -h and without -i.  Lots of columns are usually wasted
   in -h format.  This despite df having lots of dynamic formatting.

So k vs K more or less works as well as possible for scientificize_number()=
,
but is not documented to do so.  parse^Wexpand_number() is considerably
more primitive and broken.  It only supports power of 2 format, and
only documents k, but accepts K as an alias for k.  So it converts
1000 printed as 1k by scientificize_number() to 1024.

Bruce
--0-1396774578-1295586880=:2616--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20110121153528.P2616>