Date: Fri, 5 Aug 2005 13:08:31 -0400 From: John Baldwin <jhb@FreeBSD.org> To: freebsd-hackers@freebsd.org Subject: Re: Checking sysctl values from within the kernel. Message-ID: <200508051308.32649.jhb@FreeBSD.org> In-Reply-To: <20050805164417.32edf853.thib@mi.is> References: <20050805005543.5bd947f2.thib@mi.is> <200508051101.33927.jhb@FreeBSD.org> <20050805164417.32edf853.thib@mi.is>
next in thread | previous in thread | raw e-mail | index | archive | help
On Friday 05 August 2005 12:44 pm, Thordur I. Bjornsson wrote: > On Fri, 5 Aug 2005 11:01:32 -0400 > > John Baldwin <jhb@FreeBSD.org> 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. > > > > -- > > John Baldwin <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/ > > "Power Users Use the Power to Serve" = http://www.FreeBSD.org > > Ahh. Cool > This is not in any manpage ... > > I'm trying to understand the first argument to kernel_systcl(), > kernel_sysctl(struct thread *td, ... ) > > This thread, that it takes as an argument is this something that I need > to worry about when writing KLD's or could I just pass a NULL pointer ? > > The proplem is that I do not know/understand how threading works in the > kernel. I'll be lookin into that (although pointers are more then > welcome ;) Pass curthread as the thread. -- John Baldwin <jhb@FreeBSD.org> <>< http://www.FreeBSD.org/~jhb/ "Power Users Use the Power to Serve" = http://www.FreeBSD.org
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200508051308.32649.jhb>