Checking sysctl values from within the kernel.

Scott Long scottl at samsco.org
Fri Aug 5 17:24:48 GMT 2005


John Baldwin wrote:
> On Friday 05 August 2005 10:50 am, 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.
> 
> 
> There's also a kernel_sysctl() function available in the kernel for in-kernel 
> access to sysctls.  You might have to lookup the OID for a given name 
> yourself though.  Actually, there's a kernel_sysctlbyname() as well.
> 

Shoot, forgot about that function.  However, exporting data throughout
the kernel via the sysctl interface sounds like poor design.

Scott


More information about the freebsd-hackers mailing list