From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 18 21:12:46 2011 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 806DD106566C for ; Sun, 18 Dec 2011 21:12:46 +0000 (UTC) (envelope-from julian@freebsd.org) Received: from vps1.elischer.org (vps1.elischer.org [204.109.63.16]) by mx1.freebsd.org (Postfix) with ESMTP id 531AE8FC0A for ; Sun, 18 Dec 2011 21:12:45 +0000 (UTC) Received: from julian-mac.elischer.org (c-67-180-24-15.hsd1.ca.comcast.net [67.180.24.15]) (authenticated bits=0) by vps1.elischer.org (8.14.4/8.14.4) with ESMTP id pBILCfxR010726 (version=TLSv1/SSLv3 cipher=DHE-RSA-CAMELLIA256-SHA bits=256 verify=NO); Sun, 18 Dec 2011 13:12:44 -0800 (PST) (envelope-from julian@freebsd.org) Message-ID: <4EEE5763.6010509@freebsd.org> Date: Sun, 18 Dec 2011 13:13:07 -0800 From: Julian Elischer User-Agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X 10.4; en-US; rv:1.9.2.24) Gecko/20111103 Thunderbird/3.1.16 MIME-Version: 1.0 To: =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 8bit Cc: FreeBSD Hackers Subject: Re: sysctl variable question 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: Sun, 18 Dec 2011 21:12:46 -0000 On 12/18/11 12:18 PM, Fernando Apesteguía wrote: > Hi all, > > I'm writing a small module just for fun. I would like to have two variables: > > - "pid" of type unsigned int and RW so the user can set a pid > - "process_name" as a string RD that will display the process name > associated to that pid (or a message if the pid doesn't exist anymore) this is dangerous as there are some places in the kernel where processes are referenced by pid, so changing it may break kernel assumptions. > My problem is with the handler functions. For "process_name", as it is > read only, I wrote a simple handler that works fine. However, I want > to write another one for "pid" so I can sanitize the input (avoiding > pids< 0 and so). As I understand, the handler I specify with > SYSCTL_OID will be called for both reads and writes. But, how can I > tell what kind of operation is it, so I know if I have to use > SYSCTL_OUT or SYSCTL_IN? I tried to have a look at sysctl_handle_int > but I don't fully understand what is going on with the arg1 parameter. > What is it for? > > Thanks in advance. > _______________________________________________ > freebsd-hackers@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-hackers > To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org" >