a puzzle about FreeBSD

Andrey Simonenko simon at comsys.ntu-kpi.kiev.ua
Wed Nov 23 16:15:03 GMT 2005

On Sat, Nov 19, 2005 at 09:51:58PM +0800, ?????? wrote:
> I read the source code of a project. I don??t understand SYSCTL_IN macro and
> SYSCTL_PROC macro. I want to know when my function registered in SYSCTL_PROC
> is called.

This sysctl handler is called, for example, from __sysctl ->
userland_sysctl -> sysctl_root as oid_handler, which is setuped,
when SYSCTL_PROC declared struct sysctl_oid{}.

SYSCTL_IN/OUT are used for copying to/from one buffer to another
buffer with advancing pointers and offsets of buffers.  Since
there are two spaces userland and kernel, but interface should
be general, there are two functions oldfunc and newfunc in struct
sysctl_req{}, which are defined to sysctl_{new,old}_{kernel,user},
depending from which space it is necessary to make sysctl call.

More information about the freebsd-hackers mailing list