From owner-freebsd-hackers@FreeBSD.ORG Fri Feb 2 05:41:58 2007 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 18E3616A400 for ; Fri, 2 Feb 2007 05:41:58 +0000 (UTC) (envelope-from dr2867@pacbell.net) Received: from smtp113.sbc.mail.mud.yahoo.com (smtp113.sbc.mail.mud.yahoo.com [68.142.198.212]) by mx1.freebsd.org (Postfix) with SMTP id CB74713C474 for ; Fri, 2 Feb 2007 05:41:57 +0000 (UTC) (envelope-from dr2867@pacbell.net) Received: (qmail 6506 invoked from network); 2 Feb 2007 05:41:55 -0000 DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=pacbell.net; h=Received:X-YMail-OSG:Message-ID:Date:From:User-Agent:MIME-Version:To:CC:Subject:References:In-Reply-To:Content-Type:Content-Transfer-Encoding; b=aG3KHUIcNp1ChwSgSVKdWzJk+1stZXwI34/JHhoLIHXNAMsYC5PizKOXqqParlUv8boz+8G7FqfEDlh3N8CjOXTLJjmZGjJG/u3t67va1lckxqP69a24f8c3sTMRghUgtJwO60kj+/EQWNkIkl4HchaJxEkciQgcIRymbFHgAno= ; Received: from unknown (HELO ?192.168.0.190?) (dr2867.business@pacbell.net@71.146.53.89 with plain) by smtp113.sbc.mail.mud.yahoo.com with SMTP; 2 Feb 2007 05:41:55 -0000 X-YMail-OSG: Dc8l9lcVM1mN_JUk3ImlJpNy5qu9X.B1rY.FFabbWw5ay8aMbdF7VhjkhBOeBZEQ_VRod4uNjFvzuCMmekLSLkosDJtzy1K.8c5BprLb_owN4.7i.bDq.H0hePe6jHVSEwBd.5aNPf7p82Y- Message-ID: <45C2D000.3070300@pacbell.net> Date: Thu, 01 Feb 2007 21:45:36 -0800 From: Daniel Rudy User-Agent: Mozilla/5.0 (X11R6; UNIX; FreeBSD/i386 6.1-RELEASE-p7; en-US; ja-JP; rv:1.8.0.7) Gecko/20060910 SeaMonkey/1.0.5 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Dag-Erling_Sm=F8rgrav?= References: <45BB72D6.9070809@pacbell.net> <86k5z3jylp.fsf@dwp.des.no> In-Reply-To: <86k5z3jylp.fsf@dwp.des.no> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Cc: freebsd-hackers@freebsd.org Subject: Re: sysctl(3) interface X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 02 Feb 2007 05:41:58 -0000 At about the time of 1/31/2007 2:10 AM, Dag-Erling Smørgrav stated the following: > Daniel Rudy 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