Module Name:    src
Committed By:   pooka
Date:           Thu Jan 27 17:36:27 UTC 2011

Modified Files:
        src/sys/rump/librump/rumpkern: rump.c

Log Message:
Fix syscall name for compat syscalls.  Arguably makesyscalls.sh
should generate the right info, but it's easier to fix here now.

This fixes compat syscalls for rump servers with dynamically loaded
components.  Since the compat syscall revamp a little time ago e.g.
stat() didn't work on my system (which is 5.0-based) with e.g.
rump_server -lrumpvfs.  Static servers and non-compat syscalls
worked just fine, though, making this a little harder to spot that
the usual bug.


To generate a diff of this commit:
cvs rdiff -u -r1.221 -r1.222 src/sys/rump/librump/rumpkern/rump.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/rump/librump/rumpkern/rump.c
diff -u src/sys/rump/librump/rumpkern/rump.c:1.221 src/sys/rump/librump/rumpkern/rump.c:1.222
--- src/sys/rump/librump/rumpkern/rump.c:1.221	Sat Jan 22 18:33:25 2011
+++ src/sys/rump/librump/rumpkern/rump.c	Thu Jan 27 17:36:27 2011
@@ -1,4 +1,4 @@
-/*	$NetBSD: rump.c,v 1.221 2011/01/22 18:33:25 pooka Exp $	*/
+/*	$NetBSD: rump.c,v 1.222 2011/01/27 17:36:27 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.221 2011/01/22 18:33:25 pooka Exp $");
+__KERNEL_RCSID(0, "$NetBSD: rump.c,v 1.222 2011/01/27 17:36:27 pooka Exp $");
 
 #include <sys/systm.h>
 #define ELFSIZE ARCH_ELFSIZE
@@ -469,8 +469,38 @@
 		    rump_sysent[i].sy_call == sys_nomodule)
 			continue;
 
-		/* if present, adjust symbol value */
-		sprintf(buf, "rumpns_sys_%s", syscallnames[i]);
+		/*
+		 * deal with compat wrappers.  makesyscalls.sh should
+		 * generate the necessary info instead of this hack,
+		 * though.  ugly, fix it later.
+		 */ 
+#define CPFX "compat_"
+#define CPFXLEN (sizeof(CPFX)-1)
+		if (strncmp(syscallnames[i], CPFX, CPFXLEN) == 0) {
+			const char *p = syscallnames[i] + CPFXLEN;
+			size_t namelen;
+
+			/* skip version number */
+			while (*p >= '0' && *p <= '9')
+				p++;
+			if (p == syscallnames[i] + CPFXLEN || *p != '_')
+				panic("invalid syscall name %s\n",
+				    syscallnames[i]);
+
+			/* skip over the next underscore */
+			p++;
+			namelen = p + (sizeof("rumpns_")-1) - syscallnames[i];
+
+			strcpy(buf, "rumpns_");
+			strcat(buf, syscallnames[i]);
+			/* XXX: no strncat in the kernel */
+			strcpy(buf+namelen, "sys_");
+			strcat(buf, p);
+#undef CPFX
+#undef CPFXLEN
+		} else {
+			sprintf(buf, "rumpns_sys_%s", syscallnames[i]);
+		}
 		if ((sym = rumpuser_dl_globalsym(buf)) != NULL
 		    && sym != rump_sysent[i].sy_call) {
 #if 0

Reply via email to