Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/envstat RUMP_ACTION -> RUMPPRG



details:   https://anonhg.NetBSD.org/src/rev/f9171bdcf60e
branches:  trunk
changeset: 759605:f9171bdcf60e
user:      pooka <pooka%NetBSD.org@localhost>
date:      Mon Dec 13 18:00:38 2010 +0000

description:
RUMP_ACTION -> RUMPPRG

diffstat:

 usr.sbin/envstat/Makefile          |  11 +-------
 usr.sbin/envstat/envstat.c         |  37 +++++++++-------------------
 usr.sbin/envstat/envstat_hostops.c |  46 ++++++++++++++++++++++++++++++++++++
 usr.sbin/envstat/envstat_rumpops.c |  48 ++++++++++++++++++++++++++++++++++++++
 usr.sbin/envstat/prog_ops.h        |  48 ++++++++++++++++++++++++++++++++++++++
 5 files changed, 156 insertions(+), 34 deletions(-)

diffs (291 lines):

diff -r fb518fbdd9e8 -r f9171bdcf60e usr.sbin/envstat/Makefile
--- a/usr.sbin/envstat/Makefile Mon Dec 13 17:51:39 2010 +0000
+++ b/usr.sbin/envstat/Makefile Mon Dec 13 18:00:38 2010 +0000
@@ -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>
diff -r fb518fbdd9e8 -r f9171bdcf60e usr.sbin/envstat/envstat.c
--- a/usr.sbin/envstat/envstat.c        Mon Dec 13 17:51:39 2010 +0000
+++ b/usr.sbin/envstat/envstat.c        Mon Dec 13 18:00:38 2010 +0000
@@ -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;
diff -r fb518fbdd9e8 -r f9171bdcf60e usr.sbin/envstat/envstat_hostops.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/envstat/envstat_hostops.c        Mon Dec 13 18:00:38 2010 +0000
@@ -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,
+};
diff -r fb518fbdd9e8 -r f9171bdcf60e usr.sbin/envstat/envstat_rumpops.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/envstat/envstat_rumpops.c        Mon Dec 13 18:00:38 2010 +0000
@@ -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,
+};
diff -r fb518fbdd9e8 -r f9171bdcf60e usr.sbin/envstat/prog_ops.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/usr.sbin/envstat/prog_ops.h       Mon Dec 13 18:00:38 2010 +0000
@@ -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_ */



Home | Main Index | Thread Index | Old Index