On Fri, 26 Mar 2010 13:45:44 -0700 Philip Guenther <[email protected]>
wrote:

> > As for dmesg picking the right kernel file for getting the names of
> > the currently running kernel, there is either some magic in demsg
> > which picks the right kernel from disk, or a properly running
> > kernel does not need to read names from the kernel file since
> > they're already in memory.
> 
> It's simpler than that: when run without the -N or -M options, dmesg
> gets the info via sysctl() instead of trying to read from /dev/kmem.
> This makes it ABI-proof against various kernel or libkvm changes that
> break code that reads /dev/kmem.
> 
> That's true not just of dmesg but of all the other programs that need
> kernel info: ps, netstat, fstat, ipcs, systat, etc.
> 
> $ sysctl -A kern 2>&1 >/dev/null | grep 'use ' | head
> sysctl: use pstat to view kern.vnode information
> sysctl: use ps to view kern.proc information
> sysctl: use pstat to view kern.file information
> sysctl: use pstat -t to view kern.tty.ttyinfo information
> sysctl: use dmesg to view kern.msgbuf
> sysctl: use netstat to view kern.mbstat
> sysctl: use ps to view kern.proc2 information
> sysctl: use fstat to view kern.file2 information
> sysctl: use vmstat or systat to view vm.vmmeter information
> sysctl: use vmstat or systat to view vm.uvmexp information
> $
> 
> Make sense?

Yep. Thank you.

I knew at least some of the data was available through sysctl, but I
didn't know how, or more importantly, why. The ABI-proffing makes sense.

jcr

Reply via email to