Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Aug 2005 16:21:02 -0700 (PDT)
From:      Doug Ambrisko <ambrisko@ambrisko.com>
To:        John Baldwin <jhb@freebsd.org>
Cc:        freebsd-hackers@freebsd.org, Dan Nelson <dnelson@allantgroup.com>
Subject:   Re: Checking sysctl values from within the kernel.
Message-ID:  <200508112321.j7BNL2rf001303@ambrisko.com>
In-Reply-To: <200508051101.33927.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
John Baldwin writes:
| 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.

This could be a fragile interface though.  I used this scheme to do 
"soft-linking" between modules that could be kldloaded into the kernel
or static.  We called it several times every few seconds.  Over time
the system would wedge on a setjmp or something like that.  We changed
it to a function call since in a static kernel then the problem went away.

Doug A.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508112321.j7BNL2rf001303>