Module Name: src Committed By: pooka Date: Mon Dec 13 14:13:22 UTC 2010
Modified Files: src/usr.bin/rump_allserver: rump_allserver.c Log Message: 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). To generate a diff of this commit: cvs rdiff -u -r1.6 -r1.7 src/usr.bin/rump_allserver/rump_allserver.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/usr.bin/rump_allserver/rump_allserver.c diff -u src/usr.bin/rump_allserver/rump_allserver.c:1.6 src/usr.bin/rump_allserver/rump_allserver.c:1.7 --- src/usr.bin/rump_allserver/rump_allserver.c:1.6 Mon Dec 13 13:32:25 2010 +++ src/usr.bin/rump_allserver/rump_allserver.c Mon Dec 13 14:13:21 2010 @@ -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");