qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] sysctl
@ 2004-04-06 10:01 Timo Savola
  0 siblings, 0 replies; only message in thread
From: Timo Savola @ 2004-04-06 10:01 UTC (permalink / raw)
  To: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 612 bytes --]

Hello,

Since the user-mode qemu doesn't support sysctl (syscall 149) and
linuxthreads uses it to check kernel/version, some programs fail.  sysctl
is an obsolete syscall and seems like a big job to support since you'd
have to know what kind of data goes in and out with each parameter, so
I'm not surprised why it's not supported.  However, implementing only the
kernel/version case seems worthwhile.  I tested this patch with qemu-arm
and it seems to help.

Extending this patch to implement all cases that copy string (or integer)
values would be straightforward, but I wanted to keep the patch simple.

Timo

[-- Attachment #2: sysctl.patch --]
[-- Type: text/plain, Size: 1575 bytes --]

--- qemu-0.5.3/linux-user/syscall.c.orig	2004-04-06 12:07:48.000000000 +0300
+++ qemu-0.5.3/linux-user/syscall.c	2004-04-06 12:15:07.000000000 +0300
@@ -46,6 +46,7 @@
 //#include <sys/user.h>
 #include <netinet/ip.h>
 #include <netinet/tcp.h>
+#include <sys/sysctl.h>
 
 #define termios host_termios
 #define winsize host_winsize
@@ -2565,7 +2566,31 @@
         ret = get_errno(fdatasync(arg1));
         break;
     case TARGET_NR__sysctl:
-        goto unimplemented;
+        {
+            struct __sysctl_args *args = (struct __sysctl_args *) arg1;
+            int *name, nlen, *oldlenp, oldlen, newlen;
+            void *oldval, *newval;
+
+            name = (int *) tswapl((long) args->name);
+            nlen = tswapl(args->nlen);
+            oldval = (void *) tswapl((long) args->oldval);
+            oldlenp = (int *) tswapl((long) args->oldlenp);
+            oldlen = tswapl(*oldlenp);
+            newval = (void *) tswapl((long) args->newval);
+            newlen = tswapl(args->newlen);
+
+            if (nlen == 2 && name[0] == CTL_KERN && name[1] == KERN_VERSION) {
+                ret = get_errno(
+                        sysctl(name, nlen, oldval, &oldlen, newval, newlen));
+                if (!is_error(ret)) {
+                    *oldlenp = tswapl(oldlen);
+                }
+            } else {
+                gemu_log("qemu: Unsupported sysctl name\n");
+                ret = -ENOSYS;
+            }
+        }
+        break;
     case TARGET_NR_sched_setparam:
         {
             struct sched_param *target_schp = (void *)arg2;

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2004-04-06 10:01 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2004-04-06 10:01 [Qemu-devel] [PATCH] sysctl Timo Savola

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).