Subject: Re: dynamic sysctl
To: David Laight <david@l8s.co.uk>
From: Andrew Brown <atatat@atatdot.net>
List: tech-kern
Date: 11/16/2003 20:41:44
>> > 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).

sounds nice, but how does that communicate the type of the returned
data to the caller?  or maybe buf could then consist of a type number,
followed by a length number, followed by the actual data...

we can do that later.

>Return EISDIR if there are extra levels, and make "kern.*" return
>the list of names at the next level.

exactly.  most of the groundwork for doing something like this is in
what i've got.

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

you mean like the structs?  i still say that sysctl(8) shouldn't need
to know how to display arbitrary structs.

-- 
|-----< "CODE WARRIOR" >-----|
codewarrior@daemon.org             * "ah!  i see you have the internet
twofsonet@graffiti.com (Andrew Brown)                that goes *ping*!"
werdna@squooshy.com       * "information is power -- share the wealth."