From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 18 20:49:23 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 C1F5E106566C for ; Sun, 18 Dec 2011 20:49:23 +0000 (UTC) (envelope-from fernando.apesteguia@gmail.com) Received: from mail-lpp01m010-f54.google.com (mail-lpp01m010-f54.google.com [209.85.215.54]) by mx1.freebsd.org (Postfix) with ESMTP id 453998FC0C for ; Sun, 18 Dec 2011 20:49:22 +0000 (UTC) Received: by lahl5 with SMTP id l5so2804585lah.13 for ; Sun, 18 Dec 2011 12:49:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; bh=ohGWIqCxDxsG02d+7mriP/L18uHnc7RpKnlRnLRB/Iw=; b=inT3qsCNRCsPyU607cnTeV6Y+10mTlejl8g8pOwl0CNWP5CadfDlTvBAmdIWIKYjbB R4w6O5t45HiAZ6+7p3Wav1eiYvHN9xe72qVjfM3oz3snBrQDA5NZtu1m9Ql+tttgf6S7 r1XWwXhLkOGAzyaqiCJbn5lu/99uoXHGTytyQ= MIME-Version: 1.0 Received: by 10.152.103.51 with SMTP id ft19mr13961747lab.42.1324239502546; Sun, 18 Dec 2011 12:18:22 -0800 (PST) Received: by 10.152.24.138 with HTTP; Sun, 18 Dec 2011 12:18:22 -0800 (PST) Date: Sun, 18 Dec 2011 21:18:22 +0100 Message-ID: From: =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= To: FreeBSD Hackers Content-Type: text/plain; charset=ISO-8859-1 Subject: 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 20:49:23 -0000 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) 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.