[Zrouter-src-freebsd] ZRouter.org: push to FreeBSD HEAD tree
zrouter-src-freebsd at zrouter.org
zrouter-src-freebsd at zrouter.org
Mon Sep 3 09:53:33 UTC 2012
details: http://zrouter.org/hg/FreeBSD/head//rev/76b85088d564
changeset: 532:76b85088d564
user: Aleksandr Rybalko <ray at ddteam.net>
date: Mon Sep 03 12:55:26 2012 +0300
description:
Simplify sysctl handler.
Pointed by: jhb@
diffstat:
head/sys/kern/subr_hints.c | 22 +++++++++++++---------
1 files changed, 13 insertions(+), 9 deletions(-)
diffs (59 lines):
diff -r c7324ca78e10 -r 76b85088d564 head/sys/kern/subr_hints.c
--- a/head/sys/kern/subr_hints.c Sun Sep 02 23:14:10 2012 +0300
+++ b/head/sys/kern/subr_hints.c Mon Sep 03 12:55:26 2012 +0300
@@ -43,6 +43,12 @@
static int use_kenv;
static char *hintp;
+/*
+ * Define kern.hintmode sysctl, which only accept value 2, that cause to
+ * switch from Static KENV mode to Dynamic KENV. So systems that have hints
+ * compiled into kernel will be able to see/modify KENV (and hints too).
+ */
+
static int
sysctl_hintmode(SYSCTL_HANDLER_ARGS)
{
@@ -52,16 +58,13 @@
from_kenv = 0;
cp = kern_envp;
+ value = hintmode;
- /* Write out the old value. */
- error = SYSCTL_OUT(req, &hintmode, sizeof(int));
- if (error || req->newptr == NULL)
+ /* Fetch candidate for new hintmode value */
+ error = sysctl_handle_int(oidp, &value, 0, req);
+ if (error || !req->newptr)
return (error);
- /* Read in and verify the new value. */
- error = SYSCTL_IN(req, &value, sizeof(int));
- if (error)
- return (error);
if (value != 2)
/* Only accept swithing to hintmode 2 */
return (EINVAL);
@@ -69,10 +72,11 @@
/* Migrate from static to dynamic hints */
switch (hintmode) {
case 0:
- if (dynamic_kenv)
+ if (dynamic_kenv) {
/* Already here */
hintmode = value; /* XXX: Need we switch or not ? */
return (0);
+ }
from_kenv = 1;
cp = kern_envp;
break;
@@ -113,7 +117,7 @@
}
SYSCTL_PROC(_kern, OID_AUTO, hintmode, CTLTYPE_INT|CTLFLAG_RW,
- &hintmode, 0, sysctl_hintmode, "I", "get/set hintmode");
+ &hintmode, 0, sysctl_hintmode, "I", "Get/set current hintmode");
/*
* Evil wildcarding resource string lookup.
More information about the Zrouter-src-freebsd
mailing list