Module Name:    src
Committed By:   pooka
Date:           Mon Dec 13 18:00:39 UTC 2010

Modified Files:
        src/usr.sbin/envstat: Makefile envstat.c
Added Files:
        src/usr.sbin/envstat: envstat_hostops.c envstat_rumpops.c prog_ops.h

Log Message:
RUMP_ACTION -> RUMPPRG


To generate a diff of this commit:
cvs rdiff -u -r1.8 -r1.9 src/usr.sbin/envstat/Makefile
cvs rdiff -u -r1.82 -r1.83 src/usr.sbin/envstat/envstat.c
cvs rdiff -u -r0 -r1.1 src/usr.sbin/envstat/envstat_hostops.c \
    src/usr.sbin/envstat/envstat_rumpops.c src/usr.sbin/envstat/prog_ops.h

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

Modified files:

Index: src/usr.sbin/envstat/Makefile
diff -u src/usr.sbin/envstat/Makefile:1.8 src/usr.sbin/envstat/Makefile:1.9
--- src/usr.sbin/envstat/Makefile:1.8	Fri Nov  5 13:42:37 2010
+++ src/usr.sbin/envstat/Makefile	Mon Dec 13 18:00:38 2010
@@ -1,6 +1,6 @@
-# $NetBSD: Makefile,v 1.8 2010/11/05 13:42:37 pooka Exp $
+# $NetBSD: Makefile,v 1.9 2010/12/13 18:00:38 pooka Exp $
 
-PROG=		envstat
+RUMPPRG=	envstat
 SRCS+=		envstat.c config.c config_yacc.y config_lex.l
 
 LDADD=		-lprop
@@ -12,11 +12,4 @@
 
 YHEADER=	yes
 
-.ifdef RUMP_ACTION
-LDADD+=		-lrumpclient
-CPPFLAGS+=	-DRUMP_SYS_OPEN -DRUMP_SYS_CLOSE
-CPPFLAGS+=	-DRUMP_ACTION
-DBG=		-g
-.endif
-
 .include <bsd.prog.mk>

Index: src/usr.sbin/envstat/envstat.c
diff -u src/usr.sbin/envstat/envstat.c:1.82 src/usr.sbin/envstat/envstat.c:1.83
--- src/usr.sbin/envstat/envstat.c:1.82	Fri Nov  5 13:52:42 2010
+++ src/usr.sbin/envstat/envstat.c	Mon Dec 13 18:00:38 2010
@@ -1,4 +1,4 @@
-/* $NetBSD: envstat.c,v 1.82 2010/11/05 13:52:42 pooka Exp $ */
+/* $NetBSD: envstat.c,v 1.83 2010/12/13 18:00:38 pooka Exp $ */
 
 /*-
  * Copyright (c) 2007, 2008 Juan Romero Pardines.
@@ -27,7 +27,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: envstat.c,v 1.82 2010/11/05 13:52:42 pooka Exp $");
+__RCSID("$NetBSD: envstat.c,v 1.83 2010/12/13 18:00:38 pooka Exp $");
 #endif /* not lint */
 
 #include <stdio.h>
@@ -48,12 +48,7 @@
 #include <prop/proplib.h>
 
 #include "envstat.h"
-
-#ifdef RUMP_ACTION
-#include <rump/rump.h>
-#include <rump/rumpclient.h>
-#include <rump/rump_syscalls.h>
-#endif
+#include "prog_ops.h"
 
 #define ENVSYS_DFLAG	0x00000001	/* list registered devices */
 #define ENVSYS_FFLAG	0x00000002	/* show temp in farenheit */
@@ -123,8 +118,6 @@
 static int		sysmonfd; /* fd of /dev/sysmon */
 
 /* sneak in between ioctl() */
-#ifdef RUMP_ACTION
-#include <sys/syscall.h>
 int
 ioctl(int fd, unsigned long request, ...)
 {
@@ -132,15 +125,11 @@
 	int rv;
 
 	va_start(ap, request);
-	if (fd == sysmonfd)
-		rv = rump_sys_ioctl(fd, request, va_arg(ap, void *));
-	else
-		rv = syscall(SYS_ioctl, fd, request, va_arg(ap, void *));
+	rv = prog_ioctl(fd, request, va_arg(ap, void *));
 	va_end(ap);
 
 	return rv;
 }
-#endif
 
 int main(int argc, char **argv)
 {
@@ -149,10 +138,8 @@
 	char *endptr, *configfile = NULL;
 	FILE *cf;
 
-#ifdef RUMP_ACTION
-	if (rumpclient_init() == -1)
-		err(1, "rumpclient init failed");
-#endif
+	if (prog_init && prog_init() == -1)
+		err(1, "init failed");
 
 	setprogname(argv[0]);
 
@@ -241,7 +228,7 @@
 		errx(EXIT_FAILURE, "-d flag cannot be used with -s");
 
 	/* Open the device in ro mode */
-	if ((sysmonfd = open(_PATH_SYSMON, O_RDONLY)) == -1)
+	if ((sysmonfd = prog_open(_PATH_SYSMON, O_RDONLY)) == -1)
 		err(EXIT_FAILURE, "%s", _PATH_SYSMON);
 
 	/* Print dictionary in raw mode */
@@ -257,10 +244,10 @@
 	/* Remove all properties set in dictionary */
 	} else if (flags & ENVSYS_SFLAG) {
 		/* Close the ro descriptor */
-		(void)close(sysmonfd);
+		(void)prog_close(sysmonfd);
 
 		/* open the fd in rw mode */
-		if ((sysmonfd = open(_PATH_SYSMON, O_RDWR)) == -1)
+		if ((sysmonfd = prog_open(_PATH_SYSMON, O_RDWR)) == -1)
 			err(EXIT_FAILURE, "%s", _PATH_SYSMON);
 
 		dict = prop_dictionary_create();
@@ -311,7 +298,7 @@
 		free(sensors);
 	if (mydevname)
 		free(mydevname);
-	(void)close(sysmonfd);
+	(void)prog_close(sysmonfd);
 
 	return rval ? EXIT_FAILURE : EXIT_SUCCESS;
 }
@@ -338,8 +325,8 @@
 	/*
 	 * Close the read only descriptor and open a new one read write.
 	 */
-	(void)close(sysmonfd);
-	if ((sysmonfd = open(_PATH_SYSMON, O_RDWR)) == -1) {
+	(void)prog_close(sysmonfd);
+	if ((sysmonfd = prog_open(_PATH_SYSMON, O_RDWR)) == -1) {
 		error = errno;
 		warn("%s", _PATH_SYSMON);
 		return error;

Added files:

Index: src/usr.sbin/envstat/envstat_hostops.c
diff -u /dev/null src/usr.sbin/envstat/envstat_hostops.c:1.1
--- /dev/null	Mon Dec 13 18:00:39 2010
+++ src/usr.sbin/envstat/envstat_hostops.c	Mon Dec 13 18:00:38 2010
@@ -0,0 +1,46 @@
+/*	$NetBSD: envstat_hostops.c,v 1.1 2010/12/13 18:00:38 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: envstat_hostops.c,v 1.1 2010/12/13 18:00:38 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+#include <sys/ioctl.h>
+
+#include <fcntl.h>
+#include <unistd.h>
+
+#include "prog_ops.h"
+
+const struct prog_ops prog_ops = {
+	.op_open = open,
+	.op_close = close,
+	.op_ioctl = ioctl,
+};
Index: src/usr.sbin/envstat/envstat_rumpops.c
diff -u /dev/null src/usr.sbin/envstat/envstat_rumpops.c:1.1
--- /dev/null	Mon Dec 13 18:00:39 2010
+++ src/usr.sbin/envstat/envstat_rumpops.c	Mon Dec 13 18:00:38 2010
@@ -0,0 +1,48 @@
+/*	$NetBSD: envstat_rumpops.c,v 1.1 2010/12/13 18:00:38 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: envstat_rumpops.c,v 1.1 2010/12/13 18:00:38 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.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_open =	rump_sys_open,
+	.op_close =	rump_sys_close,
+	.op_ioctl =	rump_sys_ioctl,
+};
Index: src/usr.sbin/envstat/prog_ops.h
diff -u /dev/null src/usr.sbin/envstat/prog_ops.h:1.1
--- /dev/null	Mon Dec 13 18:00:39 2010
+++ src/usr.sbin/envstat/prog_ops.h	Mon Dec 13 18:00:38 2010
@@ -0,0 +1,48 @@
+/*      $NetBSD: prog_ops.h,v 1.1 2010/12/13 18:00:38 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_open)(const char *, int, ...);
+	int (*op_close)(int);
+	int (*op_ioctl)(int, unsigned long, ...);
+};
+extern const struct prog_ops prog_ops;
+
+#define prog_init prog_ops.op_init
+#define prog_open prog_ops.op_open
+#define prog_close prog_ops.op_close
+#define prog_ioctl prog_ops.op_ioctl
+
+#endif /* _PROG_OPS_H_ */

Reply via email to