From owner-freebsd-hackers@FreeBSD.ORG Sun Dec 18 22:52:26 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 6665A106567A for ; Sun, 18 Dec 2011 22:52:26 +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 A30EA8FC0C for ; Sun, 18 Dec 2011 22:52:25 +0000 (UTC) Received: by lahl5 with SMTP id l5so2827761lah.13 for ; Sun, 18 Dec 2011 14:52:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=UQgyt1VVYcDfJL1MBT603u9sJfeAgJsYGBBZZ2sHwe8=; b=VCUPHsAuYZLkNBgAYWgELBSrg70//RrIaNrvKF4DGWH/cJufjEhRxVrLGn1E9VHo2J p2AICntFC1z7Tgs9MeAiPx6yWdfHLSa60OFTcZc8KFnalE9aR9Nduf4NyWQqrSrDlT4C +aHWAM4tANaIALVEw0yzdeQt8eAZ3dOiuec/w= MIME-Version: 1.0 Received: by 10.152.103.51 with SMTP id ft19mr14265162lab.42.1324248744283; Sun, 18 Dec 2011 14:52:24 -0800 (PST) Received: by 10.152.24.138 with HTTP; Sun, 18 Dec 2011 14:52:24 -0800 (PST) Received: by 10.152.24.138 with HTTP; Sun, 18 Dec 2011 14:52:24 -0800 (PST) In-Reply-To: <4EEE5763.6010509@freebsd.org> References: <4EEE5763.6010509@freebsd.org> Date: Sun, 18 Dec 2011 23:52:24 +0100 Message-ID: From: =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= To: Julian Elischer Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Content-Filtered-By: Mailman/MimeDel 2.1.5 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 22:52:26 -0000 El 18/12/2011 22:12, "Julian Elischer" escribi=F3: > > On 12/18/11 12:18 PM, Fernando Apestegu=EDa 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. Sorry, i think i didn't explain it clearly. The "pid" variable is static in my module and it is used just to tell the module which information it should show in the other variable. >> >> 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.or= g " >> >