From patchwork Sun May 19 20:36:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164514 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4789716ili; Sun, 19 May 2019 13:57:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzVSnC2UveK8p8UGKkISHEUPV3aJnx817uHRgKBVVT+tN3xnvRDUM9JV2pjVZZPT1WEkp8M X-Received: by 2002:a17:906:5ad4:: with SMTP id x20mr10055032ejs.225.1558299429659; Sun, 19 May 2019 13:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558299429; cv=none; d=google.com; s=arc-20160816; b=j3lHP8CoYRIFGlYhBhdAojq7g+jNG9UgqqK7API2uRvRjucHL25s/j47fMoZTmYl9R zciQJQD0QrHv1EalLL4akTHhBsQJ3majSyQtbzVtSUwkkR8spITuo2G7k6N52YBDJ6/V L5qy9fIukVuwO2/WQBKbVVG1xTUH0R58Jxz5e9r0uDLMcBS1CvPTvbA+vs4yn9CwQ9uG xHydjFrk111vYOnV9KrYdbs96pKKpf+bTXo2UpcBlY2Nyyfvl8BKmr5iOv+H5FzOwyYm ALoifkxZoAdaJfr2S1EK/2B1AcSms66E9JQIl63bdPfay1Gaf+9v2S7WEoFE2260sCUP JatA== 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=1sQg+P8lShstSTQHyJ7jNTozkqlGpcD4AM3YYr8dTII=; b=zZH6LBs9iRYixQQkD//bbm7u0eoS7RHvnFtyJOSWBVCfYvUsHKrb2GksRCU5tGclqm y36rtL2gRNnpaH8Pa++6esLcHtaC7v7YaMI112qsbaZoyoEe8i8y9zUFIbX4lVEVrP4i Kd8FY9k0aXPTuoddZoZCOpDaysAkFvj9Rkjy/CWsHEY6gfQA5T8qj01ldPq0CYHq+7xt sg8TkVqqgnnSvp+wRx+QraeaFXKAenDgUY3WxXUGk5hhhc6yfwXRisMCFEh8jx//2z0X poQKqKbvLHyb2pRRy1yASOYYvetlpajnn5xZZld3AY79qwMtj6Cg7v+OEB9xg/hhQEbu Qlqg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=vAxbTJLT; 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 p28si2674684edc.405.2019.05.19.13.57.09 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 13:57:09 -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=vAxbTJLT; 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]:53388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSrk-0002Tg-Fo for patch@linaro.org; Sun, 19 May 2019 16:57:08 -0400 Received: from eggs.gnu.org ([209.51.188.92]:50514) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSZN-0003UN-2v for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSZL-00043d-RG for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:09 -0400 Received: from mail-pl1-x642.google.com ([2607:f8b0:4864:20::642]:41408) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSZL-000431-Je for qemu-devel@nongnu.org; Sun, 19 May 2019 16:38:07 -0400 Received: by mail-pl1-x642.google.com with SMTP id f12so5707086plt.8 for ; Sun, 19 May 2019 13:38:07 -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=1sQg+P8lShstSTQHyJ7jNTozkqlGpcD4AM3YYr8dTII=; b=vAxbTJLT9BXhkiEJCEGyKGl8j7CT9eSVY5wjTULP9AeeXtBs84F7LZPWXrSokxv9p/ D2eFuMuL4jViPFYIvjUyLxxImxybgijNJjWy5ECOlnL/0J0AjEFMbxuKByEWPz9Ndluh Ec04vZjE98kXYnS9KochhkEfOuhTOKjX8381fFT4754W7YiUxxNymHf2/YbRnTZU4AXd b5C+AkbBIsKf2vHsUMDKyksJ/0g1O2JGifvxJLFTfPxJYAYVcBBA3q/87zkR2GIV14Oo xuPDf7JxctcGG9LV9KGEG+fa7cDacPzCj0aYBZfXapz17BQ2ekVB5BkDTy7ZR1KJNxgd 0g3Q== 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=1sQg+P8lShstSTQHyJ7jNTozkqlGpcD4AM3YYr8dTII=; b=Z+u+HNIIERViHwoD0uPnf9PFKvHpc6GlHwAkhJRcQ5CTBdhqpy6U7Nt3ROxb+bRGuZ 0rwVWgGN74tuJcdwAONh4VbzzsMWLYlZqf7KllDMy2b//+10ErApR5Gndv/ko036x+C1 Hj8iER5Wiuj11q54vPXT97A+YYz2BS7M5tAfAWxvPEGsY9b04FiO5LY+FoG+UH2eflJV VmWzkzcBYBf+W8fuWNFkUo+9c3DT0hg+vbf/hmBaSuj3zr/HFWk/PMBhYfCOJY0Bbjm0 PXz6X2aoUFiogX2ITeObXhZSQqhvaoTDAlqV0owjHWiiPOuE8ECRyccAVT4bDWP29bA1 wizA== X-Gm-Message-State: APjAAAU9+L9azPtyRFHGuN1eQeNxQDYiWLvg2nleXjBU2kyiDZR6MuEK WKu0HKf7JMzAYTOjCuApLNSCENfyxtE= X-Received: by 2002:a17:902:bd95:: with SMTP id q21mr35435241pls.159.1558298286396; Sun, 19 May 2019 13:38:06 -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.05 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:05 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:36:40 -0700 Message-Id: <20190519203726.20729-29-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::642 Subject: [Qemu-devel] [PATCH v7 28/74] 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.1 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 c70c06d965..4771badeb5 100644 --- a/linux-user/strace.c +++ b/linux-user/strace.c @@ -1125,19 +1125,6 @@ print_chroot(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, @@ -1179,21 +1166,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 3adb629124..fb64d5bd1d 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 18163f558c..3c0de73aa4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -5384,14 +5384,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)); @@ -6463,16 +6455,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 f56d9acf76..0906aba812 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