From patchwork Thu Jan 6 15:04:17 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 77725 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 7D801B713D for ; Fri, 7 Jan 2011 02:06:15 +1100 (EST) Received: from localhost ([127.0.0.1]:43877 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ParPO-0001l7-Ua for incoming@patchwork.ozlabs.org; Thu, 06 Jan 2011 10:05:46 -0500 Received: from [140.186.70.92] (port=48816 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1ParO8-0001h2-6d for qemu-devel@nongnu.org; Thu, 06 Jan 2011 10:04:30 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ParO0-0001fG-4j for qemu-devel@nongnu.org; Thu, 06 Jan 2011 10:04:21 -0500 Received: from mnementh.archaic.org.uk ([81.2.115.146]:40045) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ParNz-0001fA-Sn for qemu-devel@nongnu.org; Thu, 06 Jan 2011 10:04:20 -0500 Received: from pm215 by mnementh.archaic.org.uk with local (Exim 4.69) (envelope-from ) id 1ParNy-00053q-3E; Thu, 06 Jan 2011 15:04:18 +0000 From: Peter Maydell To: qemu-devel@nongnu.org Date: Thu, 6 Jan 2011 15:04:17 +0000 Message-Id: <1294326258-19431-2-git-send-email-peter.maydell@linaro.org> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1294326258-19431-1-git-send-email-peter.maydell@linaro.org> References: <1294326258-19431-1-git-send-email-peter.maydell@linaro.org> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Cc: Riku Voipio Subject: [Qemu-devel] [PATCH 1/2] linux-user: Support ioctls whose parameter size is not constant X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Some ioctls (for example FS_IOC_FIEMAP) use structures whose size is not constant. The generic argument conversion code in do_ioctl() cannot handle this, so add support for implementing a special-case handler for a particular ioctl which does the conversion itself. Signed-off-by: Peter Maydell --- linux-user/syscall.c | 18 +++++++++++++++--- 1 files changed, 15 insertions(+), 3 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c3e8706..7436c3f 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -2965,13 +2965,19 @@ enum { #undef STRUCT #undef STRUCT_SPECIAL -typedef struct IOCTLEntry { +typedef struct IOCTLEntry IOCTLEntry; + +typedef abi_long do_ioctl_fn(const IOCTLEntry *ie, uint8_t *buf_temp, + int fd, abi_long cmd, abi_long arg); + +struct IOCTLEntry { unsigned int target_cmd; unsigned int host_cmd; const char *name; int access; + do_ioctl_fn *do_ioctl; const argtype arg_type[5]; -} IOCTLEntry; +}; #define IOC_R 0x0001 #define IOC_W 0x0002 @@ -2981,7 +2987,9 @@ typedef struct IOCTLEntry { static IOCTLEntry ioctl_entries[] = { #define IOCTL(cmd, access, ...) \ - { TARGET_ ## cmd, cmd, #cmd, access, { __VA_ARGS__ } }, + { TARGET_ ## cmd, cmd, #cmd, access, 0, { __VA_ARGS__ } }, +#define IOCTL_SPECIAL(cmd, access, dofn, ...) \ + { TARGET_ ## cmd, cmd, #cmd, access, dofn, { __VA_ARGS__ } }, #include "ioctls.h" { 0, 0, }, }; @@ -3011,6 +3019,10 @@ static abi_long do_ioctl(int fd, abi_long cmd, abi_long arg) #if defined(DEBUG) gemu_log("ioctl: cmd=0x%04lx (%s)\n", (long)cmd, ie->name); #endif + if (ie->do_ioctl) { + return ie->do_ioctl(ie, buf_temp, fd, cmd, arg); + } + switch(arg_type[0]) { case TYPE_NULL: /* no argument */