From patchwork Tue Aug 19 08:32:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35558 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ie0-f199.google.com (mail-ie0-f199.google.com [209.85.223.199]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 87FF92136C for ; Tue, 19 Aug 2014 08:39:14 +0000 (UTC) Received: by mail-ie0-f199.google.com with SMTP id tr6sf3404322ieb.2 for ; Tue, 19 Aug 2014 01:39:14 -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=YyeJS7G43be8PjJHfKEIwbkGk0d195hyiZAxUiaBwvP9NkUE7Fwwu/xpMrcNgI2gYc 9U7pLmIX9lKhmOvhDxFdQxV9ygudM2hO04jV2U+k/rm7WHKmE0HnvmemIaeuljh8W1hd 0aaMj3WGtEBAeTwlGunnUpqcL3Z91ezjRpmtbINkwHfO/We/kKW+eXXoYkIYTImTAsSG fZwL/2zWBo4WksKkwrgzmmOBAhNMKmf9tnDq85GjXAyh5nDwtcsL41u0kbeF8TcWOm5x dnBKDzRLWl/1XnFkbiKZG8YGJGQJWRSPfU+5w1YtaX3nbi1aKnwt7LCTTDU1a/sa2I4I 4VTQ== X-Gm-Message-State: ALoCoQn23JkBBzfNMME8FOzhr1iGBgWSbtPmRCDTsPhm8+qGBP8REufNSWDNNG9iQDoDHjSyBhlq X-Received: by 10.43.74.198 with SMTP id yx6mr176775icb.32.1408437554118; Tue, 19 Aug 2014 01:39:14 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.48.35 with SMTP id n32ls2748411qga.25.gmail; Tue, 19 Aug 2014 01:39:14 -0700 (PDT) X-Received: by 10.221.68.66 with SMTP id xx2mr29038135vcb.1.1408437554018; Tue, 19 Aug 2014 01:39:14 -0700 (PDT) Received: from mail-vc0-f182.google.com (mail-vc0-f182.google.com [209.85.220.182]) by mx.google.com with ESMTPS id m8si8345546vcj.67.2014.08.19.01.39.14 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 19 Aug 2014 01:39:14 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.182 as permitted sender) client-ip=209.85.220.182; Received: by mail-vc0-f182.google.com with SMTP id hy4so6934619vcb.41 for ; Tue, 19 Aug 2014 01:39:13 -0700 (PDT) X-Received: by 10.52.239.108 with SMTP id vr12mr2155729vdc.30.1408437553892; Tue, 19 Aug 2014 01:39:13 -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.37.5 with SMTP id tc5csp220543vcb; Tue, 19 Aug 2014 01:39:13 -0700 (PDT) X-Received: by 10.224.47.6 with SMTP id l6mr65787367qaf.32.1408437553017; Tue, 19 Aug 2014 01:39:13 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id r4si28033112qan.16.2014.08.19.01.39.12 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 19 Aug 2014 01:39:13 -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]:49113 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJewi-0002C5-IU for patch@linaro.org; Tue, 19 Aug 2014 04:39:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57336) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJeqr-0000z5-VG for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:33:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XJeqk-0001YG-KE for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:33:09 -0400 Received: from afflict.kos.to ([92.243.29.197]:35143) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XJeqk-0001Xi-9y for qemu-devel@nongnu.org; Tue, 19 Aug 2014 04:33:02 -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 5B5152657B; Tue, 19 Aug 2014 10:33:01 +0200 (CEST) From: riku.voipio@linaro.org To: Peter Maydell , qemu-devel@nongnu.org Date: Tue, 19 Aug 2014 11:32:37 +0300 Message-Id: <34947d2badab67e65a619a8e490844cd4076303c.1408436940.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 v2 02/23] 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.182 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;