From patchwork Fri Aug 22 13:24:20 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35802 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qg0-f71.google.com (mail-qg0-f71.google.com [209.85.192.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 5D72E205D8 for ; Fri, 22 Aug 2014 13:28:21 +0000 (UTC) Received: by mail-qg0-f71.google.com with SMTP id f51sf31829962qge.6 for ; Fri, 22 Aug 2014 06:28:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:date :message-id:in-reply-to:references:cc:subject:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :errors-to:sender:x-original-sender :x-original-authentication-results:mailing-list; bh=4LnkO6INqK8FDNPaTdSTg4I8dD5jDuC2tjIAJrDLQnM=; b=jD5Dyo+xlukbYeJTDs8PJZkPrPZwutQRV3IF7Qb/u6wCz48gD5zIKDPFMtsZztnvdW gIXG/pZ3DOz9pkJzum8wdg3sBgNKcHrhFyJircfaF+RR/yKcx7+FigVSCOYoFH2Hy3m5 uEcdm5svkDtCnB8jmjUsYbtBRVJ2joEpsotJx63ptxRBr6v+G5KLII0khJEbhFnZTtio vz6dGcNFLaQ4mrbuFjJB9LS2dbA6/gfb1OMYZVYQpUG1ui9x16pGkXJGTDat0babGrVf vLa1K+QegZPV+K3o4SpUAot7b3MxU4YDg5jBqjGjQlDqvbFqT8yOVHlGMvbaBj7QXINR ib2w== X-Gm-Message-State: ALoCoQligl05nRpUZDIklfc3qj01RfVtrFYhXXWB8suhKN9vWyn5Epj7HtabGvUYMYj/SoavEuiM X-Received: by 10.236.108.172 with SMTP id q32mr3433899yhg.0.1408714101248; Fri, 22 Aug 2014 06:28:21 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.202 with SMTP id k68ls1260023qge.48.gmail; Fri, 22 Aug 2014 06:28:21 -0700 (PDT) X-Received: by 10.53.6.132 with SMTP id cu4mr67057vdd.62.1408714101161; Fri, 22 Aug 2014 06:28:21 -0700 (PDT) Received: from mail-vc0-f169.google.com (mail-vc0-f169.google.com [209.85.220.169]) by mx.google.com with ESMTPS id e20si13559105vdj.21.2014.08.22.06.28.21 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:28:21 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) client-ip=209.85.220.169; Received: by mail-vc0-f169.google.com with SMTP id le20so12351446vcb.14 for ; Fri, 22 Aug 2014 06:28:21 -0700 (PDT) X-Received: by 10.220.186.196 with SMTP id ct4mr81292vcb.51.1408714101023; Fri, 22 Aug 2014 06:28:21 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.221.45.67 with SMTP id uj3csp16875vcb; Fri, 22 Aug 2014 06:28:20 -0700 (PDT) X-Received: by 10.140.50.133 with SMTP id s5mr7397410qga.33.1408714099560; Fri, 22 Aug 2014 06:28:19 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id q14si42213352qay.126.2014.08.22.06.28.19 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Fri, 22 Aug 2014 06:28:19 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Received: from localhost ([::1]:37087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKot9-0007g2-4h for patch@linaro.org; Fri, 22 Aug 2014 09:28:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55369) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKopn-0006WI-NN for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XKopg-0002BU-9o for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:51 -0400 Received: from afflict.kos.to ([92.243.29.197]:39297) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XKopf-0002AK-UC for qemu-devel@nongnu.org; Fri, 22 Aug 2014 09:24:44 -0400 Received: from afflict.kos.to (afflict [92.243.29.197]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by afflict.kos.to (Postfix) with ESMTPSA id 69764264D8; Fri, 22 Aug 2014 15:24:42 +0200 (CEST) From: riku.voipio@linaro.org To: Peter Maydell , qemu-devel@nongnu.org Date: Fri, 22 Aug 2014 16:24:20 +0300 Message-Id: <0b2effd744471adea1cc82966df8a54fd6afa200.1408712881.git.riku.voipio@linaro.org> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 92.243.29.197 Cc: Mikhail Ilin , Riku Voipio Subject: [Qemu-devel] [PULL v3 02/22] linux-user: redirect openat calls 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: riku.voipio@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.169 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 From: Riku Voipio While Mikhail fixed /proc/self/maps, it was noticed openat calls are not redirected currently. Some archs don't have open at all, so openat needs to be redirected. Fix this by consolidating open/openat code to do_openat - open is implemented using openat(AT_FDCWD, ... ), which according to open(2) man page is identical. Since all targets now have openat, remove the ifdef around sys_openat and openat: case in do_syscall. Cc: Mikhail Ilin Signed-off-by: Riku Voipio --- linux-user/syscall.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c8c2b4c..dd77673 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -294,7 +294,6 @@ static int sys_getcwd1(char *buf, size_t size) return strlen(buf)+1; } -#ifdef TARGET_NR_openat static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode) { /* @@ -306,7 +305,6 @@ static int sys_openat(int dirfd, const char *pathname, int flags, mode_t mode) } return (openat(dirfd, pathname, flags)); } -#endif #ifdef TARGET_NR_utimensat #ifdef CONFIG_UTIMENSAT @@ -5274,7 +5272,7 @@ static int open_net_route(void *cpu_env, int fd) } #endif -static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) +static int do_openat(void *cpu_env, int dirfd, const char *pathname, int flags, mode_t mode) { struct fake_open { const char *filename; @@ -5295,7 +5293,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) if (is_proc_myself(pathname, "exe")) { int execfd = qemu_getauxval(AT_EXECFD); - return execfd ? execfd : get_errno(open(exec_path, flags, mode)); + return execfd ? execfd : get_errno(sys_openat(dirfd, exec_path, flags, mode)); } for (fake_open = fakes; fake_open->filename; fake_open++) { @@ -5329,7 +5327,7 @@ static int do_open(void *cpu_env, const char *pathname, int flags, mode_t mode) return fd; } - return get_errno(open(path(pathname), flags, mode)); + return get_errno(sys_openat(dirfd, path(pathname), flags, mode)); } /* do_syscall() should always have a single exit point at the end so @@ -5404,22 +5402,19 @@ abi_long do_syscall(void *cpu_env, int num, abi_long arg1, case TARGET_NR_open: if (!(p = lock_user_string(arg1))) goto efault; - ret = get_errno(do_open(cpu_env, p, - target_to_host_bitmask(arg2, fcntl_flags_tbl), - arg3)); + ret = get_errno(do_openat(cpu_env, AT_FDCWD, p, + target_to_host_bitmask(arg2, fcntl_flags_tbl), + arg3)); unlock_user(p, arg1, 0); 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)); + ret = get_errno(do_openat(cpu_env, arg1, p, + target_to_host_bitmask(arg3, fcntl_flags_tbl), + arg4)); unlock_user(p, arg2, 0); break; -#endif case TARGET_NR_close: ret = get_errno(close(arg1)); break;