Re: sysctl filesystem ?

看板FB_current作者時間13年前 (2012/06/26 09:32), 編輯推噓0(000)
留言0則, 0人參與, 最新討論串5/14 (看更多)
On Mon, Jun 25, 2012 at 8:13 PM, Garrett Cooper <yanegomi@gmail.com> wrote: > On Mon, Jun 25, 2012 at 5:03 PM, Arnaud Lacombe <lacombar@gmail.com> 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/ _______________________________________________ freebsd-current@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-current To unsubscribe, send any mail to "freebsd-current-unsubscribe@freebsd.org"
文章代碼(AID): #1FwH4JF1 (FB_current)
討論串 (同標題文章)
文章代碼(AID): #1FwH4JF1 (FB_current)