From patchwork Fri Oct 12 18:24:42 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 191171 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id 093B52C0090 for ; Sat, 13 Oct 2012 05:25:07 +1100 (EST) Received: from localhost ([::1]:46784 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMjuy-0002mY-Em for incoming@patchwork.ozlabs.org; Fri, 12 Oct 2012 14:25:04 -0400 Received: from eggs.gnu.org ([208.118.235.92]:51032) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMjug-0002ly-Oi for qemu-devel@nongnu.org; Fri, 12 Oct 2012 14:24:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TMjuf-0006LX-FL for qemu-devel@nongnu.org; Fri, 12 Oct 2012 14:24:46 -0400 Received: from afflict.kos.to ([92.243.29.197]:33090) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TMjuf-0006LM-85 for qemu-devel@nongnu.org; Fri, 12 Oct 2012 14:24:45 -0400 Received: by afflict.kos.to (Postfix, from userid 1000) id 7A0C6264C8; Fri, 12 Oct 2012 20:24:42 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Fri, 12 Oct 2012 21:24:42 +0300 Message-Id: X-Mailer: git-send-email 1.7.2.5 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 92.243.29.197 Cc: Riku Voipio Subject: [Qemu-devel] [PATCH 5/5] linux-user: do_openat wrapper added X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Riku Voipio In preparations for for refactoring the main switch/case out Signed-off-by: Riku Voipio --- linux-user/syscall.c | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index eebf219..61030f2 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5092,6 +5092,19 @@ cleanup: unlock_user(pathname, arg1, 0); return ret; } + +static int do_openat(void *cpu_env, abi_long arg1, abi_long arg2, abi_long arg3, abi_long arg4) +{ + void *p; + int ret; + if (!(p = lock_user_string(arg2))) + return -EFAULT; + ret = sys_openat(arg1, path(p), + target_to_host_bitmask(arg3, fcntl_flags_tbl), arg4); + unlock_user(p, arg2, 0); + return ret; +} + static void do_exit(void *, abi_long) __attribute__ ((noreturn)); static void do_exit(void *cpu_env, abi_long arg1) { @@ -5199,13 +5212,7 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, break; #if defined(TARGET_NR_openat) && defined(__NR_openat) case TARGET_NR_openat: - if (!(p = lock_user_string(arg2))) - goto efault; - ret = get_errno(sys_openat(arg1, - path(p), - target_to_host_bitmask(arg3, fcntl_flags_tbl), - arg4)); - unlock_user(p, arg2, 0); + ret = get_errno(do_openat(cpu_env, arg1, arg2, arg3, arg4)); break; #endif case TARGET_NR_close: