Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 01 Feb 2007 21:45:36 -0800
From:      Daniel Rudy <dr2867@pacbell.net>
To:        =?ISO-8859-1?Q?Dag-Erling_Sm=F8rgrav?= <des@des.no>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: sysctl(3) interface
Message-ID:  <45C2D000.3070300@pacbell.net>
In-Reply-To: <86k5z3jylp.fsf@dwp.des.no>
References:  <45BB72D6.9070809@pacbell.net> <86k5z3jylp.fsf@dwp.des.no>

next in thread | previous in thread | raw e-mail | index | archive | help
At about the time of 1/31/2007 2:10 AM, Dag-Erling Smørgrav stated the
following:
> Daniel Rudy <dr2867@pacbell.net> writes:
>> I've been taking apart and analyzing the sysctl(8) program to gain a
>> better insight into how to use the sysctl(3) interface.  [...]
>> It's using an oid of 0 and 2 to get something, then it comes up with 440
>> and then a sequence of numbers that are incrementing in a peculiar
>> pattern.
> 
> sysctl(8) uses undocumented interfaces to a) enumerate the nodes in
> the sysctl tree and b) obtain the name of a node, given its OID.
> 
>> So, my question is, how do I walk the tree to get the PnP info for all
>> the devices in the system?
> 
> man 3 devinfo
> 
> DES

A little too late since I already hacked the source for sysctl(8) and
figured out how it works.

Here's what I have:

mib[0] = 0;  Unused according to sys/sysctl.h.

So,

0,1 - get name from oid.
0,2 - get first sysctl node/leaf?  (I haven't used this one yet)
0,3 - get oid from name.
0,4 - get format for oid? (I haven't used this one yet either)


At least that's that I have.  I wrote a program based on that and it
does work, quite well in fact.  I am not concerned about portability
since the software that I'm writing will run ONLY on FreeBSD and maybe
some of the variants.

-- 
Daniel Rudy



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?45C2D000.3070300>