Checking sysctl values from within the kernel.
Scott Long
scottl at samsco.org
Fri Aug 5 15:33:17 GMT 2005
Dan Nelson wrote:
> In the last episode (Aug 05), Thordur I. Bjornsson said:
>
>>If I want to check a sysctl value from within the kernel (e.g. an
>>KLD), should I use the system calls described in sysctl(3) ?
>>
>>If not, what is the propper way to do so ?
>
>
> Since most sysctls are direct mappings onto integer variables in the
> kernel, just check the variable directly.
>
Most of those integer values are also declared static, so they won't
be visible to external code, especially not kld's.
There is no easy way to do this. I'm sure that you could hack up some
code to simulate a sysctl syscall from within the kernel, but that would
be really really gross, evil, and wrong. What values are you trying to
get at? Would it make more sense to export them via real accessor
functions?
Scott
More information about the freebsd-hackers
mailing list