Module Name:    src
Committed By:   pooka
Date:           Mon Dec 13 17:47:40 UTC 2010

Modified Files:
        src/sbin/sysctl: Makefile sysctl.c
Added Files:
        src/sbin/sysctl: prog_ops.h sysctl_hostops.c sysctl_rumpops.c

Log Message:
RUMP_ACTION -> RUMPPRG


To generate a diff of this commit:
cvs rdiff -u -r1.19 -r1.20 src/sbin/sysctl/Makefile
cvs rdiff -u -r0 -r1.1 src/sbin/sysctl/prog_ops.h \
    src/sbin/sysctl/sysctl_hostops.c src/sbin/sysctl/sysctl_rumpops.c
cvs rdiff -u -r1.132 -r1.133 src/sbin/sysctl/sysctl.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sbin/sysctl/Makefile
diff -u src/sbin/sysctl/Makefile:1.19 src/sbin/sysctl/Makefile:1.20
--- src/sbin/sysctl/Makefile:1.19	Fri Nov  5 15:55:23 2010
+++ src/sbin/sysctl/Makefile	Mon Dec 13 17:47:40 2010
@@ -1,19 +1,16 @@
-#	$NetBSD: Makefile,v 1.19 2010/11/05 15:55:23 pooka Exp $
+#	$NetBSD: Makefile,v 1.20 2010/12/13 17:47:40 pooka Exp $
 #	@(#)Makefile	8.1 (Berkeley) 6/6/93
 
 .include <bsd.own.mk>
 #CFLAGS+=-g
 
-PROG=	sysctl
+RUMPPRG=sysctl
 MAN=	sysctl.8
 
 SRCS=	sysctl.c
 
-.ifdef RUMP_ACTION
 .PATH:	${.CURDIR}/../../lib/libc/gen
 CPPFLAGS+= -DRUMP_ACTION
-LDADD+=	-lrumpclient
-SRCS+=	sysctlgetmibinfo.c
-.endif
+RUMPSRCS+= sysctlbyname.c sysctlgetmibinfo.c
 
 .include <bsd.prog.mk>

Index: src/sbin/sysctl/sysctl.c
diff -u src/sbin/sysctl/sysctl.c:1.132 src/sbin/sysctl/sysctl.c:1.133
--- src/sbin/sysctl/sysctl.c:1.132	Fri Nov  5 15:55:23 2010
+++ src/sbin/sysctl/sysctl.c	Mon Dec 13 17:47:40 2010
@@ -1,4 +1,4 @@
-/*	$NetBSD: sysctl.c,v 1.132 2010/11/05 15:55:23 pooka Exp $ */
+/*	$NetBSD: sysctl.c,v 1.133 2010/12/13 17:47:40 pooka Exp $ */
 
 /*-
  * Copyright (c) 2003 The NetBSD Foundation, Inc.
@@ -68,7 +68,7 @@
 #if 0
 static char sccsid[] = "@(#)sysctl.c	8.1 (Berkeley) 6/6/93";
 #else
-__RCSID("$NetBSD: sysctl.c,v 1.132 2010/11/05 15:55:23 pooka Exp $");
+__RCSID("$NetBSD: sysctl.c,v 1.133 2010/12/13 17:47:40 pooka Exp $");
 #endif
 #endif /* not lint */
 
@@ -105,12 +105,7 @@
 #include <time.h>
 #include <unistd.h>
 
-#ifdef RUMP_ACTION
-#include <rump/rumpclient.h>
-#include <rump/rump_syscalls.h>
-
-#define sysctl(a,b,c,d,e,f) rump_sys___sysctl(a,b,c,d,e,f)
-#endif
+#include "prog_ops.h"
 
 /*
  * this needs to be able to do the printing and the setting
@@ -276,11 +271,6 @@
 	int name[CTL_MAXNAME];
 	int ch;
 
-#ifdef RUMP_ACTION
-	if (rumpclient_init() == -1)
-		err(1, "rumpclient init failed");
-#endif
-
 	while ((ch = getopt(argc, argv, "Aabdef:Mnqrwx")) != -1) {
 		switch (ch) {
 		case 'A':
@@ -337,6 +327,9 @@
 	if ((Aflag || Mflag || dflag) && argc == 0 && fn == NULL)
 		aflag = 1;
 
+	if (prog_init && prog_init() == -1)
+		err(1, "prog init failed");
+
 	if (Aflag)
 		warnfp = stdout;
 	stale = req = 0;
@@ -667,7 +660,7 @@
 	}
 
 	if (type != CTLTYPE_NODE && pnode->sysctl_size == 0) {
-		rc = sysctl(&name[0], namelen, NULL, &sz, NULL, 0);
+		rc = prog_sysctl(&name[0], namelen, NULL, &sz, NULL, 0);
 		if (rc == -1) {
 			sysctlerror(1);
 			*sp = *dp = '\0';
@@ -718,7 +711,7 @@
 	}
 	case CTLTYPE_INT: {
 		int i;
-		rc = sysctl(name, namelen, &i, &sz, NULL, 0);
+		rc = prog_sysctl(name, namelen, &i, &sz, NULL, 0);
 		if (rc == -1) {
 			sysctlerror(1);
 			break;
@@ -728,7 +721,7 @@
 	}
 	case CTLTYPE_BOOL: {
 		bool b;
-		rc = sysctl(name, namelen, &b, &sz, NULL, 0);
+		rc = prog_sysctl(name, namelen, &b, &sz, NULL, 0);
 		if (rc == -1) {
 			sysctlerror(1);
 			break;
@@ -740,14 +733,14 @@
 		unsigned char buf[1024], *tbuf;
 		tbuf = buf;
 		sz = sizeof(buf);
-		rc = sysctl(&name[0], namelen, tbuf, &sz, NULL, 0);
+		rc = prog_sysctl(&name[0], namelen, tbuf, &sz, NULL, 0);
 		if (rc == -1 && errno == ENOMEM) {
 			tbuf = malloc(sz);
 			if (tbuf == NULL) {
 				sysctlerror(1);
 				break;
 			}
-			rc = sysctl(&name[0], namelen, tbuf, &sz, NULL, 0);
+			rc = prog_sysctl(&name[0], namelen, tbuf, &sz, NULL, 0);
 		}
 		if (rc == -1)
 			sysctlerror(1);
@@ -760,7 +753,7 @@
 	case CTLTYPE_QUAD: {
 		u_quad_t q;
 		sz = sizeof(q);
-		rc = sysctl(&name[0], namelen, &q, &sz, NULL, 0);
+		rc = prog_sysctl(&name[0], namelen, &q, &sz, NULL, 0);
 		if (rc == -1) {
 			sysctlerror(1);
 			break;
@@ -780,7 +773,7 @@
 			fprintf(warnfp, "%s: !malloc failed!\n", gsname);
 			break;
 		}
-		rc = sysctl(&name[0], namelen, d, &sz, NULL, 0);
+		rc = prog_sysctl(&name[0], namelen, d, &sz, NULL, 0);
 		if (rc == -1) {
 			sysctlerror(1);
 			break;
@@ -1023,7 +1016,7 @@
 		}
 
 		/*
-		 * note that we (mostly) let the invoker of sysctl(8)
+		 * note that we (mostly) let the invoker of prog_sysctl(8)
 		 * play rampant here and depend on the kernel to tell
 		 * them that they were wrong.  well...within reason.
 		 * we later check the various parameters against each
@@ -1417,7 +1410,7 @@
 		name[namelen++] = CTL_CREATE;
 
 	sz = sizeof(node);
-	rc = sysctl(&name[0], namelen, &node, &sz, &node, sizeof(node));
+	rc = prog_sysctl(&name[0], namelen, &node, &sz, &node, sizeof(node));
 
 	if (rc == -1) {
 		sysctlperror("%s: CTL_CREATE failed: %s\n",
@@ -1460,7 +1453,7 @@
 	name[namelen - 1] = CTL_DESTROY;
 
 	sz = sizeof(node);
-	rc = sysctl(&name[0], namelen, &node, &sz, &node, sizeof(node));
+	rc = prog_sysctl(&name[0], namelen, &node, &sz, &node, sizeof(node));
 
 	if (rc == -1) {
 		sysctlperror("%s: CTL_DESTROY failed: %s\n",
@@ -1509,7 +1502,7 @@
 	newdesc.sysctl_num = name[namelen - 1];
 	newdesc.sysctl_desc = value;
 	name[namelen - 1] = CTL_DESCRIBE;
-	rc = sysctl(name, namelen, d, &sz, &newdesc, sizeof(newdesc));
+	rc = prog_sysctl(name, namelen, d, &sz, &newdesc, sizeof(newdesc));
 	if (rc == -1)
 		sysctlperror("%s: CTL_DESCRIBE failed: %s\n",
 			     gsname, strerror(errno));
@@ -1558,7 +1551,7 @@
 	node.sysctl_flags = SYSCTL_VERSION;
 	node.sysctl_num = name[namelen - 1];
 	name[namelen - 1] = CTL_DESCRIBE;
-	rc = sysctl(name, namelen, d, &sz, &node, sizeof(node));
+	rc = prog_sysctl(name, namelen, d, &sz, &node, sizeof(node));
 
 	if (rc == -1 ||
 	    d->descr_len == 1 ||
@@ -1600,7 +1593,7 @@
 		d = malloc(sz);
 		if (d == NULL)
 			return;
-		rc = sysctl(name, namelen + 1, d, &sz, NULL, 0);
+		rc = prog_sysctl(name, namelen + 1, d, &sz, NULL, 0);
 		if (rc == -1) {
 			free(d);
 			d = NULL;
@@ -1764,7 +1757,7 @@
 		break;
 	}
 
-	rc = sysctl(name, namelen, o, &so, i, si);
+	rc = prog_sysctl(name, namelen, o, &so, i, si);
 	if (rc == -1) {
 		sysctlerror(0);
 		return;
@@ -1806,7 +1799,7 @@
 		exit(1);
 	}
 
-	rc = sysctl(name, namelen, o, &so, i, si);
+	rc = prog_sysctl(name, namelen, o, &so, i, si);
 	if (rc == -1) {
 		sysctlerror(0);
 		return;
@@ -2047,14 +2040,14 @@
 	 * okay...you asked for it, so let's give it a go
 	 */
 	while (type != CTLTYPE_NODE && (xflag || rflag)) {
-		rc = sysctl(name, namelen, NULL, &sz1, NULL, 0);
+		rc = prog_sysctl(name, namelen, NULL, &sz1, NULL, 0);
 		if (rc == -1 || sz1 == 0)
 			break;
 		p = malloc(sz1);
 		if (p == NULL)
 			break;
 		sz2 = sz1;
-		rc = sysctl(name, namelen, p, &sz2, NULL, 0);
+		rc = prog_sysctl(name, namelen, p, &sz2, NULL, 0);
 		if (rc == -1 || sz1 != sz2) {
 			free(p);
 			break;
@@ -2106,7 +2099,7 @@
 	int rc;
 
 	sz = sizeof(clkinfo);
-	rc = sysctl(name, namelen, &clkinfo, &sz, NULL, 0);
+	rc = prog_sysctl(name, namelen, &clkinfo, &sz, NULL, 0);
 	if (rc == -1) {
 		sysctlerror(1);
 		return;
@@ -2136,7 +2129,7 @@
 	int rc;
 
 	sz = sizeof(timeval);
-	rc = sysctl(name, namelen, &timeval, &sz, NULL, 0);
+	rc = prog_sysctl(name, namelen, &timeval, &sz, NULL, 0);
 	if (rc == -1) {
 		sysctlerror(1);
 		return;
@@ -2167,7 +2160,7 @@
 	int rc;
 
 	sz = sizeof(cons);
-	rc = sysctl(name, namelen, &cons, &sz, NULL, 0);
+	rc = prog_sysctl(name, namelen, &cons, &sz, NULL, 0);
 	if (rc == -1) {
 		sysctlerror(1);
 		return;
@@ -2225,7 +2218,7 @@
 	}
 
 	osz = sz;
-	rc = sysctl(name, namelen, cp_time + (n != -1) * CPUSTATES, &osz,
+	rc = prog_sysctl(name, namelen, cp_time + (n != -1) * CPUSTATES, &osz,
 		    NULL, 0);
 
 	if (rc == -1) {
@@ -2301,7 +2294,7 @@
 	int rc;
 	const char *comma;
 
-	rc = sysctl(name, namelen, NULL, &sz, NULL, 0);
+	rc = prog_sysctl(name, namelen, NULL, &sz, NULL, 0);
 	if (rc == -1) {
 		sysctlerror(1);
 		return;
@@ -2316,7 +2309,7 @@
 		return;
 	}
 
-	rc = sysctl(name, namelen, kd, &sz, NULL, 0);
+	rc = prog_sysctl(name, namelen, kd, &sz, NULL, 0);
 	if (rc == -1) {
 		sysctlerror(1);
 		return;
@@ -2371,7 +2364,7 @@
 	}
 
 	osz = sz;
-	rc = sysctl(name, namelen, cp_id, &osz, NULL, 0);
+	rc = prog_sysctl(name, namelen, cp_id, &osz, NULL, 0);
 	if (rc == -1) {
 		sysctlerror(1);
 		free(cp_id);
@@ -2428,7 +2421,7 @@
 	int rc;
 
 	sz = sizeof(loadavg);
-	rc = sysctl(name, namelen, &loadavg, &sz, NULL, 0);
+	rc = prog_sysctl(name, namelen, &loadavg, &sz, NULL, 0);
 	if (rc == -1) {
 		sysctlerror(1);
 		return;
@@ -2482,7 +2475,7 @@
 		newp = NULL;
 	}
 
-	rc = sysctl(name, namelen, &olim, &osz, newp, nsz);
+	rc = prog_sysctl(name, namelen, &olim, &osz, newp, nsz);
 	if (rc == -1) {
 		sysctlerror(newp == NULL);
 		return;
@@ -2520,7 +2513,7 @@
 	size_t sz;
 	uint i, b, lim;
 
-	rc = sysctl(name, namelen, NULL, &sz, NULL, 0);
+	rc = prog_sysctl(name, namelen, NULL, &sz, NULL, 0);
 	if (rc == -1) {
 		sysctlerror(1);
 		return;
@@ -2530,7 +2523,7 @@
 		sysctlerror(1);
 		return;
 	}
-	rc = sysctl(name, namelen, dl, &sz, NULL, 0);
+	rc = prog_sysctl(name, namelen, dl, &sz, NULL, 0);
 	if (rc == -1) {
 		sysctlerror(1);
 		return;
@@ -2590,7 +2583,7 @@
 		nsz = sizeof(m);
 		newp = &m;
 		errno = 0;
-		rc = sysctl(name, namelen, &tt, &ttsz, NULL, 0);
+		rc = prog_sysctl(name, namelen, &tt, &ttsz, NULL, 0);
 		if (rc == -1) {
 			sysctlperror("%s: failed query\n", sname);
 			return;
@@ -2618,7 +2611,7 @@
 		newp = NULL;
 	}
 
-	rc = sysctl(name, namelen, &o, &osz, newp, nsz);
+	rc = prog_sysctl(name, namelen, &o, &osz, newp, nsz);
 	if (rc == -1) {
 		sysctlerror(newp == NULL);
 		return;

Added files:

Index: src/sbin/sysctl/prog_ops.h
diff -u /dev/null src/sbin/sysctl/prog_ops.h:1.1
--- /dev/null	Mon Dec 13 17:47:40 2010
+++ src/sbin/sysctl/prog_ops.h	Mon Dec 13 17:47:40 2010
@@ -0,0 +1,45 @@
+/*      $NetBSD: prog_ops.h,v 1.1 2010/12/13 17:47:40 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef _PROG_OPS_H_
+#define _PROG_OPS_H_
+
+#include <sys/types.h>
+
+struct prog_ops {
+	int (*op_init)(void);
+
+	int (*op_sysctl)(const int *, u_int, void *, size_t *,
+			 const void *, size_t);
+};
+extern const struct prog_ops prog_ops;
+
+#define prog_init prog_ops.op_init
+#define prog_sysctl prog_ops.op_sysctl
+
+#endif /* _PROG_OPS_H_ */
Index: src/sbin/sysctl/sysctl_hostops.c
diff -u /dev/null src/sbin/sysctl/sysctl_hostops.c:1.1
--- /dev/null	Mon Dec 13 17:47:40 2010
+++ src/sbin/sysctl/sysctl_hostops.c	Mon Dec 13 17:47:40 2010
@@ -0,0 +1,41 @@
+/*	$NetBSD: sysctl_hostops.c,v 1.1 2010/12/13 17:47:40 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: sysctl_hostops.c,v 1.1 2010/12/13 17:47:40 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include "prog_ops.h"
+
+const struct prog_ops prog_ops = {
+	.op_sysctl = sysctl,
+};
Index: src/sbin/sysctl/sysctl_rumpops.c
diff -u /dev/null src/sbin/sysctl/sysctl_rumpops.c:1.1
--- /dev/null	Mon Dec 13 17:47:40 2010
+++ src/sbin/sysctl/sysctl_rumpops.c	Mon Dec 13 17:47:40 2010
@@ -0,0 +1,47 @@
+/*	$NetBSD: sysctl_rumpops.c,v 1.1 2010/12/13 17:47:40 pooka Exp $	*/
+
+/*
+ * Copyright (c) 2010 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <sys/cdefs.h>
+#ifndef lint
+__RCSID("$NetBSD: sysctl_rumpops.c,v 1.1 2010/12/13 17:47:40 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+#include <sys/sysctl.h>
+
+#include <rump/rump.h>
+#include <rump/rump_syscalls.h>
+#include <rump/rumpclient.h>
+
+#include "prog_ops.h"
+
+const struct prog_ops prog_ops = {
+	.op_init =	rumpclient_init,
+
+	.op_sysctl =	rump_sys___sysctl,
+};

Reply via email to