Requery syscall handlers during rump kernel init. This fixes

syscalls provided by a rump faction such as rumpvfs when the library
is not linked into the binary, but is dlopen()'d before calling
rump_init().
(it is illegal to dlopen() a faction after rump_init(), but syscalls
maybe be added the usual way with modules)

rump_server(1) -lstuff works now.
This commit is contained in:
pooka 2010-12-30 16:46:32 +00:00
parent 4513e431d6
commit 9b98cb6805
1 changed files with 31 additions and 2 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: rump.c,v 1.212 2010/12/16 12:38:20 pooka Exp $ */
/* $NetBSD: rump.c,v 1.213 2010/12/30 16:46:32 pooka Exp $ */
/*
* Copyright (c) 2007 Antti Kantee. All Rights Reserved.
@ -28,7 +28,7 @@
*/
#include <sys/cdefs.h>
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.212 2010/12/16 12:38:20 pooka Exp $");
__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.213 2010/12/30 16:46:32 pooka Exp $");
#include <sys/systm.h>
#define ELFSIZE ARCH_ELFSIZE
@ -440,6 +440,35 @@ rump__init(int rump_version)
if (initproc == NULL)
panic("where in the world is initproc?");
/*
* Adjust syscall vector in case factions were dlopen()'d
* before calling rump_init().
* (modules will handle dynamic syscalls the usual way)
*
* Note: this will adjust the function vectors of
* syscalls which use a funcalias (getpid etc.), but
* it makes no difference.
*/
for (i = 0; i < SYS_NSYSENT; i++) {
void *sym;
if (rump_sysent[i].sy_flags & SYCALL_NOSYS ||
*syscallnames[i] == '#' ||
rump_sysent[i].sy_call == sys_nomodule)
continue;
/* if present, adjust symbol value */
sprintf(buf, "rumpns_sys_%s", syscallnames[i]);
if ((sym = rumpuser_dl_globalsym(buf)) != NULL
&& sym != rump_sysent[i].sy_call) {
#if 0
rumpuser_dprintf("adjusting %s: %p (old %p)\n",
syscallnames[i], sym, rump_sysent[i].sy_call);
#endif
rump_sysent[i].sy_call = sym;
}
}
/* release cpu */
rump_unschedule();