Subject: Re: new sysctl(KERN_PROC, ...) interface (was: sysinfo(2))
To: None <erh@nimenees.com>
From: Eduardo Horvath <eeh@turbolinux.com>
List: tech-kern
Date: 04/16/2000 07:56:58
On Sat, 15 Apr 2000 erh@nimenees.com wrote:
> On Sat, Apr 15, 2000 at 03:27:17PM -0400, Aidan Cully wrote:
> > After thinking a bit more about the versioning, I think a hybrid
> > approach is best: When elements are removed from the structure, or
> > change sizes, or get re-sorted, bump the KERN_PROC2 constant and
> > provide a compatibility function[*]. But also provide the 'elemsize'
> > argument, for dealing with adding fields to the structure. Best of
> > both worlds, right? The 'flag/flaglen' thing, I don't care about.
> This idea sounds ok but I think emphasis should be placed on
> keeping the interface (==the structure returned) as static as possible
> (and keep the interface simpler)
> How about dropping the elemsize argument because it makes it to
> easy to add stuff to the structure. Instead, have the kernel code, if
> compiled with support for previous versions of KERN_PROC2, know how big
> the structure should be and use that instead. (keep track of each different
> struct and use the right one, with the obvious optimization for additions
> of elements)
> The idea here is that if it is a little more difficult to change
> the structure it is more likely to stay the same.
If I recall correctly, the original source for this discussion was my
mentioning that sysctl() and kernel grovelling does not work well for
binaries under 32-bit emulation.
The proposed interface(s) don't really address this issue.
sysctl() is broken because it passes internal kernel structures
directly out to userland. This means that any 32-bit emulation
sysctl() system call must have knowledge of all sysctl variables to make
appropriate translations.
And this still does not solve the kmem grovelling issue that results if
you want to extract the data from a dead kernel.
I can see using two different interfaces, one for a live kernel and
another for grovelling in a dead kernel, but we already have that.
What you need to do is provide a formal interface which provides data in a
specific format so the syscall wrappers can do required
translations. Providing raw kernel data structures along with a size does
not help. You could do the same thing with kernel grovelling by ignoring
the structure size mismatch and presuming that no existing fields have
changed size or location.
Eduardo Horvath