From patchwork Fri Jan 18 21:31:02 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 156092 Delivered-To: patch@linaro.org Received: by 2002:a02:48:0:0:0:0:0 with SMTP id 69csp3757382jaa; Fri, 18 Jan 2019 14:12:04 -0800 (PST) X-Google-Smtp-Source: ALg8bN7mJUz0Nvv0ZvPQKoFVHcA29vDVvKB4mANA8LxpoNx4mj+XM5Q8EWd1XD1//DwRyn4SqG7A X-Received: by 2002:a5d:4f10:: with SMTP id c16mr18814215wru.177.1547849524063; Fri, 18 Jan 2019 14:12:04 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1547849524; cv=none; d=google.com; s=arc-20160816; b=X76RwZgBYy/UBfzAWc+CwspGijWaNPwzj3wkoA8+qqGzguxmWQakDoYosWY3N/L2Hh c3NOXwO72+xYFq02hACPpomSRre0gjnIKySFOpBGvq9bepSNoRmRVOh09LT5+RnDUhX+ uZI7ed2WwyMzv1h4hkOGWtSu7AmTcAKPpOWWAdswsLDNl1e/I2xUc8EFwIBXcXqAxqRt kHdpUdBE9euunNENrpSjBkY7wbQJRpe18WN0OwNQstt79tYmaMXAL9BoRN43G1i3t6D5 qfWIExkoJ0yvmqVknC/EOqwU3McPFLC5t3U78yPZp9eM/IthbaHVr/p87h9jd83VJdH6 zJoQ== 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=zDlRdC1NTM0KeXCW3hCrt9ktirWpz96vKzURH5zW4i8=; b=oCE9EKUu67xejdgNrGBdsGPgoALJvmLiTy3O2HzbHq9+d79VvNcn+BU5EZPSh688N/ QWItvuTG1sTetb5o51L2tz95FtB7N4DyJrA1aY+hCEMupOyWyWadekAc9wD3M71rkqym beNN0S4GF0xPakF3PgKy6ZGk4tYZg7bSo8ip3Nyy+b5lKXRHYNzdWwwvCdV41fmu2Svx XRxfzAItEBnt7g0EAte54PCoXEgIKjSA9dcVe9h6wXNVV0g0GfjSIOBu1+i/6hCsqB3m qSPBHiCt9X23AqTxGadAC7Ll+t3nv3PrL6wxmu6LMyLbQUf1qZGs4JAkzPvi9jcV4t/p uc6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=XyA4wkCo; 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 p12si15222486wmh.112.2019.01.18.14.12.03 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 18 Jan 2019 14:12:04 -0800 (PST) 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=XyA4wkCo; 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]:47998 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkcMt-00043F-0J for patch@linaro.org; Fri, 18 Jan 2019 17:12:03 -0500 Received: from eggs.gnu.org ([209.51.188.92]:56147) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gkbkn-0005Sk-Jn for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:42 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gkbkl-000528-Pi for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:41 -0500 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:40106) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1gkbkj-0004zL-SC for qemu-devel@nongnu.org; Fri, 18 Jan 2019 16:32:39 -0500 Received: by mail-pl1-x642.google.com with SMTP id u18so6885895plq.7 for ; Fri, 18 Jan 2019 13:32:36 -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=zDlRdC1NTM0KeXCW3hCrt9ktirWpz96vKzURH5zW4i8=; b=XyA4wkCo4kDR69tsrOfi02xcYWXge3mzqsLLeJZ4jlReLt5n8Cw6ta1s1fP0aCHdWw KFqzm//w6QD29FEGN97NGpq5qRTnfBpoyxgcbYSt8lsplk8tN6bhUsO5k4f6Eue31tgM 55ANuq71H9287lobOZoptBVqFNFEKV686W8Zo= 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=zDlRdC1NTM0KeXCW3hCrt9ktirWpz96vKzURH5zW4i8=; b=cJUV8MvlheE29PPrWOz/qHF4yYUaAR2HsbcWT7GJasvF7+7KTAySALkPPyYP9KI4k1 2j85PfFvq9FX8Ct2AzINTWeLRi6DfT/gWXK+k9lDxddhY/l0/WIx5St0Kc+1Tnbr7i96 YS8ZUMoSA7G2HjCuNbRW6Sq8lW+XyVOqRYdn3aataVPDKG9kkGYRTReADJ6025bet9zL VNIvKdytVE6fcD5aEDNkuDQsjj0CfrTKmJWPgNIr+8nli6VS5coD9bgySdtJHOihlZwM 5bO/WPmUoDOrdpoPI8DJdez57bs4bdJ6zDVg1AnxA5PdGW+IjTityr4467qgClf3GcVy ULTQ== X-Gm-Message-State: AJcUukdk4Wvb+xZpgCNurQULi6ky4FUPJU1QalQuZXgpCO28A4ZLCfOV XRdhAblvvsBC9f2GBP5odgrmekszXI8= X-Received: by 2002:a17:902:8f97:: with SMTP id z23mr20957641plo.283.1547847155448; Fri, 18 Jan 2019 13:32:35 -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.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 18 Jan 2019 13:32:34 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 19 Jan 2019 08:31:02 +1100 Message-Id: <20190118213122.22865-29-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::642 Subject: [Qemu-devel] [PATCH v6 29/49] linux-user: Split out chmod, fchmod, fchmodat 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 fchmodat is universally provided. Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 5 +++++ linux-user/strace.c | 28 ---------------------------- linux-user/syscall-file.inc.c | 30 ++++++++++++++++++++++++++++++ linux-user/syscall.c | 18 ------------------ linux-user/strace.list | 9 --------- 5 files changed, 35 insertions(+), 55 deletions(-) -- 2.17.2 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index b5951e6911..3ddf8aa0e3 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -20,6 +20,9 @@ SYSCALL_DEF_FULL(brk, .impl = impl_brk, .print_ret = print_syscall_ptr_ret, .arg_type = { ARG_PTR }); SYSCALL_DEF(chdir, ARG_STR); +#ifdef TARGET_NR_chmod +SYSCALL_DEF(chmod, ARG_STR, ARG_MODEFLAG); +#endif SYSCALL_DEF_ARGS(clone, ARG_CLONEFLAG, ARG_PTR, ARG_PTR, ARG_PTR, ARG_PTR); SYSCALL_DEF(close, ARG_DEC); #ifdef TARGET_NR_creat @@ -28,6 +31,8 @@ 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(fchmod, ARG_DEC, ARG_MODEFLAG); +SYSCALL_DEF(fchmodat, ARG_ATDIRFD, ARG_STR, ARG_MODEFLAG); #ifdef TARGET_NR_fork SYSCALL_DEF(fork); #endif diff --git a/linux-user/strace.c b/linux-user/strace.c index 668e6a4759..66d981b9e6 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1113,19 +1113,6 @@ print_access(const struct syscallname *name, } #endif -#ifdef TARGET_NR_chmod -static void -print_chmod(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_file_mode(arg1, 1); - print_syscall_epilogue(name); -} -#endif - #ifdef TARGET_NR_clock_adjtime static void print_clock_adjtime(const struct syscallname *name, @@ -1167,21 +1154,6 @@ print_faccessat(const struct syscallname *name, } #endif -#ifdef TARGET_NR_fchmodat -static void -print_fchmodat(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_file_mode(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, diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index 3b5a79fe74..9844382166 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -30,6 +30,26 @@ SYSCALL_IMPL(chdir) return ret; } +static abi_long do_fchmodat(int dirfd, abi_ulong target_path, mode_t mode) +{ + char *p = lock_user_string(target_path); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(fchmodat(dirfd, p, mode, 0)); + unlock_user(p, target_path, 0); + return ret; +} + +#ifdef TARGET_NR_chmod +SYSCALL_IMPL(chmod) +{ + return do_fchmodat(AT_FDCWD, arg1, arg2); +} +#endif + SYSCALL_IMPL(close) { int fd = arg1; @@ -54,6 +74,16 @@ SYSCALL_IMPL(creat) } #endif +SYSCALL_IMPL(fchmod) +{ + return get_errno(fchmod(arg1, arg2)); +} + +SYSCALL_IMPL(fchmodat) +{ + return do_fchmodat(arg1, arg2, arg3); +} + static abi_long do_linkat(int olddirfd, abi_ulong target_oldpath, int newdirfd, abi_ulong target_newpath, int flags) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index d46b4df677..f9101d0b08 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5331,14 +5331,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_chmod - case TARGET_NR_chmod: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(chmod(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif #ifdef TARGET_NR_lseek case TARGET_NR_lseek: return get_errno(lseek(arg1, arg2, arg3)); @@ -6410,16 +6402,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, #ifdef TARGET_NR_ftruncate case TARGET_NR_ftruncate: return get_errno(ftruncate(arg1, arg2)); -#endif - case TARGET_NR_fchmod: - return get_errno(fchmod(arg1, arg2)); -#if defined(TARGET_NR_fchmodat) - case TARGET_NR_fchmodat: - if (!(p = lock_user_string(arg2))) - return -TARGET_EFAULT; - ret = get_errno(fchmodat(arg1, p, arg3, 0)); - unlock_user(p, arg2, 0); - return ret; #endif case TARGET_NR_getpriority: /* Note that negative values are valid for getpriority, so we must diff --git a/linux-user/strace.list b/linux-user/strace.list index adf8955278..92a86c682c 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -61,9 +61,6 @@ #ifdef TARGET_NR_capset { TARGET_NR_capset, "capset" , "%s(%p,%p)", NULL, NULL }, #endif -#ifdef TARGET_NR_chmod -{ TARGET_NR_chmod, "chmod" , NULL, print_chmod, NULL }, -#endif #ifdef TARGET_NR_chown { TARGET_NR_chown, "chown" , NULL, NULL, NULL }, #endif @@ -169,12 +166,6 @@ #ifdef TARGET_NR_fchdir { TARGET_NR_fchdir, "fchdir" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_fchmod -{ TARGET_NR_fchmod, "fchmod" , "%s(%d,%#o)", NULL, NULL }, -#endif -#ifdef TARGET_NR_fchmodat -{ TARGET_NR_fchmodat, "fchmodat" , NULL, print_fchmodat, NULL }, -#endif #ifdef TARGET_NR_fchown { TARGET_NR_fchown, "fchown" , "%s(%d,%d,%d)", NULL, NULL }, #endif