From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 15 14:17:33 2008 Return-Path: Delivered-To: freebsd-hackers@FreeBSD.ORG Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A553F1065694 for ; Wed, 15 Oct 2008 14:17:33 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (unknown [IPv6:2a01:170:102f::2]) by mx1.freebsd.org (Postfix) with ESMTP id 24F898FC26 for ; Wed, 15 Oct 2008 14:17:32 +0000 (UTC) (envelope-from olli@lurza.secnetix.de) Received: from lurza.secnetix.de (localhost [127.0.0.1]) by lurza.secnetix.de (8.14.3/8.14.3) with ESMTP id m9FEHUS8037918; Wed, 15 Oct 2008 16:17:31 +0200 (CEST) (envelope-from oliver.fromme@secnetix.de) Received: (from olli@localhost) by lurza.secnetix.de (8.14.3/8.14.3/Submit) id m9FEHUEn037917; Wed, 15 Oct 2008 16:17:30 +0200 (CEST) (envelope-from olli) Date: Wed, 15 Oct 2008 16:17:30 +0200 (CEST) Message-Id: <200810151417.m9FEHUEn037917@lurza.secnetix.de> From: Oliver Fromme To: freebsd-hackers@FreeBSD.ORG, m.jakeman@lancaster.ac.uk In-Reply-To: <200810151343.28136.m.jakeman@lancaster.ac.uk> X-Newsgroups: list.freebsd-hackers User-Agent: tin/1.8.3-20070201 ("Scotasay") (UNIX) (FreeBSD/6.4-PRERELEASE-20080904 (i386)) MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-2.1.2 (lurza.secnetix.de [127.0.0.1]); Wed, 15 Oct 2008 16:17:31 +0200 (CEST) Cc: Subject: Re: Call function on sysctl value change X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: freebsd-hackers@FreeBSD.ORG, m.jakeman@lancaster.ac.uk List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 15 Oct 2008 14:17:33 -0000 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 -- 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: http://www.secnetix.de/bsd "Whatever happened to the days when hacking started at the cerebral cortex, and not at the keyboard?" -- Sid on userfriendly.org by Illiad, 2007-06-20