Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/rump/librump/rumpkern Fix syscall name for compat syscal...



details:   https://anonhg.NetBSD.org/src/rev/c76e2c10e33c
branches:  trunk
changeset: 761440:c76e2c10e33c
user:      pooka <pooka%NetBSD.org@localhost>
date:      Thu Jan 27 17:36:27 2011 +0000

description:
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.

diffstat:

 sys/rump/librump/rumpkern/rump.c |  38 ++++++++++++++++++++++++++++++++++----
 1 files changed, 34 insertions(+), 4 deletions(-)

diffs (59 lines):

diff -r 8a97e8806d38 -r c76e2c10e33c sys/rump/librump/rumpkern/rump.c
--- a/sys/rump/librump/rumpkern/rump.c  Thu Jan 27 16:13:51 2011 +0000
+++ b/sys/rump/librump/rumpkern/rump.c  Thu Jan 27 17:36:27 2011 +0000
@@ -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



Home | Main Index | Thread Index | Old Index