From patchwork Fri Jan 18 21:31:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 1027792 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.b="eRg2tOo4"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 43hFL06vYjz9sDB for ; Sat, 19 Jan 2019 09:02:32 +1100 (AEDT) Received: from localhost ([127.0.0.1]:47824 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkcDe-0004VM-90 for incoming@patchwork.ozlabs.org; Fri, 18 Jan 2019 17:02:30 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56328) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkbl6-0005g5-JH for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:03 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkbl4-0005Lo-DL for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:33:00 -0500 Received: from mail-pg1-x542.google.com ([2607:f8b0:4864:20::542]:33671) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkbl3-0005Fk-2l for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:57 -0500 Received: by mail-pg1-x542.google.com with SMTP id z11so6661221pgu.0 for ; Fri, 18 Jan 2019 13:32:54 -0800 (PST) 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=R+Y7Q/knJrp4IbesLUM7CvnwCm1qZrvO4LyA8sL+Brs=; b=eRg2tOo4bCfC/6fnXT482WfCDxMyG3Wdv7aIBm9KSCw8FeYFfqhJxw2d/1/GXqFP+b W5RrSmaa8QNsD3rvtbKKzc8mfG88MEVpKl1XCXWaxOon2c0jSjZt77/T6I8fxTSatDh1 umzgiBeP0rDZPDfyDrRxd4Tr9rSAVHpT0u6K8= 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=R+Y7Q/knJrp4IbesLUM7CvnwCm1qZrvO4LyA8sL+Brs=; b=HM3bonRPEz2d7a/P3ixePz8yQm112bhDdiMSIM1EJYLvT0QBIYQSQeI9norplvr5Y6 jEoclmMC9ktyuJRp6u4tBS0ukQojMx1Zztoagzs3bdYoxGsHohEDo3ynOQsau+ZJRZJ8 tTfugCJRrwXnf6d96/CLMNspKW4lTIcf3L+PziUAYTa4lzp4BtN4NFLFv+nb0hbue7z3 WL29X2Gw9FlyWf/GdM4Nb1X3teEC6zN2PXAnsCluviIWru1oPM3FBHw8z3YZX/X3RA5Z QeFmnFbofvIWFKrWW++LIH9XNiY/Oir+H0zQf3JG8zhad7bsJjR+X6vUPXvWI4jGw495 6qwg== X-Gm-Message-State: AJcUukd2aGqrSzbpo9knZhdl3o1I/Kacb6aIJC+t/hktBaR8BgC0uOee vSBbAJerqJvz8HaaMwO0CUEw6td7Xgg= X-Google-Smtp-Source: ALg8bN7NNzjyCRNVddrWkZjgs7K+00EvUc7er9uuS+25vzTHNxEifafnuYp+vff0CcKwaprDcOVxmg== X-Received: by 2002:a63:8149:: with SMTP id t70mr19681133pgd.172.1547847173657; Fri, 18 Jan 2019 13:32:53 -0800 (PST) Received: from cloudburst.twiddle.net ([2001:8000:10e0:a000:c673:a6b6:fdef:1933]) by smtp.gmail.com with ESMTPSA id v12sm5833667pgg.41.2019.01.18.13.32.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 13:32:53 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 19 Jan 2019 08:31:10 +1100 Message-Id: <20190118213122.22865-37-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20190118213122.22865-1-richard.henderson@linaro.org> References: <20190118213122.22865-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::542 Subject: [Qemu-devel] [PATCH v6 37/49] 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+incoming=patchwork.ozlabs.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(-) 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 b54949df27..da2cc30f82 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_clock_adjtime static void print_clock_adjtime(const struct syscallname *name, @@ -1153,21 +1140,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, @@ -2206,6 +2178,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 6a7ef80bfc..3111abd861 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 ca462fde61..9074cf8b8d 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5327,24 +5327,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 c0c1b896f7..fc0eb91e29 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