sysctl output formatting
John Baldwin
jhb at freebsd.org
Thu Apr 9 15:51:52 UTC 2015
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
More information about the freebsd-arch
mailing list