From owner-freebsd-hackers@FreeBSD.ORG Thu Feb 26 05:32:03 2004 Return-Path: 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 A390C16A4CE for ; Thu, 26 Feb 2004 05:32:03 -0800 (PST) Received: from arginine.spc.org (arginine.spc.org [195.206.69.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id 22EA043D1D for ; Thu, 26 Feb 2004 05:32:03 -0800 (PST) (envelope-from bms@spc.org) Received: from localhost (localhost [127.0.0.1]) by arginine.spc.org (Postfix) with ESMTP id 572E765319; Thu, 26 Feb 2004 13:32:01 +0000 (GMT) Received: from arginine.spc.org ([127.0.0.1]) by localhost (arginine.spc.org [127.0.0.1]) (amavisd-new, port 10024) with LMTP id 57885-04-7; Thu, 26 Feb 2004 13:32:00 +0000 (GMT) Received: from saboteur.dek.spc.org (82-147-17-88.dsl.uk.rapidplay.com [82.147.17.88]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by arginine.spc.org (Postfix) with ESMTP id 7959F6530A; Thu, 26 Feb 2004 13:32:00 +0000 (GMT) Received: by saboteur.dek.spc.org (Postfix, from userid 1001) id 73E8C38; Thu, 26 Feb 2004 13:31:59 +0000 (GMT) Date: Thu, 26 Feb 2004 13:31:59 +0000 From: Bruce M Simpson To: Ivan Voras Message-ID: <20040226133159.GA17994@saboteur.dek.spc.org> References: <403DF050.80208@fer.hr> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <403DF050.80208@fer.hr> cc: hackers@freebsd.org Subject: Re: Accessing sysctls from kernel X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Feb 2004 13:32:03 -0000 On Thu, Feb 26, 2004 at 02:10:40PM +0100, Ivan Voras wrote: > In sys/sys/sysctl.h I see function kernel_sysctlbyname() that looks (to > me) to be intended for accessing sysctl values from kernel, but for it's > first parameter it requires a struct thread *td. > > What should I pass to it? (I'm calling it from inside a screensaver module) You could try lying about which thread you are, when you aren't in a userland thread: Cscope tag: kernel_sysctlbyname # line filename / context / line 1 728 /sys/dev/vinum/vinumio.c <> error = kernel_sysctlbyname(&thread0, "kern.disks", NULL, 2 741 /sys/dev/vinum/vinumio.c <> kernel_sysctlbyname(&thread0, "kern.disks", devicename, 3 305 /sys/i386/i386/elan-mmcr.c <> i = kernel_sysctlbyname(&thread0, "machdep.i8254_freq", BMS