Subject: Re: sysinfo(2)
To: Aidan Cully <aidan@kublai.com>
From: Simon Burge <simonb@netbsd.org>
List: tech-kern
Date: 04/08/2000 11:52:38
Aidan Cully wrote:

> I was thinking about it as a general replacement for anything that used
> libkvm against a live kernel.  Most of the motivation was in those
> periodic 'proc size mismatch'es that /bin/ps gives when upgrading the
> kernel, but done a bit differently sysctl() could avoid those as well.

I was thinking about something similar to this just this week, having
been exposed to HP/UX for the first time and having to get some info
about a process from a user land program.  The pstat*() calls that take
the (buffer, elem_len, num_elem [, index]) arguments seem to be a good
way of fixing the 'proc size mismatch' problems we have.  From the man
page:

	"As the system changes, some fields may be added.  However,
	since any new fields will be appended to the structures, and the
	call to pstat() passes the expected structure size in elemsize,
	a program can continue to work without recompilation.  If the
	user program is recompiled, the additional pstat() fields will
	be available."

It may be sane to make this a read-only interface, since it's made to
cope with backwards compatible structure sizes.  Using sysinfo() as a
name, the prototype could be something like:

	int sysinfo(int *name, u_int namelen, void *indata, size_t elemsize,
	    size_t elemcount, int index);

where index has the HP/UX meaning of "give me `elemcount' items starting
at item number `index'".

Thoughts?

Simon.