RFC: sysctl additional functions/macros

Poul-Henning Kamp phk at phk.freebsd.dk
Fri Jan 4 02:38:45 PST 2008


In message <477D931D.4000303 at elischer.org>, Julian Elischer writes:
>I would like to extend the current SYSCTL_INT() with 
>SYSCTL_INT_CLAMPED() or similar, where you also supply a
>maximum acceptable value. (and maybe a clue as to what to say if it is 
>a bad value).

I'm not sure I think it is a good idea.

Next you'll want SYSCTL_INT_BITMAP(), SYSCTL_INT_POWERS_OF_PI() and
so on.

A much better idea would be to add a code argument to a version of
SYSCTL_INT(), so that people could write something like:

SYSCTL_INT(_debug, OID_AUTO, foobar, ORD_WR, &foobar, 0,
	"mumble desc mumble",
	{
	if (newval < 3 || newval > 70 || newval == 59)
		return (EINVAL);
	}
)

-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk at FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.


More information about the freebsd-arch mailing list