Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 15 Jan 2011 16:12:45 -0800
From:      mdf@FreeBSD.org
To:        FreeBSD Arch <freebsd-arch@freebsd.org>
Subject:   Automagic SYSCTLs
Message-ID:  <AANLkTi=cbdS0g370r=X%2B=uSd0vsRdC0oRkugq-nsBpgy@mail.gmail.com>

next in thread | raw e-mail | index | archive | help
I started out with a plan to import a patch from Isilon that adds
type-safety to the existing SYSCTLs for scalar variables in the
kernel.  After the discussion on the svn mailing list here
(http://lists.freebsd.org/pipermail/svn-src-head/2011-January/024097.html)
I now have a prototype patch for SYSCTL_ADD_SCALAR that could replace
most uses of SYSCTL_ADD_{INT, UINT, LONG, ULONG, QUAD} and is suitable
for the SYSCTL_ADD_FOO that are used on 16 and 8 bit members (without
type checking) today.

The gist is that the handler knows the sizeof the variable in the
kernel and uses this to copy out.  For the case of a long, there's
some goop for SCTL_MASK32.  For the case of 8 and 16 bit variables,
they are still copied in and out as 32-bit quantities.

Let me know if this seems like the right or wrong direction in which
to move.  I haven't tackled the static sysctls as the code I have does
some run-time evaluation because the code is easier to write that way.
 One possibility is to change the sysctl_oid struct or at least add a
SIGNED flag; this would also have the advantage of making it possible
to clean up the CTLTYPE_[U]INT issue where there is no real difference
between the two CTLTYPEs.

http://people.freebsd.org/~mdf/bsd-sysctl-scalar.diff

Thanks,
matthew



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTi=cbdS0g370r=X%2B=uSd0vsRdC0oRkugq-nsBpgy>