Source-Changes-HG archive

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

[src/trunk]: src/sbin Add rump client support for module utilities. It shoul...



details:   https://anonhg.NetBSD.org/src/rev/657bb3e8a550
branches:  trunk
changeset: 759614:657bb3e8a550
user:      pooka <pooka%NetBSD.org@localhost>
date:      Mon Dec 13 20:48:44 2010 +0000

description:
Add rump client support for module utilities.  It should be noted
that while modstat and modunload and builtin modules work exactly
the same as in the host case, modload loads file system kernel
modules from the rump kernel namespace.  By default, archs which
have rump support for the kernel kernel ABI have the host module
directory mapped into the rump kernel namespace at the same location
(/stand/...).  Therefore, if the *host* module directory is populated,
"rump.modload foo" will work as expected.  Otherwise, RUMP_MODULEBASE
can be used to point to the module directory.

diffstat:

 sbin/modload/Makefile              |   4 +-
 sbin/modload/main.c                |  10 +++++--
 sbin/modload/modload_hostops.c     |  41 +++++++++++++++++++++++++++++++++
 sbin/modload/modload_rumpops.c     |  47 ++++++++++++++++++++++++++++++++++++++
 sbin/modload/prog_ops.h            |  44 +++++++++++++++++++++++++++++++++++
 sbin/modstat/Makefile              |   4 +-
 sbin/modstat/main.c                |  11 ++++++--
 sbin/modstat/modstat_hostops.c     |  41 +++++++++++++++++++++++++++++++++
 sbin/modstat/modstat_rumpops.c     |  47 ++++++++++++++++++++++++++++++++++++++
 sbin/modstat/prog_ops.h            |  44 +++++++++++++++++++++++++++++++++++
 sbin/modunload/Makefile            |   4 +-
 sbin/modunload/main.c              |  11 ++++++--
 sbin/modunload/modunload_hostops.c |  41 +++++++++++++++++++++++++++++++++
 sbin/modunload/modunload_rumpops.c |  47 ++++++++++++++++++++++++++++++++++++++
 sbin/modunload/prog_ops.h          |  44 +++++++++++++++++++++++++++++++++++
 15 files changed, 425 insertions(+), 15 deletions(-)

diffs (truncated from 595 to 300 lines):

diff -r 47e19fa0a5ec -r 657bb3e8a550 sbin/modload/Makefile
--- a/sbin/modload/Makefile     Mon Dec 13 19:39:37 2010 +0000
+++ b/sbin/modload/Makefile     Mon Dec 13 20:48:44 2010 +0000
@@ -1,8 +1,8 @@
-#      $NetBSD: Makefile,v 1.14 2008/11/12 12:35:53 ad Exp $
+#      $NetBSD: Makefile,v 1.15 2010/12/13 20:48:44 pooka Exp $
 
 .include <bsd.own.mk>
 
-PROG=  modload
+RUMPPRG=modload
 SRCS=  main.c
 MAN=   modload.8
 LDADD= -lprop
diff -r 47e19fa0a5ec -r 657bb3e8a550 sbin/modload/main.c
--- a/sbin/modload/main.c       Mon Dec 13 19:39:37 2010 +0000
+++ b/sbin/modload/main.c       Mon Dec 13 20:48:44 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.13 2009/06/11 08:12:00 wiz Exp $    */
+/*     $NetBSD: main.c,v 1.14 2010/12/13 20:48:44 pooka Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.13 2009/06/11 08:12:00 wiz Exp $");
+__RCSID("$NetBSD: main.c,v 1.14 2010/12/13 20:48:44 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/module.h>
@@ -44,6 +44,8 @@
 
 #include <prop/proplib.h>
 
+#include "prog_ops.h"
+
 int            main(int, char **);
 static void    parse_bool_param(prop_dictionary_t, const char *,
                                 const char *);
@@ -160,12 +162,14 @@
        } else {
                if (argc != 1)
                        usage();
+               if (prog_init && prog_init() == -1)
+                       err(1, "prog init failed");
                cmdargs.ml_filename = argv[0];
                cmdargs.ml_flags = flags;
                cmdargs.ml_props = propsstr;
                cmdargs.ml_propslen = strlen(propsstr);
 
-               if (modctl(MODCTL_LOAD, &cmdargs)) {
+               if (prog_modctl(MODCTL_LOAD, &cmdargs)) {
                        err(EXIT_FAILURE, NULL);
                }
        }
diff -r 47e19fa0a5ec -r 657bb3e8a550 sbin/modload/modload_hostops.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/modload/modload_hostops.c    Mon Dec 13 20:48:44 2010 +0000
@@ -0,0 +1,41 @@
+/*     $NetBSD: modload_hostops.c,v 1.1 2010/12/13 20:48:44 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: modload_hostops.c,v 1.1 2010/12/13 20:48:44 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+#include <sys/module.h>
+
+#include "prog_ops.h"
+
+const struct prog_ops prog_ops = {
+       .op_modctl = modctl,
+};
diff -r 47e19fa0a5ec -r 657bb3e8a550 sbin/modload/modload_rumpops.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/modload/modload_rumpops.c    Mon Dec 13 20:48:44 2010 +0000
@@ -0,0 +1,47 @@
+/*     $NetBSD: modload_rumpops.c,v 1.1 2010/12/13 20:48:44 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: modload_rumpops.c,v 1.1 2010/12/13 20:48:44 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+#include <sys/module.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_modctl =    rump_sys_modctl,
+};
diff -r 47e19fa0a5ec -r 657bb3e8a550 sbin/modload/prog_ops.h
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/modload/prog_ops.h   Mon Dec 13 20:48:44 2010 +0000
@@ -0,0 +1,44 @@
+/*      $NetBSD: prog_ops.h,v 1.1 2010/12/13 20:48:44 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_modctl)(int, void *);
+};
+extern const struct prog_ops prog_ops;
+
+#define prog_init prog_ops.op_init
+#define prog_modctl prog_ops.op_modctl
+
+#endif /* _PROG_OPS_H_ */
diff -r 47e19fa0a5ec -r 657bb3e8a550 sbin/modstat/Makefile
--- a/sbin/modstat/Makefile     Mon Dec 13 19:39:37 2010 +0000
+++ b/sbin/modstat/Makefile     Mon Dec 13 20:48:44 2010 +0000
@@ -1,6 +1,6 @@
-#      $NetBSD: Makefile,v 1.1 2008/01/16 12:34:57 ad Exp $
+#      $NetBSD: Makefile,v 1.2 2010/12/13 20:48:45 pooka Exp $
 
-PROG=  modstat
+RUMPPRG=modstat
 SRCS=  main.c
 MAN=   modstat.8
 
diff -r 47e19fa0a5ec -r 657bb3e8a550 sbin/modstat/main.c
--- a/sbin/modstat/main.c       Mon Dec 13 19:39:37 2010 +0000
+++ b/sbin/modstat/main.c       Mon Dec 13 20:48:44 2010 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: main.c,v 1.10 2010/03/19 16:25:33 pooka Exp $  */
+/*     $NetBSD: main.c,v 1.11 2010/12/13 20:48:45 pooka Exp $  */
 
 /*-
  * Copyright (c) 2008 The NetBSD Foundation, Inc.
@@ -28,7 +28,7 @@
 
 #include <sys/cdefs.h>
 #ifndef lint
-__RCSID("$NetBSD: main.c,v 1.10 2010/03/19 16:25:33 pooka Exp $");
+__RCSID("$NetBSD: main.c,v 1.11 2010/12/13 20:48:45 pooka Exp $");
 #endif /* !lint */
 
 #include <sys/module.h>
@@ -39,6 +39,8 @@
 #include <unistd.h>
 #include <err.h>
 
+#include "prog_ops.h"
+
 int    main(int, char **);
 static void    usage(void) __dead;
 static int     modstatcmp(const void *, const void *);
@@ -88,10 +90,13 @@
        if (argc != 0)
                usage();
 
+       if (prog_init && prog_init() == -1)
+               err(1, "prog init failed");
+
        for (len = 8192;;) {
                iov.iov_base = malloc(len);
                iov.iov_len = len;
-               if (modctl(MODCTL_STAT, &iov)) {
+               if (prog_modctl(MODCTL_STAT, &iov)) {
                        err(EXIT_FAILURE, "modctl(MODCTL_STAT)");
                }
                if (len >= iov.iov_len) {
diff -r 47e19fa0a5ec -r 657bb3e8a550 sbin/modstat/modstat_hostops.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/sbin/modstat/modstat_hostops.c    Mon Dec 13 20:48:44 2010 +0000
@@ -0,0 +1,41 @@
+/*     $NetBSD: modstat_hostops.c,v 1.1 2010/12/13 20:48:45 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: modstat_hostops.c,v 1.1 2010/12/13 20:48:45 pooka Exp $");
+#endif /* !lint */
+
+#include <sys/types.h>
+#include <sys/module.h>
+
+#include "prog_ops.h"
+
+const struct prog_ops prog_ops = {
+       .op_modctl = modctl,
+};



Home | Main Index | Thread Index | Old Index