Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys Add kern.{ostype, osrelease, osrevision, version} kern.doma...
details: https://anonhg.NetBSD.org/src/rev/50712801ac2d
branches: trunk
changeset: 326990:50712801ac2d
user: justin <justin%NetBSD.org@localhost>
date: Tue Feb 25 01:02:42 2014 +0000
description:
Add kern.{ostype,osrelease,osrevision,version} kern.domainname,
kern.rawpartition sysctl support to rump kernel.
Moved the sysctl support that is shared between rump and normal
kernels to init_sysctl_base.c as rump cannot use init_sysctl.c
in order to avoid code duplication. Agreed with pooka@.
diffstat:
sys/kern/init_sysctl.c | 73 +-------------------------------
sys/kern/init_sysctl_base.c | 90 +++++++++++++++++++++++++++++++++++++++-
sys/rump/librump/rumpkern/rump.c | 14 +-----
3 files changed, 92 insertions(+), 85 deletions(-)
diffs (275 lines):
diff -r c06df2e90d6e -r 50712801ac2d sys/kern/init_sysctl.c
--- a/sys/kern/init_sysctl.c Tue Feb 25 00:26:43 2014 +0000
+++ b/sys/kern/init_sysctl.c Tue Feb 25 01:02:42 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_sysctl.c,v 1.199 2014/01/17 02:12:48 pooka Exp $ */
+/* $NetBSD: init_sysctl.c,v 1.200 2014/02/25 01:02:42 justin Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,7 +30,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.199 2014/01/17 02:12:48 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_sysctl.c,v 1.200 2014/02/25 01:02:42 justin Exp $");
#include "opt_sysv.h"
#include "opt_compat_netbsd.h"
@@ -105,7 +105,6 @@
static int sysctl_kern_rtc_offset(SYSCTLFN_PROTO);
static int sysctl_kern_maxproc(SYSCTLFN_PROTO);
static int sysctl_kern_hostid(SYSCTLFN_PROTO);
-static int sysctl_setlen(SYSCTLFN_PROTO);
static int sysctl_kern_clockrate(SYSCTLFN_PROTO);
static int sysctl_msgbuf(SYSCTLFN_PROTO);
static int sysctl_kern_defcorename(SYSCTLFN_PROTO);
@@ -151,30 +150,6 @@
CTL_KERN, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
- CTLFLAG_PERMANENT,
- CTLTYPE_STRING, "ostype",
- SYSCTL_DESCR("Operating system type"),
- NULL, 0, __UNCONST(&ostype), 0,
- CTL_KERN, KERN_OSTYPE, CTL_EOL);
- sysctl_createv(clog, 0, NULL, NULL,
- CTLFLAG_PERMANENT,
- CTLTYPE_STRING, "osrelease",
- SYSCTL_DESCR("Operating system release"),
- NULL, 0, __UNCONST(&osrelease), 0,
- CTL_KERN, KERN_OSRELEASE, CTL_EOL);
- sysctl_createv(clog, 0, NULL, NULL,
- CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
- CTLTYPE_INT, "osrevision",
- SYSCTL_DESCR("Operating system revision"),
- NULL, __NetBSD_Version__, NULL, 0,
- CTL_KERN, KERN_OSREV, CTL_EOL);
- sysctl_createv(clog, 0, NULL, NULL,
- CTLFLAG_PERMANENT,
- CTLTYPE_STRING, "version",
- SYSCTL_DESCR("Kernel version"),
- NULL, 0, __UNCONST(&version), 0,
- CTL_KERN, KERN_VERSION, CTL_EOL);
- sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
CTLTYPE_INT, "maxvnodes",
SYSCTL_DESCR("Maximum number of vnodes"),
@@ -200,12 +175,6 @@
NULL, ARG_MAX, NULL, 0,
CTL_KERN, KERN_ARGMAX, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
- CTLTYPE_STRING, "hostname",
- SYSCTL_DESCR("System hostname"),
- sysctl_setlen, 0, hostname, MAXHOSTNAMELEN,
- CTL_KERN, KERN_HOSTNAME, CTL_EOL);
- sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_READWRITE|CTLFLAG_HEX,
CTLTYPE_INT, "hostid",
SYSCTL_DESCR("System host ID number"),
@@ -282,12 +251,6 @@
NULL, 0, &boottime, sizeof(boottime),
CTL_KERN, KERN_BOOTTIME, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
- CTLTYPE_STRING, "domainname",
- SYSCTL_DESCR("YP domain name"),
- sysctl_setlen, 0, domainname, MAXHOSTNAMELEN,
- CTL_KERN, KERN_DOMAINNAME, CTL_EOL);
- sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
CTLTYPE_INT, "maxpartitions",
SYSCTL_DESCR("Maximum number of partitions allowed per "
@@ -295,12 +258,6 @@
NULL, MAXPARTITIONS, NULL, 0,
CTL_KERN, KERN_MAXPARTITIONS, CTL_EOL);
sysctl_createv(clog, 0, NULL, NULL,
- CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
- CTLTYPE_INT, "rawpartition",
- SYSCTL_DESCR("Raw partition of a disk"),
- NULL, RAW_PART, NULL, 0,
- CTL_KERN, KERN_RAWPARTITION, CTL_EOL);
- sysctl_createv(clog, 0, NULL, NULL,
CTLFLAG_PERMANENT,
CTLTYPE_STRUCT, "timex", NULL,
sysctl_notavail, 0, NULL, 0,
@@ -1011,32 +968,6 @@
}
/*
- * sysctl helper function for kern.hostname and kern.domainnname.
- * resets the relevant recorded length when the underlying name is
- * changed.
- */
-static int
-sysctl_setlen(SYSCTLFN_ARGS)
-{
- int error;
-
- error = sysctl_lookup(SYSCTLFN_CALL(rnode));
- if (error || newp == NULL)
- return (error);
-
- switch (rnode->sysctl_num) {
- case KERN_HOSTNAME:
- hostnamelen = strlen((const char*)rnode->sysctl_data);
- break;
- case KERN_DOMAINNAME:
- domainnamelen = strlen((const char*)rnode->sysctl_data);
- break;
- }
-
- return (0);
-}
-
-/*
* sysctl helper routine for kern.clockrate. Assembles a struct on
* the fly to be returned to the caller.
*/
diff -r c06df2e90d6e -r 50712801ac2d sys/kern/init_sysctl_base.c
--- a/sys/kern/init_sysctl_base.c Tue Feb 25 00:26:43 2014 +0000
+++ b/sys/kern/init_sysctl_base.c Tue Feb 25 01:02:42 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: init_sysctl_base.c,v 1.1 2009/09/16 15:03:56 pooka Exp $ */
+/* $NetBSD: init_sysctl_base.c,v 1.2 2014/02/25 01:02:42 justin Exp $ */
/*-
* Copyright (c) 2003, 2007, 2008, 2009 The NetBSD Foundation, Inc.
@@ -30,10 +30,14 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: init_sysctl_base.c,v 1.1 2009/09/16 15:03:56 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: init_sysctl_base.c,v 1.2 2014/02/25 01:02:42 justin Exp $");
#include <sys/param.h>
#include <sys/sysctl.h>
+#include <sys/kernel.h>
+#include <sys/disklabel.h>
+
+static int sysctl_setlen(SYSCTLFN_PROTO);
/*
* sets up the base nodes...
@@ -124,3 +128,85 @@
NULL, 0, NULL, 0,
CTL_SECURITY, CTL_EOL);
}
+
+/*
+ * now add some nodes which both rump kernel and standard
+ * NetBSD both need, as rump cannot use sys/kern/init_sysctl.c
+ */
+SYSCTL_SETUP(sysctl_kernbase_setup, "sysctl kern subtree base setup")
+{
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_NODE, "kern", NULL,
+ NULL, 0, NULL, 0,
+ CTL_KERN, CTL_EOL);
+
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_STRING, "ostype",
+ SYSCTL_DESCR("Operating system type"),
+ NULL, 0, __UNCONST(&ostype), 0,
+ CTL_KERN, KERN_OSTYPE, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_STRING, "osrelease",
+ SYSCTL_DESCR("Operating system release"),
+ NULL, 0, __UNCONST(&osrelease), 0,
+ CTL_KERN, KERN_OSRELEASE, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
+ CTLTYPE_INT, "osrevision",
+ SYSCTL_DESCR("Operating system revision"),
+ NULL, __NetBSD_Version__, NULL, 0,
+ CTL_KERN, KERN_OSREV, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT,
+ CTLTYPE_STRING, "version",
+ SYSCTL_DESCR("Kernel version"),
+ NULL, 0, __UNCONST(&version), 0,
+ CTL_KERN, KERN_VERSION, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_STRING, "hostname",
+ SYSCTL_DESCR("System hostname"),
+ sysctl_setlen, 0, hostname, MAXHOSTNAMELEN,
+ CTL_KERN, KERN_HOSTNAME, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_READWRITE,
+ CTLTYPE_STRING, "domainname",
+ SYSCTL_DESCR("YP domain name"),
+ sysctl_setlen, 0, domainname, MAXHOSTNAMELEN,
+ CTL_KERN, KERN_DOMAINNAME, CTL_EOL);
+ sysctl_createv(clog, 0, NULL, NULL,
+ CTLFLAG_PERMANENT|CTLFLAG_IMMEDIATE,
+ CTLTYPE_INT, "rawpartition",
+ SYSCTL_DESCR("Raw partition of a disk"),
+ NULL, RAW_PART, NULL, 0,
+ CTL_KERN, KERN_RAWPARTITION, CTL_EOL);
+}
+
+/*
+ * sysctl helper function for kern.hostname and kern.domainnname.
+ * resets the relevant recorded length when the underlying name is
+ * changed.
+ */
+static int
+sysctl_setlen(SYSCTLFN_ARGS)
+{
+ int error;
+
+ error = sysctl_lookup(SYSCTLFN_CALL(rnode));
+ if (error || newp == NULL)
+ return (error);
+
+ switch (rnode->sysctl_num) {
+ case KERN_HOSTNAME:
+ hostnamelen = strlen((const char*)rnode->sysctl_data);
+ break;
+ case KERN_DOMAINNAME:
+ domainnamelen = strlen((const char*)rnode->sysctl_data);
+ break;
+ }
+
+ return (0);
+}
diff -r c06df2e90d6e -r 50712801ac2d sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c Tue Feb 25 00:26:43 2014 +0000
+++ b/sys/rump/librump/rumpkern/rump.c Tue Feb 25 01:02:42 2014 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump.c,v 1.284 2014/01/29 18:42:14 pooka Exp $ */
+/* $NetBSD: rump.c,v 1.285 2014/02/25 01:02:42 justin Exp $ */
/*
* Copyright (c) 2007-2011 Antti Kantee. All Rights Reserved.
@@ -26,7 +26,7 @@
*/
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.284 2014/01/29 18:42:14 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.285 2014/02/25 01:02:42 justin Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@@ -168,16 +168,6 @@
mksysctls(void)
{
- /* kern.hostname */
- sysctl_createv(NULL, 0, NULL, NULL,
- CTLFLAG_PERMANENT, CTLTYPE_NODE, "kern", NULL,
- NULL, 0, NULL, 0, CTL_KERN, CTL_EOL);
- /* XXX: setting hostnamelen is missing */
- sysctl_createv(NULL, 0, NULL, NULL,
- CTLFLAG_PERMANENT|CTLFLAG_READWRITE, CTLTYPE_STRING, "hostname",
- SYSCTL_DESCR("System hostname"), NULL, 0,
- hostname, MAXHOSTNAMELEN, CTL_KERN, KERN_HOSTNAME, CTL_EOL);
-
/* hw.pagesize */
sysctl_createv(NULL, 0, NULL, NULL,
CTLFLAG_PERMANENT,
Home |
Main Index |
Thread Index |
Old Index