From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by monty-python.gnu.org with tmda-scanned (Exim 4.30) id 1BAnOw-0002zy-4z for qemu-devel@nongnu.org; Tue, 06 Apr 2004 06:01:50 -0400 Received: from mail by monty-python.gnu.org with spam-scanned (Exim 4.30) id 1BAnOO-0002sn-Oe for qemu-devel@nongnu.org; Tue, 06 Apr 2004 06:01:47 -0400 Received: from [62.236.252.195] (helo=sulkku.creanor.com) by monty-python.gnu.org with esmtp (TLSv1:DES-CBC3-SHA:168) (Exim 4.30) id 1BAnON-0002rf-PQ for qemu-devel@nongnu.org; Tue, 06 Apr 2004 06:01:16 -0400 Received: from creanor.com (helufile.hel.creanor.com [172.16.6.5]) (using TLSv1 with cipher EDH-RSA-DES-CBC3-SHA (168/168 bits)) (Client CN "smtp.hel.creanor.com", Issuer "Movial Server CA" (verified OK)) by sulkku.creanor.com (Postfix) with ESMTP id C278A6BA84 for ; Tue, 6 Apr 2004 13:01:13 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by creanor.com (Postfix) with ESMTP id B7ACE38875A for ; Tue, 6 Apr 2004 12:57:35 +0300 (EEST) Received: from held085.hel.creanor.com (held085.hel.creanor.com [172.16.6.85]) by creanor.com (Postfix) with ESMTP id CC75D388759 for ; Tue, 6 Apr 2004 12:57:34 +0300 (EEST) Received: from tsavola by held085.hel.creanor.com with local (Exim 3.36 #1 (Debian)) id 1BAnOJ-00031K-00 for ; Tue, 06 Apr 2004 13:01:11 +0300 Date: Tue, 6 Apr 2004 13:01:11 +0300 Message-ID: <20040406100111.GD9385@held085.hel.creanor.com> Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="OXfL5xGRrasGEqWY" Content-Disposition: inline From: Timo Savola Subject: [Qemu-devel] [PATCH] sysctl Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org --OXfL5xGRrasGEqWY Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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 --OXfL5xGRrasGEqWY Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="sysctl.patch" --- 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 #include #include +#include #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; --OXfL5xGRrasGEqWY--