From patchwork Tue Aug 12 13:42:12 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku Voipio X-Patchwork-Id: 35265 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-qa0-f70.google.com (mail-qa0-f70.google.com [209.85.216.70]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 53C9720540 for ; Tue, 12 Aug 2014 13:49:18 +0000 (UTC) Received: by mail-qa0-f70.google.com with SMTP id j7sf26418458qaq.1 for ; Tue, 12 Aug 2014 06:49:18 -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=SLHiH6aMjZ/99BFG4ORdo9BHAnfpTowjkuMLTuz+nMdre/vuIjkdbJpXrcyiIxaVcH 0tPd0vh0ZuTxRfJWLWkmfwwhnp+vopCFm6VDsyUQ02NJKqMMET5u8HYROkyPoDOU4x5D DmtaWsN5VZdJQdaJTTQZ+JAt7k9Nth8Uqpx/mxgH/cgkL+txImYbc1awDBeQHmTUqs7t tL8JgXvLL9nzjhh1+6u6xnT/CY8tTRzxQDPLzfD6S1Y0+3qfTgasRNd7vDp07Xf+/arU k2vVBnyhIFSBr/G9CYZu2DmMd4KBvyBiPf1xyuwM228CM/lxAEo2igz1ewuiGmfyeIWj CP0Q== X-Gm-Message-State: ALoCoQmO1dva7jroXV6d4EHyYppavcQL/ewy5IN2f4FhuNf9mDxgo09KnN/NCrrFBMKkqz/KTT0b X-Received: by 10.236.150.170 with SMTP id z30mr91761yhj.58.1407851358206; Tue, 12 Aug 2014 06:49:18 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.202 with SMTP id k68ls136948qge.48.gmail; Tue, 12 Aug 2014 06:49:18 -0700 (PDT) X-Received: by 10.220.166.207 with SMTP id n15mr698484vcy.75.1407851358116; Tue, 12 Aug 2014 06:49:18 -0700 (PDT) Received: from mail-vc0-f174.google.com (mail-vc0-f174.google.com [209.85.220.174]) by mx.google.com with ESMTPS id ga5si8233436vdb.79.2014.08.12.06.49.18 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 12 Aug 2014 06:49:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.220.174 as permitted sender) client-ip=209.85.220.174; Received: by mail-vc0-f174.google.com with SMTP id la4so13429562vcb.33 for ; Tue, 12 Aug 2014 06:49:18 -0700 (PDT) X-Received: by 10.52.73.202 with SMTP id n10mr574347vdv.86.1407851358043; Tue, 12 Aug 2014 06:49:18 -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 tc5csp250407vcb; Tue, 12 Aug 2014 06:49:17 -0700 (PDT) X-Received: by 10.140.107.131 with SMTP id h3mr6522611qgf.83.1407851357177; Tue, 12 Aug 2014 06:49:17 -0700 (PDT) Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id dt10si23453100qcb.26.2014.08.12.06.49.17 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Tue, 12 Aug 2014 06:49:17 -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]:42150 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCRw-0001RH-PM for patch@linaro.org; Tue, 12 Aug 2014 09:49:16 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41348) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCLU-0007de-KY for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:42:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XHCLG-00018a-UR for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:42:36 -0400 Received: from afflict.kos.to ([92.243.29.197]:55488) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XHCLG-000182-K2 for qemu-devel@nongnu.org; Tue, 12 Aug 2014 09:42:22 -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 68A1626552; Tue, 12 Aug 2014 15:42:21 +0200 (CEST) From: riku.voipio@linaro.org To: qemu-devel@nongnu.org Date: Tue, 12 Aug 2014 16:42:12 +0300 Message-Id: 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] [PATCH 02/10] 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.174 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;