[prev in list] [next in list] [prev in thread] [next in thread]
List: freebsd-hackers
Subject: Re: ENOMEM when calling sysctl_handle_int from custom handler
From: Austin Shafer <amshafer64 () gmail ! com>
Date: 2018-12-18 20:08:51
Message-ID: m236quiomk.fsf () triplebuff ! com
[Download RAW message or body]
Ryan Stone <rysto32@gmail.com> writes:
> You should not pass arg1 and arg2 to sysctl_handle_int(). You instead
> need to pass a pointer to a local value containing the value you want
> to return to the sysctl caller. After sysctl_handle_int returns, if
> it returned 0 and req->newptr is non-NULL, then the integer value will
> contain the new value that was passed to you from userland. You want
> something that looks like this:
>
> int
> my_sysctl_handler(SYSCTL_HANDLER_ARGS)
> {
> int val, error;
>
> val = 5; /* Or whatever value you want to return from userland. */
>
> error = sysctl_handle_int(oidp, &val, 0, req);
> if (error != 0 || req->newptr == NULL)
> return (error);
>
> /* val contains the value set by the caller, so do something
> interesting with it here. */
>
> return (0);
> }
Hmm yup this seems to be problem. I had originally tried to just pass
the handler args directly through to sysctl_handle_int to make sure I
was creating the nodes correctly, since I knew sysctl_handle_int
worked.
Thanks again for all the help on these beginner questions!
Austin Shafer
_______________________________________________
freebsd-hackers@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/freebsd-hackers
To unsubscribe, send any mail to "freebsd-hackers-unsubscribe@freebsd.org"
[prev in list] [next in list] [prev in thread] [next in thread]
Configure |
About |
News |
Add a list |
Sponsored by KoreLogic