From owner-freebsd-hackers@FreeBSD.ORG Thu Aug 11 23:21:02 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 CA0B616A41F; Thu, 11 Aug 2005 23:21:02 +0000 (GMT) (envelope-from ambrisko@ambrisko.com) Received: from mail.ambrisko.com (mail.ambrisko.com [64.174.51.43]) by mx1.FreeBSD.org (Postfix) with ESMTP id 7825643D58; Thu, 11 Aug 2005 23:21:02 +0000 (GMT) (envelope-from ambrisko@ambrisko.com) Received: from server2.ambrisko.com (HELO www.ambrisko.com) ([192.168.1.2]) by mail.ambrisko.com with ESMTP; 11 Aug 2005 16:21:02 -0700 Received: from ambrisko.com (localhost [127.0.0.1]) by www.ambrisko.com (8.12.11/8.12.9) with ESMTP id j7BNL27p001304; Thu, 11 Aug 2005 16:21:02 -0700 (PDT) (envelope-from ambrisko@ambrisko.com) Received: (from ambrisko@localhost) by ambrisko.com (8.12.11/8.12.11/Submit) id j7BNL2rf001303; Thu, 11 Aug 2005 16:21:02 -0700 (PDT) (envelope-from ambrisko) From: Doug Ambrisko Message-Id: <200508112321.j7BNL2rf001303@ambrisko.com> In-Reply-To: <200508051101.33927.jhb@FreeBSD.org> To: John Baldwin Date: Thu, 11 Aug 2005 16:21:02 -0700 (PDT) X-Mailer: ELM [version 2.4ME+ PL94b (25)] MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=US-ASCII 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: Thu, 11 Aug 2005 23:21:02 -0000 John Baldwin writes: | 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. This could be a fragile interface though. I used this scheme to do "soft-linking" between modules that could be kldloaded into the kernel or static. We called it several times every few seconds. Over time the system would wedge on a setjmp or something like that. We changed it to a function call since in a static kernel then the problem went away. Doug A.