Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/rump_allserver Add -m which can be used to load modu...
details: https://anonhg.NetBSD.org/src/rev/d61777fd8d75
branches: trunk
changeset: 759592:d61777fd8d75
user: pooka <pooka%NetBSD.org@localhost>
date: Mon Dec 13 14:13:21 2010 +0000
description:
Add -m which can be used to load modules (which is a completely
different code path than using dlopen() before rump_init(), since
the former uses the in-kernel linker and the latter links the object
in rtld).
So:
golem> ./rump_server -l librumpvfs.so -m /sys/modules/tmpfs/tmpfs.kmod unix:///tmp/commsuck
==>
golem> env RUMP_SERVER=unix:///tmp/commsuck rump.modstat
NAME CLASS SOURCE REFS SIZE REQUIRES
suser secmodel builtin 0 - -
tmpfs vfs filesys 0 16713 -
wapbl vfs builtin 0 - -
Source is filesys instead of builtin, as expected.
Notably, for -m you *must* use -l librumpvfs.so. This is because
you need VFS in your kernel to be able to load modules from the
file system. In a regular kernel "librumpvfs.so" is linked at
kernel build time and loaded by the bootloader. Here we use dlopen()
for both effects (the other choices would have been to link
rump_server with -lrumpvfs, but that would limit the flexibility,
or link tmpfs.kmod directly into the binary, but that would limit
the flexibility even more).
diffstat:
usr.bin/rump_allserver/rump_allserver.c | 34 ++++++++++++++++++++++++++++++--
1 files changed, 31 insertions(+), 3 deletions(-)
diffs (78 lines):
diff -r ac86f0ee2734 -r d61777fd8d75 usr.bin/rump_allserver/rump_allserver.c
--- a/usr.bin/rump_allserver/rump_allserver.c Mon Dec 13 14:03:59 2010 +0000
+++ b/usr.bin/rump_allserver/rump_allserver.c Mon Dec 13 14:13:21 2010 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: rump_allserver.c,v 1.6 2010/12/13 13:32:25 pooka Exp $ */
+/* $NetBSD: rump_allserver.c,v 1.7 2010/12/13 14:13:21 pooka Exp $ */
/*-
* Copyright (c) 2010 Antti Kantee. All Rights Reserved.
@@ -27,11 +27,12 @@
#include <sys/cdefs.h>
#ifndef lint
-__RCSID("$NetBSD: rump_allserver.c,v 1.6 2010/12/13 13:32:25 pooka Exp $");
+__RCSID("$NetBSD: rump_allserver.c,v 1.7 2010/12/13 14:13:21 pooka Exp $");
#endif /* !lint */
#include <sys/types.h>
#include <sys/signal.h>
+#include <sys/module.h>
#include <rump/rump.h>
#include <rump/rump_syscalls.h>
@@ -75,19 +76,31 @@
main(int argc, char *argv[])
{
const char *serverurl;
+ char **modarray = NULL;
+ unsigned nmods = 0, curmod = 0, i;
int error;
int ch, sflag;
setprogname(argv[0]);
sflag = 0;
- while ((ch = getopt(argc, argv, "l:s")) != -1) {
+ while ((ch = getopt(argc, argv, "l:m:s")) != -1) {
switch (ch) {
case 'l':
if (dlopen(optarg, RTLD_LAZY|RTLD_GLOBAL) == NULL)
errx(1, "dlopen %s failed: %s",
optarg, dlerror());
break;
+ case 'm':
+ if (nmods - curmod == 0) {
+ modarray = realloc(modarray,
+ (nmods+16) * sizeof(char *));
+ if (modarray == NULL)
+ err(1, "realloc");
+ nmods += 16;
+ }
+ modarray[curmod++] = optarg;
+ break;
case 's':
sflag = 1;
break;
@@ -114,6 +127,21 @@
error = rump_init();
if (error)
die(sflag, error, "rump init failed");
+
+ for (i = 0; i < curmod; i++) {
+ struct modctl_load ml;
+
+#define ETFSKEY "/module.mod"
+ if ((error = rump_pub_etfs_register(ETFSKEY,
+ modarray[0], RUMP_ETFS_REG)) != 0)
+ die(sflag, error, "module etfs register failed");
+ memset(&ml, 0, sizeof(ml));
+ ml.ml_filename = ETFSKEY;
+ if (rump_sys_modctl(MODCTL_LOAD, &ml) == -1)
+ die(sflag, errno, "module load failed");
+ rump_pub_etfs_remove(ETFSKEY);
+ }
+
error = rump_init_server(serverurl);
if (error)
die(sflag, error, "rump server init failed");
Home |
Main Index |
Thread Index |
Old Index