Subject: Re: how to add variables to be controled by 'sysctl' ?
To: suxm <suxm@gnuchina.org>
From: Manuel Bouyer <bouyer@antioche.lip6.fr>
List: tech-kern
Date: 06/24/2001 16:57:59
On Sat, Jun 23, 2001 at 12:54:57PM +0800, suxm wrote:
> I have done something in NetBSD kernel, and I want to turn on or off
> the functions by sysctl. That is to say, use the following command to turn on
> my functions:
> # sysctl -w my_function=1
Maybe it should be down in the hierarchy, under one of the top-level
name ?
>
> Would someone like to tell me how to implement it ?
First you have to add your entry in sys/sys/sysctl.h
How it's handled in the kernel depends on the top-level name you choose.
dispacth in function of the top-level name is done in
sys/kern/kern_sysctl.c:sys___sysctl()
For example if you choose to put your new entry under kern
(sysctl -w kern.my_function=1), then you'll have to add a case for
KERN_MY_FUNCTION in kern_sysctl()
If you did the rigth change in sysctl.h, you just need to recompile
sbin/sysctl for the userland part.
--
Manuel Bouyer <bouyer@antioche.eu.org>
--