Subject: Re: dynamic sysctl
To: Pavel Cahyna <>
From: David Laight <>
List: tech-kern
Date: 11/15/2003 21:33:38
On Fri, Nov 14, 2003 at 06:17:29PM +0100, Pavel Cahyna wrote:
> > 
> > sysctlnametomib() will use sysctl() to ask the kernel for the
> > name<->number mapping at a given level (eg kern.* or net.inet.*).  i
> What does this sysctl() call look like? There is no option of sysctl to
> tell the name<->number mapping currently. Will there also be a way to
> enumerate all subnodes of a given node?

Why not just make:
	sysctl((void *)"kern.maxproc", 0, &buf, sizeof buf, NULL, 0);
return the value of kern.maxproc (etc).
Return EISDIR if there are extra levels, and make "kern.*" return
the list of names at the next level.

All you need then is some heuristic in sysctl(1) to work out how to
format unknown items.


David Laight: