Dumping Large Binary Buffer Through Sysctl

Dan Nelson dnelson at allantgroup.com
Sat Nov 8 15:11:47 PST 2008


In the last episode (Nov 08), David Christensen said:
> I'm looking for a way to dump a large binary debug buffer 
> in a driver to a file.  I've currently implemented this
> with SYSCTL_ADD_OPAQUE() and it works fine but running the
> "sysctl -a" command causes this buffer to be dumped which
> is something of a pain.  Is there a better way to do this?

Opaque values aren't really automatically skipped by /sbin/sysctl; the
format string is checked, and if the format isn't handled by
show_var(), it's not printed.  Formats don't seem to be documented
anywhere, though.  Try a blank format string.  This will print all
"opaque" (not necessarily CTLTYPE_OPAQUE) variables, and their reported
format strings:

sysctl -ao | sed -ne 's/Length.*//p'

Here are some weird ones that are probably typos:

vfs.nfs.diskless_rootaddr: Format:%Ssockaddr_in
kern.malloc_stats: Format:s,malloc_type_ustats
vm.zone_stats: Format:s,struct uma_type_header

-- 
	Dan Nelson
	dnelson at allantgroup.com


More information about the freebsd-current mailing list