On Fri, Mar 23, 2001 at 08:11:03PM +0100, Adrian Chadd wrote:
> A while back I started running through the undocumented sysctls and
> documenting them. I didn't get through all of them, and the main reason
> I stopped was because there wasn't a nifty way to extract the sysctls
> short of writing a script to extract them from /usr/src.
>
> Someone did point out that you could stuff the sysctl's into an elf
> segment and only load it when needed, but I don't know much about elf.
> If someone would like to do this, I'm sure a small group of us
> (Asmodai? :-P) could walk the sysctl tree again and figure out what
> the undocumented sysctls are. :-)
Some time ago I wrote such a script and even sent it to someone; never
got any response, though.
It is pretty minimal but does the job. I believe that the only sysctls
it misses are those which use auxilliary defines to minimize the number
of parameters (like #define P1B_SYSCTL in posix4/posix4_mib.c).
FWIW, the script is attached.
Cheers,
&Anton.
--
May the tuna salad be with you.
#! /usr/bin/perl -w
use File::Find;
use Text::ParseWords;
sub check_file
{
return unless /\.c$/ && -r;
local $/;
open SRC, "< $_"
or print( "can't open $File::Find::dir: $!"), return;
my $src = <SRC>; # memory hog
close SRC;
my @found = ($src =~ /\nSYSCTL_(\w+\([^()]+\))/sg);
return unless @found;
print "$File::Find::dir/$_:\n";
for (@found) {
tr/\n\t / /s;
my ($type) = /^(\w+)\(/;
next if $type eq "DECL";
s/^.*\(//; s/\)//;
my @args = quotewords ',', 1, $_;
#print "|@args|\n";
$args[0] =~ s/^\s*_//;
$args[0] =~ s/\s+$//;
$args[0] =~ tr/_/./;
$args[2] =~ s/^\s+//;
$args[2] =~ s/\s+$//;
print "$type\t$args[0].$args[2]\t$args[-1]\n";
}
}
find( \&check_file, '/usr/src/sys');