Call function on sysctl value change

Oliver Fromme olli at
Wed Oct 15 14:17:33 UTC 2008

Matthew Jakeman wrote:
 > I was wondering if it is possible to call a function when a sysctl value is 
 > changed. I have added a few sysctl int variables to the kernel and for some 
 > of these i only want certain values to be acceptable as input depending on 
 > some conditions. I would like to be able to call a function if possible, to 
 > validate the value entered via the sysctl command.

Yes, you can do this with a "PROC" type sysctl.  For example,
look at sysctl_hlt_cpus() in sys/i386/i386/mp_machdep.c.

Best regards

Oliver Fromme, secnetix GmbH & Co. KG, Marktplatz 29, 85567 Grafing b. M.
Handelsregister: Registergericht Muenchen, HRA 74606,  Geschäftsfuehrung:
secnetix Verwaltungsgesellsch. mbH, Handelsregister: Registergericht Mün-
chen, HRB 125758,  Geschäftsführer: Maik Bachmann, Olaf Erb, Ralf Gebhart

FreeBSD-Dienstleistungen, -Produkte und mehr:

"Whatever happened to the days when hacking started
at the cerebral cortex, and not at the keyboard?"
  --  Sid on by Illiad, 2007-06-20

More information about the freebsd-hackers mailing list