Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 18 Dec 2011 21:18:22 +0100
From:      =?ISO-8859-1?Q?Fernando_Apestegu=EDa?= <fernando.apesteguia@gmail.com>
To:        FreeBSD Hackers <freebsd-hackers@freebsd.org>
Subject:   sysctl variable question
Message-ID:  <CAGwOe2bxBLHFcMzVygcaQjLrHsxFuccs9CHZoP30PC%2BDoORCdQ@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGwOe2bxBLHFcMzVygcaQjLrHsxFuccs9CHZoP30PC%2BDoORCdQ>