From owner-freebsd-hackers@FreeBSD.ORG Fri Aug 5 15:33:17 2005 Return-Path: X-Original-To: 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 D281B16A420 for ; Fri, 5 Aug 2005 15:33:17 +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 85FEA43D49 for ; Fri, 5 Aug 2005 15:33:16 +0000 (GMT) (envelope-from scottl@samsco.org) Received: from [192.168.254.14] (imini.samsco.home [192.168.254.14]) (authenticated bits=0) by pooker.samsco.org (8.13.3/8.13.3) with ESMTP id j75FegWO063814; Fri, 5 Aug 2005 09:40:43 -0600 (MDT) (envelope-from scottl@samsco.org) Message-ID: <42F386B2.1010108@samsco.org> Date: Fri, 05 Aug 2005 09:33:06 -0600 From: Scott Long User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.7.7) Gecko/20050416 X-Accept-Language: en-us, en MIME-Version: 1.0 To: Dan Nelson References: <20050805005543.5bd947f2.thib@mi.is> <20050805145046.GB78669@dan.emsphone.com> In-Reply-To: <20050805145046.GB78669@dan.emsphone.com> 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: hackers@freebsd.org 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 15:33:17 -0000 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. > Most of those integer values are also declared static, so they won't be visible to external code, especially not kld's. There is no easy way to do this. I'm sure that you could hack up some code to simulate a sysctl syscall from within the kernel, but that would be really really gross, evil, and wrong. What values are you trying to get at? Would it make more sense to export them via real accessor functions? Scott