From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 5 17:24:48 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 38AC516A41F; Fri, 5 Aug 2005 17:24:48 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from pooker.samsco.org (pooker.samsco.org [168.103.85.57]) by mx1.FreeBSD.org (Postfix) with ESMTP id C271F43D45; Fri, 5 Aug 2005 17:24:45 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [192.168.254.11] (junior.samsco.home [192.168.254.11]) (authenticated bits=0) by pooker.samsco.org (8.13.3/8.13.3) with ESMTP id j75HWG9K064365; Fri, 5 Aug 2005 11:32:16 -0600 (MDT) (envelope-from scottl@samsco.org) Message-ID: <42F3A0D2.7090402@samsco.org> Date: Fri, 05 Aug 2005 11:24:34 -0600 From: Scott Long User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.7.8) Gecko/20050615 X-Accept-Language: en-us, en MIME-Version: 1.0 To: John Baldwin References: <20050805005543.5bd947f2.thib@mi.is> <20050805145046.GB78669@dan.emsphone.com> <200508051101.33927.jhb@FreeBSD.org> In-Reply-To: <200508051101.33927.jhb@FreeBSD.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.8 required=3.8 tests=ALL_TRUSTED autolearn=failed version=3.0.2 X-Spam-Checker-Version: SpamAssassin 3.0.2 (2004-11-16) on pooker.samsco.org Cc: freebsd-hackers@freebsd.org, Dan Nelson Subject: Re: Checking sysctl values from within the kernel. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 05 Aug 2005 17:24:48 -0000 John Baldwin 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. > Shoot, forgot about that function. However, exporting data throughout the kernel via the sysctl interface sounds like poor design. Scott