From owner-freebsd-hackers@FreeBSD.ORG Tue Jun 26 01:24:28 2012 Return-Path: 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 E8631106564A; Tue, 26 Jun 2012 01:24:28 +0000 (UTC) (envelope-from lacombar@gmail.com) Received: from mail-wg0-f50.google.com (mail-wg0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id E4A6A8FC1A; Tue, 26 Jun 2012 01:24:27 +0000 (UTC) Received: by wgbds11 with SMTP id ds11so4481954wgb.31 for ; Mon, 25 Jun 2012 18:24:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; bh=RjX88LddFI9Y7cutb20kzrPYlzQ+zN19w6SaQdgeSao=; b=W0eIewdw4kIpZ2SQRLjvaRykIXPseKuw5GmZr7+KcDIwgOFyeCrnnbfRMql95B0TE5 M2A7XWRqU80uxVQwCCSpN3N4+IwqLpDwTFMn7A7bdjAOCyokqa7ml2za9LevNMSd7PSI NsmJqmYxSgJ6POsCGHyN0RH9Sjktqv6pAeT5YPGlJGWtFgRTPYeHnfFiBoOT3sF+4TVg yFffme1yTFFUR4gbHMEcTudibgoVFYIdf7Tr4zGJQwdsljs64JkzMddDm5yv/J4uDyl4 4cvIl11/yClvcXDa4926QMHPq1Q/eaE/i7UWxvNbM3AvfsLJBwy8+kBzbCb0KPk8hakX hdeA== MIME-Version: 1.0 Received: by 10.216.196.166 with SMTP id r38mr6612952wen.161.1340673866890; Mon, 25 Jun 2012 18:24:26 -0700 (PDT) Received: by 10.216.214.101 with HTTP; Mon, 25 Jun 2012 18:24:26 -0700 (PDT) In-Reply-To: References: Date: Mon, 25 Jun 2012 21:24:26 -0400 Message-ID: From: Arnaud Lacombe To: Garrett Cooper Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: FreeBSD Hackers , FreeBSD Current , kby@freebsd.org, bp@freebsd.org Subject: Re: sysctl filesystem ? 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: Tue, 26 Jun 2012 01:24:29 -0000 On Mon, Jun 25, 2012 at 8:13 PM, Garrett Cooper wrote: > On Mon, Jun 25, 2012 at 5:03 PM, Arnaud Lacombe wrot= e: >> Hi folks, >> >> I find myself in a situation where I need to directly explore the >> sysctl(8) tree from my program. The tricky part is this: >> >> from `src/sbin/sysctl.c': >> /* >> =A0* These functions uses a presently undocumented interface to the kern= el >> =A0* to walk the tree and get the type so it can print the value. >> =A0* This interface is under work and consideration, and should probably >> =A0* be killed with a big axe by the first person who can find the time. >> =A0* (be aware though, that the proper interface isn't as obvious as it >> =A0* may seem, there are various conflicting requirements. >> =A0*/ >> >> AFAIT, the whole interface used by sysctl(8) to explore the sysctl >> tree (ie. list, name, get description) is undocumented. This comment >> has been there for about, well... 17 years. No matter to say that it >> is highly unlikely anyone is ever gonna design that perfect interface. >> Right now, I am left with no choice but to figure out how that stuff >> work, which I foresee will be a real PITA. No choice ? Well, not so >> much. About 12 years ago a filesystem interface was written for >> sysctl, namely scfs(4). It was authored by Kelly Yancey and (?) Boris >> Popov. Unfortunately, time passed and no code is any longer publicly >> available. URLs are either no longer valid or password-protected. >> >> This interface would just be perfect for my use-case. No need to spend >> time decoding a prehistoric interface, no need to craft custom >> accessors. I would just have to use standard POSIX file interface... >> if the code was available. >> >> I was hoping some of the people on this list would either, have the >> scfs(4) code on their drives/tapes, or have a way to contact the >> original author(s) and thus have a chance to get that code ? >> >> Thanks in advance, >> =A0- Arnaud >> >> ps: I know the code will certainly have to be fixed, but that is still >> the best option I've got so far. > > Alternatively, the interface could just be documented (from > sys/kern/kern_sysctl.c): > > /* > =A0* "Staff-functions" > =A0* > =A0* These functions implement a presently undocumented interface > =A0* used by the sysctl program to walk the tree, and get the type > =A0* so it can print the value. > =A0* This interface is under work and consideration, and should probably > =A0* be killed with a big axe by the first person who can find the time. > =A0* (be aware though, that the proper interface isn't as obvious as it > =A0* may seem, there are various conflicting requirements. > =A0* > =A0* {0,0} =A0 =A0 =A0 =A0printf the entire MIB-tree. > =A0* {0,1,...} =A0 =A0return the name of the "..." OID. > =A0* {0,2,...} =A0 =A0return the next OID. > =A0* {0,3} =A0 =A0 =A0 =A0return the OID of the name in "new" > =A0* {0,4,...} =A0 =A0return the kind & format info for the "..." OID. > =A0* {0,5,...} =A0 =A0return the description the "..." OID. > =A0*/ > > I know 2 closed-source versions that have wholesale stolen/"borrowed" > the code from sysctl(3), and I adapted the sysctl(8) code for my own > uses for the cython derivative I made here [1]. > I guess I will have no choice but to write a third... - Arnaud > Thanks, > -Garrett > > 1. http://sourceforge.net/projects/sysctl/