From patchwork Fri Jan 7 20:52:30 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 77909 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 1891BB70D6 for ; Sat, 8 Jan 2011 07:55:43 +1100 (EST) Received: from localhost ([127.0.0.1]:48074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PbJLY-0000xC-61 for incoming@patchwork.ozlabs.org; Fri, 07 Jan 2011 15:55:40 -0500 Received: from [140.186.70.92] (port=60543 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PbJIe-0008G4-Lu for qemu-devel@nongnu.org; Fri, 07 Jan 2011 15:52:43 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PbJId-0007VA-D3 for qemu-devel@nongnu.org; Fri, 07 Jan 2011 15:52:40 -0500 Received: from afflict.kos.to ([92.243.29.197]:44845) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PbJId-0007Ue-7l for qemu-devel@nongnu.org; Fri, 07 Jan 2011 15:52:39 -0500 Received: by afflict.kos.to (Postfix, from userid 1000) id A81C726673; Fri, 7 Jan 2011 20:52:35 +0000 (UTC) From: Riku Voipio To: qemu-devel@nongnu.org Date: Fri, 7 Jan 2011 22:52:30 +0200 Message-Id: X-Mailer: git-send-email 1.6.5 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Peter Maydell , Riku Voipio Subject: [Qemu-devel] [PATCH 2/7] 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 From: Peter Maydell 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 Signed-off-by: Riku Voipio --- 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 1939a5f..970efe3 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 */