Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 09 Apr 2015 11:51:17 -0400
From:      John Baldwin <jhb@freebsd.org>
To:        freebsd-arch@freebsd.org
Cc:        Chris Torek <torek@torek.net>
Subject:   Re: sysctl output formatting
Message-ID:  <4560967.0vtmTZXoz1@ralph.baldwin.cx>
In-Reply-To: <201504062229.t36MTMlJ024359@elf.torek.net>
References:  <201504062229.t36MTMlJ024359@elf.torek.net>

next in thread | previous in thread | raw e-mail | index | archive | help
On Monday, April 06, 2015 03:29:22 PM Chris Torek wrote:
> We had a side discussion at $work about a private sysctl emulation
> (so our side thing doesn't actually affect sysctl itself at all)
> where it was suggested that some simple numeric sysctls are "best
> displayed in hex".

We had this feature for hex and it was removed.  8.x still has SYSCTL_XINT()
and friends.

It was removed in
https://svnweb.freebsd.org/base?view=revision&revision=217586

The argument in that comment is that you should use sysctl -x.  However, I
think that doesn't really wash.  That is fine if you are looking at a single
node, but I think SYSCTL_XINT() was useful to set the default format that was
used for sysctl -a, etc.  You could then have flags to sysctl to override it
for individual nodes for use in scripts, etc.

> Consider, e.g.:
> 
>     $ sysctl kern.timecounter.tc.i8254
>     kern.timecounter.tc.i8254.mask: 65535
>     kern.timecounter.tc.i8254.counter: 25822
>     kern.timecounter.tc.i8254.frequency: 1193182
>     kern.timecounter.tc.i8254.quality: 0
> 
> The "mask" here actually makes more sense displayed in hex.  One
> can of course use:
> 
>     $ sysctl -x kern.timecounter.tc.i8254
>     kern.timecounter.tc.i8254.mask: 0x0000ffff
>     kern.timecounter.tc.i8254.counter: 0x0000786c
>     kern.timecounter.tc.i8254.frequency: 0x00000000001234de
>     kern.timecounter.tc.i8254.quality: 0000000000
> 
> but now the mask is shown in hex (yay) but the others are shown
> in hex too (boo).

Exactly.

I would support bringing the XINT variants back.  Note that you would not want
to revert the above commit, but you would want to make the XINT variants use a
format of "X" and then fix sysctl(8) to handle "X" formats again.

-- 
John Baldwin



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