Subject: Re: dynamic sysctl
To: <>
From: David Laight <>
List: tech-kern
Date: 11/18/2003 14:44:58
> I did not mean to imply that programs should continue to use:
> 	int name[2], namelen = 2;
> 	name[0] = CTL_KERN;
> 	name[1] = KERN_SECURELVL;
> 	sysctl(&name[0], namelen, ...
> though that's still supported.  it's better, imho, to do this:
> 	int name[2], namelen = 2;
> 	sysctlnametomib("kern.securelevel", &name[0], &namelen,
> 	sysctl(&name[0], namelen, ...
> (though i've grown particularly fond of merely using 1.9 on the
> command line to represent kern.securelevel -- it's a lot lesss
> typing :).

(Yes - there is no reason why the current sysctl program couldn't
just accept random numeric tags...)

> that uses the kernel's name<->number mapping and not the header file
> and the program continues to "know" what it's asking for.

I suspect we are arguing over finer points of agreement!
My thought was the the application doesn't ever(?) need to know that the
numbers exists at all, so you might just as well pass the string into the
kernel and have it find the data item while parsing the string.

> >Maybe, in time, the numbers could be depracated....
> sure, though the sysctl() interface would have to be abandoned at that
> point in favor of something else.

Well you are adding a system call to convert names to numbers, why not
add 'sysctl by name' instead?


David Laight: