Checking sysctl values from within the kernel.
Jeremie Le Hen
jeremie at le-hen.org
Sat Aug 6 07:04:09 GMT 2005
Hi Thordur,
> PS: If you don't mind, what is a "real accessor function" ?
This is a function acting as a wrapper for accessing an integer
declared as static. This function must of course live in the same
file. This may be something like this, there may exist neater
interfaces though :
static int age;
int
age_accessor(int *get, int set)
{
if (get != NULL)
*get = age;
else if (set < 0 || set > 125)
return -1;
else
age = set;
return 0;
}
If `get' is not NULL, this means the caller wants to retrieve the
current age value. Else, this means the caller wants to set the age
value to a new one : if the latter is lower than 0 and greater than
125, this is an incredible age and the accessor reports an error.
Else it sets the new value.
I hope this helped.
Regards,
--
Jeremie Le Hen
< jeremie at le-hen dot org >< ttz at chchile dot org >
More information about the freebsd-hackers
mailing list