From owner-freebsd-hackers@FreeBSD.ORG Sat Jan 27 16:05:12 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 CD4CB16A403 for ; Sat, 27 Jan 2007 16:05:12 +0000 (UTC) (envelope-from dr2867@pacbell.net) Received: from smtp103.sbc.mail.mud.yahoo.com (smtp103.sbc.mail.mud.yahoo.com [68.142.198.202]) by mx1.freebsd.org (Postfix) with SMTP id 875CC13C484 for ; Sat, 27 Jan 2007 16:05:10 +0000 (UTC) (envelope-from dr2867@pacbell.net) Received: (qmail 95341 invoked from network); 27 Jan 2007 15:38:30 -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:Subject:Content-Type:Content-Transfer-Encoding; b=OeUOkaLa8xPuFGgE4f7QjY1EqO1wtE2cw9xpA/3hf+3PeJ+GmafIfN3bPoIaVcvAz2b8kw0a+NFjMzhQlD4NLHcHADZBw+X3sbC+nnlrNLrfbPAZ18jZzrnScZOM7qwoTmhAXhdBmna3UT0u/nYz8cu361awSXlRFplxJYrMKDQ= ; Received: from unknown (HELO ?192.168.0.190?) (dr2867.business@pacbell.net@71.146.53.89 with plain) by smtp103.sbc.mail.mud.yahoo.com with SMTP; 27 Jan 2007 15:38:29 -0000 X-YMail-OSG: Ic9vHxkVM1l.pyh.wHl.RDQ.7h4xPU31o5EUnYbB.aIowRvuNDBP1cZX0imMgp.sM8sshGB9Lg-- Message-ID: <45BB72D6.9070809@pacbell.net> Date: Sat, 27 Jan 2007 07:42:14 -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: freebsd-hackers@freebsd.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: 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: Sat, 27 Jan 2007 16:05:12 -0000 Hello List, I've been taking apart and analyzing the sysctl(8) program to gain a better insight into how to use the sysctl(3) interface. Adding some debugging code to the program in strategic locations, this is what I have as an output: debug: name: dev debug: all: oid: 0 2 440 debug: name: dev.nexus.%parent debug: oid: 440 912 913 debug: all: oid: 0 2 440 912 913 debug: name: dev.nexus.0.%desc debug: oid: 440 912 914 915 debug: all: oid: 0 2 440 912 914 915 debug: name: dev.nexus.0.%driver debug: oid: 440 912 914 916 debug: value: nexusdev.nexus.0.%driver: nexus debug: all: oid: 0 2 440 912 914 916 debug: name: dev.nexus.0.%location debug: oid: 440 912 914 917 debug: all: oid: 0 2 440 912 914 917 debug: name: dev.nexus.0.%pnpinfo debug: oid: 440 912 914 918 debug: all: oid: 0 2 440 912 914 918 debug: name: dev.nexus.0.%parent debug: oid: 440 912 914 919 debug: value: root0dev.nexus.0.%parent: root0 debug: all: oid: 0 2 440 912 914 919 debug: name: dev.acpi.%parent debug: oid: 440 920 921 debug: all: oid: 0 2 440 920 921 debug: name: dev.acpi.0.%desc debug: oid: 440 920 922 923 debug: value: AMIINT dev.acpi.0.%desc: AMIINT debug: all: oid: 0 2 440 920 922 923 debug: name: dev.acpi.0.%driver debug: oid: 440 920 922 924 debug: value: acpidev.acpi.0.%driver: acpi debug: all: oid: 0 2 440 920 922 924 debug: name: dev.acpi.0.%location debug: oid: 440 920 922 925 debug: all: oid: 0 2 440 920 922 925 debug: name: dev.acpi.0.%pnpinfo debug: oid: 440 920 922 926 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. I went looking and found that 0 is CTL_UNSPEC which according to the comment is unused, but I see it here in the program output. I also noticed this little blurb in the source code too: /* * These functions uses a presently undocumented interface to the kernel * to walk the tree and get the type so it can print the value. * This interface is under work and consideration, and should probably * be killed with a big axe by the first person who can find the time. * (be aware though, that the proper interface isn't as obvious as it * may seem, there are various conflicting requirements. */ But I figure it's for the actual display of the various variables and not for returning information about the dev tree. So, my question is, how do I walk the tree to get the PnP info for all the devices in the system? -- Daniel Rudy