From patchwork Sun May 19 20:36:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164531 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4800873ili; Sun, 19 May 2019 14:11:38 -0700 (PDT) X-Google-Smtp-Source: APXvYqztGHNYCCXn9Oi+gxD9/pLmY6JCQgmX2bZ7YTaam4R27UodMng2VKJbiPWsxLTwh97PH4Uk X-Received: by 2002:a17:906:9145:: with SMTP id y5mr11557725ejw.206.1558300298121; Sun, 19 May 2019 14:11:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558300298; cv=none; d=google.com; s=arc-20160816; b=YW59EThK22ONqbUH7ARnIWkZFCJlguCVjctDurO68qr5f4eE3mehQvUtHXILA/tQtA y/6mixn4UOf7WuTjER39rSNLHHxVxrOJrmTiQn4//diyVLx1BA5XE600oDsAOMT4YMBZ bJJ78OcsVbqc5Rts7T0xqQK4S6saz0pS+Y9WD19TWjtvbDaQQT+N1mRqkai89HCfiSte bwzsdCJp5fIWJo/kYSF82SLv0451AyS6QYRHX6zagGMFiRn46QAaYHBpJW2T39vKSMoP KiAfTwbTxXf4bSiTfmSBOz37Q0m5YLwHfDTXqaEcP6KUa3jAPyjlyPDS2PdHRB+HxnkU oV6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature; bh=RSrci5Zj8IDwkVKyxa0LFWqGkMUNuHHhltz/gMocb2g=; b=k2Qbdc/iXv4vySIF/XgFTQ9ulalGFg7ZMGTwk4B6vDVLZGhKQXRpaVk5UME9mI6nyJ vPSeo5aKnAvJYMoyc1z5tHzppplD9n3dOrK2mNVldtndhMSzxuA0KxniB+5lISYA4WPI oc8jjqZKbkzvBFCyJIRbeRaeZ58DpcLkSBkYJsXQvshCUTCm1tI0STcNjQdgZdIsC3I/ 7AAePSHdvVXqnJ5f/PnG91Uy4S3mQYDw6dNMQ2vymuyv+NbqTjSo47M71M6xXcUWLYpG Pgl1izljvcXicb8+S8EypvjlqY0m0xvMOHfD5l+p/eR8zLt8EcnbQ9xXv+D4vWD+1BSh 56bw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jDdO0zc2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z18si1516721ejx.36.2019.05.19.14.11.37 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:11:38 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=jDdO0zc2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([127.0.0.1]:53611 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hST5l-0007HG-0Y for patch@linaro.org; Sun, 19 May 2019 17:11:37 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50642) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZc-0003cU-CZ for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZZ-0004Kt-92 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:23 -0400 Received: from mail-pl1-x641.google.com ([2607:f8b0:4864:20::641]:45099) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZX-0004F6-9f for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:20 -0400 Received: by mail-pl1-x641.google.com with SMTP id a5so5687657pls.12 for ; Sun, 19 May 2019 13:38:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RSrci5Zj8IDwkVKyxa0LFWqGkMUNuHHhltz/gMocb2g=; b=jDdO0zc2XOPVrgHNM7q3palvQ30e3PDzRDXcePaLqRdKym7cLd/LjwZG688coSBiDH uhPpWTjODsh5mhOWQBcN4VnB+PnRHeE/zGifzcRVu0yIOk5t2DAsX6UNFUtKqWVnBI0e 1umbfEqqJnQ1FdgLO/wH3NC60ltA6G2HX3yeHsdQoDq3vjgriqgHJIG9DsE5istdSWKg KvT2nm0jxrN7+OKsHkN+uzIn6IEivAqeS1imme5WHtTaM18gkB+QUDF/4t6RzP2J814f l30i1GJRYTzQPvmOW12bA2y8C9tn953vOADKHtdurdxHBqDE2FSsTn4J0AWKzOagBDu5 OGnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RSrci5Zj8IDwkVKyxa0LFWqGkMUNuHHhltz/gMocb2g=; b=S8qtEUhfE0CyhO+ja31G+a9sHtc1wkgjQaEjae/Gf6WvBXAufMhoj2S6SkuksvfgLz j95DNW6ALLXy0M0h8gWI+fnz2ic0zMvT6pkxCEW0W++JSRKFbLnX6i41I9BHnuCdDEz1 xE+XvpQS0bqEs5fjKjQrDxM3mIUV2M9wTHPMEkUrp02jZowciU+zGIq0U5bkFrd4CQ07 Jr5rDnhO84Tqmhd8LZhzRBGEfGWTTqqC+YAtJ0iUCLG73c685HTY4BHDGWMRSezOvX2w cAMGMxXcRRGo73iBta0R1sO+2FK63EF42Pfo5IFOgmgJJ8SBkGwB3B7ThJHtPK8zapjJ yaBQ== X-Gm-Message-State: APjAAAUSiNeMLCWCnpuHzqdQE5VCEf1m+RLXDzsqASNV60vbKhEcQFgw fdPY1jexUkR9aTJhXDI7OgF9tYQpmco= X-Received: by 2002:a17:902:4e:: with SMTP id 72mr19186217pla.80.1558298295592; Sun, 19 May 2019 13:38:15 -0700 (PDT) Received: from localhost.localdomain (97-113-13-231.tukw.qwest.net. [97.113.13.231]) by smtp.gmail.com with ESMTPSA id i7sm11397448pfo.19.2019.05.19.13.38.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:14 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:48 -0700 Message-Id: <20190519203726.20729-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190519203726.20729-1-richard.henderson@linaro.org> References: <20190519203726.20729-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::641 Subject: [Qemu-devel] [PATCH v7 36/74] linux-user: Split out access, faccessat X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: laurent@vivier.eu Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" Note that faccessat is unconditionally available. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 4 ++++ linux-user/syscall.h | 1 + linux-user/strace.c | 33 ++++----------------------------- linux-user/syscall-file.inc.c | 25 +++++++++++++++++++++++++ linux-user/syscall.c | 18 ------------------ linux-user/strace.list | 6 ------ 6 files changed, 34 insertions(+), 53 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 2767e335d8..39e3ae3c21 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -16,6 +16,9 @@ * along with this program; if not, see . */ +#ifdef TARGET_NR_access +SYSCALL_DEF(access, ARG_STR, ARG_ACCESSFLAG); +#endif #ifdef TARGET_NR_alarm SYSCALL_DEF(alarm, ARG_DEC); #endif @@ -34,6 +37,7 @@ SYSCALL_DEF(creat, ARG_STR, ARG_MODEFLAG); SYSCALL_DEF(exit, ARG_DEC); SYSCALL_DEF(execve, ARG_STR, ARG_PTR, ARG_PTR); SYSCALL_DEF(execveat, ARG_ATDIRFD, ARG_STR, ARG_PTR, ARG_PTR, ARG_ATFLAG); +SYSCALL_DEF(faccessat, ARG_ATDIRFD, ARG_STR, ARG_ACCESSFLAG); SYSCALL_DEF(fchmod, ARG_DEC, ARG_MODEFLAG); SYSCALL_DEF(fchmodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG); #ifdef TARGET_NR_futimesat diff --git a/linux-user/syscall.h b/linux-user/syscall.h index 3c936b648a..84a52b2d9a 100644 --- a/linux-user/syscall.h +++ b/linux-user/syscall.h @@ -57,6 +57,7 @@ typedef enum { /* These print as sets of flags. */ ARG_ATDIRFD, + ARG_ACCESSFLAG, ARG_ATFLAG, ARG_CLONEFLAG, ARG_MMAPFLAG, diff --git a/linux-user/strace.c b/linux-user/strace.c index 3a7a5c30ec..c42abc2f08 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -634,7 +634,7 @@ print_syscall_ret_adjtimex(const struct syscallname *name, abi_long ret) gemu_log("\n"); } -UNUSED static struct flags access_flags[] = { +static struct flags const access_flags[] = { FLAG_GENERIC(F_OK), FLAG_GENERIC(R_OK), FLAG_GENERIC(W_OK), @@ -1114,19 +1114,6 @@ print_accept(const struct syscallname *name, } #endif -#ifdef TARGET_NR_access -static void -print_access(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_string(arg0, 0); - print_flags(access_flags, arg1, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_chroot static void print_chroot(const struct syscallname *name, @@ -1165,21 +1152,6 @@ print_execv(const struct syscallname *name, } #endif -#ifdef TARGET_NR_faccessat -static void -print_faccessat(const struct syscallname *name, - abi_long arg0, abi_long arg1, abi_long arg2, - abi_long arg3, abi_long arg4, abi_long arg5) -{ - print_syscall_prologue(name); - print_at_dirfd(arg0, 0); - print_string(arg1, 0); - print_flags(access_flags, arg2, 0); - print_flags(at_file_flags, arg3, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_fchownat static void print_fchownat(const struct syscallname *name, @@ -2218,6 +2190,9 @@ static void print_syscall_def1(const SyscallDef *def, int64_t args[6]) case ARG_ATDIRFD: len = add_atdirfd(b, rest, arg); break; + case ARG_ACCESSFLAG: + len = add_flags(b, rest, access_flags, arg, false); + break; case ARG_ATFLAG: len = add_flags(b, rest, at_file_flags, arg, false); break; diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 42e5cd2dc1..5e276d13bc 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -16,6 +16,26 @@ * along with this program; if not, see . */ +static abi_long do_faccessat(int dirfd, abi_ulong target_path, int mode) +{ + char *p = lock_user_string(target_path); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(faccessat(dirfd, p, mode, 0)); + unlock_user(p, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_access +SYSCALL_IMPL(access) +{ + return do_faccessat(AT_FDCWD, arg1, arg2); +} +#endif + SYSCALL_IMPL(chdir) { abi_ulong target_path = arg1; @@ -74,6 +94,11 @@ SYSCALL_IMPL(creat) } #endif +SYSCALL_IMPL(faccessat) +{ + return do_faccessat(arg1, arg2, arg3); +} + SYSCALL_IMPL(fchmod) { return get_errno(fchmod(arg1, arg2)); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f66acbf27c..b5ade974a7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5380,24 +5380,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_access - case TARGET_NR_access: - if (!(p = lock_user_string(arg1))) { - return -TARGET_EFAULT; - } - ret = get_errno(access(path(p), arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif -#if defined(TARGET_NR_faccessat) && defined(__NR_faccessat) - case TARGET_NR_faccessat: - if (!(p = lock_user_string(arg2))) { - return -TARGET_EFAULT; - } - ret = get_errno(faccessat(arg1, p, arg3, 0)); - unlock_user(p, arg2, 0); - return ret; -#endif #ifdef TARGET_NR_nice /* not on alpha */ case TARGET_NR_nice: return get_errno(nice(arg1)); diff --git a/linux-user/strace.list b/linux-user/strace.list index 3f92224b55..80b9220e89 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -9,9 +9,6 @@ #ifdef TARGET_NR_accept4 { TARGET_NR_accept4, "accept4" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_access -{ TARGET_NR_access, "access" , NULL, print_access, NULL }, -#endif #ifdef TARGET_NR_acct { TARGET_NR_acct, "acct" , NULL, NULL, NULL }, #endif @@ -142,9 +139,6 @@ #ifdef TARGET_NR_exit_group { TARGET_NR_exit_group, "exit_group" , "%s(%d)\n", NULL, NULL }, #endif -#ifdef TARGET_NR_faccessat -{ TARGET_NR_faccessat, "faccessat" , NULL, print_faccessat, NULL }, -#endif #ifdef TARGET_NR_fadvise64 { TARGET_NR_fadvise64, "fadvise64" , NULL, NULL, NULL }, #endif