Subject: Re: sysinfo(2)
To: Simon Burge <simonb@netbsd.org>
From: Todd Whitesel <toddpw@best.com>
List: tech-net
Date: 04/16/2000 01:48:57
> "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."
Hee Hee!
Back in the late 80's when I got my Apple IIgs and started hacking that,
I remember being impressed at how _every_ syscall did that. (Back then,
I was used to the Apple-style "fat parameter block" paradigm, so it didn't
occur to me that most syscalls really didn't need such complexity.)
In brief, the main list of parameters (and return values!) was defined to
be a struct, and you passed the O/S a pointer+paramcount. Input values not
included in the count were defaulted to something reasonable, and output
values not included in the count were ignored.
Things like strings and data buffers were passed as pointers to a "resultbuf"
which looked like this:
struct {
int totalsize;
int actualsize;
char data[];
};
The idea was that you filled in the totalsize field before calling the O/S,
and the O/S filled in the actualsize field to let you know how much it used.
There was some protocol for buffer overflows where the actualsize would be
set to the true length of the data and nothing else was returned, but I
forget the details.
I've still got the addison-wesley printed documentation at home somewhere.
Todd Whitesel
toddpw @ best.com