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.
This commit is contained in:
parent
759b07d20a
commit
e73ffdda13
@ -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
|
||||
|
@ -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 @@ __RCSID("$NetBSD: main.c,v 1.13 2009/06/11 08:12:00 wiz Exp $");
|
||||
|
||||
#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 @@ main(int argc, char **argv)
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
41
sbin/modload/modload_hostops.c
Normal file
41
sbin/modload/modload_hostops.c
Normal file
@ -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,
|
||||
};
|
47
sbin/modload/modload_rumpops.c
Normal file
47
sbin/modload/modload_rumpops.c
Normal file
@ -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,
|
||||
};
|
44
sbin/modload/prog_ops.h
Normal file
44
sbin/modload/prog_ops.h
Normal file
@ -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_ */
|
@ -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
|
||||
|
||||
|
@ -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 @@ __RCSID("$NetBSD: main.c,v 1.10 2010/03/19 16:25:33 pooka Exp $");
|
||||
#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 @@ main(int argc, char **argv)
|
||||
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) {
|
||||
|
41
sbin/modstat/modstat_hostops.c
Normal file
41
sbin/modstat/modstat_hostops.c
Normal file
@ -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,
|
||||
};
|
47
sbin/modstat/modstat_rumpops.c
Normal file
47
sbin/modstat/modstat_rumpops.c
Normal file
@ -0,0 +1,47 @@
|
||||
/* $NetBSD: modstat_rumpops.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_rumpops.c,v 1.1 2010/12/13 20:48:45 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,
|
||||
};
|
44
sbin/modstat/prog_ops.h
Normal file
44
sbin/modstat/prog_ops.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* $NetBSD: prog_ops.h,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.
|
||||
*/
|
||||
|
||||
#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_ */
|
@ -1,6 +1,6 @@
|
||||
# $NetBSD: Makefile,v 1.13 2008/11/12 12:35:53 ad Exp $
|
||||
# $NetBSD: Makefile,v 1.14 2010/12/13 20:48:45 pooka Exp $
|
||||
|
||||
PROG= modunload
|
||||
RUMPPRG=modunload
|
||||
SRCS= main.c
|
||||
MAN= modunload.8
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
/* $NetBSD: main.c,v 1.3 2010/12/06 23:42:48 jmcneill Exp $ */
|
||||
/* $NetBSD: main.c,v 1.4 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.3 2010/12/06 23:42:48 jmcneill Exp $");
|
||||
__RCSID("$NetBSD: main.c,v 1.4 2010/12/13 20:48:45 pooka Exp $");
|
||||
#endif /* !lint */
|
||||
|
||||
#include <sys/module.h>
|
||||
@ -39,6 +39,8 @@ __RCSID("$NetBSD: main.c,v 1.3 2010/12/06 23:42:48 jmcneill Exp $");
|
||||
#include <unistd.h>
|
||||
#include <err.h>
|
||||
|
||||
#include "prog_ops.h"
|
||||
|
||||
int main(int, char **);
|
||||
static void usage(void) __dead;
|
||||
|
||||
@ -50,8 +52,11 @@ main(int argc, char **argv)
|
||||
if (argc < 2)
|
||||
usage();
|
||||
|
||||
if (prog_init && prog_init() == -1)
|
||||
err(1, "init failed");
|
||||
|
||||
for (i = 1; i < argc; i++) {
|
||||
if (modctl(MODCTL_UNLOAD, argv[i])) {
|
||||
if (prog_modctl(MODCTL_UNLOAD, argv[i])) {
|
||||
err(EXIT_FAILURE, NULL);
|
||||
}
|
||||
}
|
||||
|
41
sbin/modunload/modunload_hostops.c
Normal file
41
sbin/modunload/modunload_hostops.c
Normal file
@ -0,0 +1,41 @@
|
||||
/* $NetBSD: modunload_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: modunload_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,
|
||||
};
|
47
sbin/modunload/modunload_rumpops.c
Normal file
47
sbin/modunload/modunload_rumpops.c
Normal file
@ -0,0 +1,47 @@
|
||||
/* $NetBSD: modunload_rumpops.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: modunload_rumpops.c,v 1.1 2010/12/13 20:48:45 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,
|
||||
};
|
44
sbin/modunload/prog_ops.h
Normal file
44
sbin/modunload/prog_ops.h
Normal file
@ -0,0 +1,44 @@
|
||||
/* $NetBSD: prog_ops.h,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.
|
||||
*/
|
||||
|
||||
#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_ */
|
Loading…
Reference in New Issue
Block a user