From patchwork Sun May 19 20:37:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 164561 Delivered-To: patch@linaro.org Received: by 2002:a92:9e1a:0:0:0:0:0 with SMTP id q26csp4815664ili; Sun, 19 May 2019 14:32:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqx5xLyE6yCalT2ex/AvKLpnsi+oUXL7hXZsO1YutGoJaQpsfsqF4eaHKbVyVWtO+ojOIlHE X-Received: by 2002:a17:906:1315:: with SMTP id w21mr19760941ejb.193.1558301576686; Sun, 19 May 2019 14:32:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1558301576; cv=none; d=google.com; s=arc-20160816; b=YiswpN5eGylpd50eoDbBYLcNdC2acj9b9XomrFB01uunEsVHQu1dd1k5Fp7wkDj86F I/4v6UyevhH5G59QGAfJ1T5kNw2gnYK15gpAFjQeLNDq6tSTxpV6K/vuN+cVhyUKlCrj SY8ojVYHCSWR4OdutDJXNyX8eLcZ9egAMP8LwI7PrpI6y8bD+d1ffMPsX2fhNNyelqi8 kbVnz+jOsw4zO0+t7j5iUTk84JhIXDdtX53KmAQ+XOapengToBhTbDfIMg8xUIcgAC+Z jcJMd87utvOZB5mQiFyfuXaKIrNdwemX2LMrFjEcpytGj6pCZhE2QAtFs+uDQplHCFEM tgUA== 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=81B5oVWex5Gu+YUrZz7czpuJcnBNioLb7beqWXgK+Ug=; b=J07H28hJTczvyuyoSnPqS4lNd0eHTEjngLytpnQbNdcP/1+LTjD5NJCPLCBOjq8UCp PlBlvH11C/GZzcEUGbjknlxjOMg6Dy6kr8c63J7IWeJv2IfmroDCINIxm3AaT2rXKT31 p0q4TOaOWbYEO1Mh5EzVTprlo79jR2a4HlUwr5Xwl83cRpvpEgVM3gFvi3p3Q3hiVzC7 2FoOn3EPoZLGgrh45Qfd1OY2/qb22Ejp4stxvj3/3uNQHaa2WM54buWXDf5ou/67N7Eo /GYpjSz1cnxuAulkk/YMEKn7owAFDZ1XMAohw+rPQRwwXjr1bRov7dtwxcg7ndpU6z1W FQFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=MW276PEe; 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 r16si104119ejj.69.2019.05.19.14.32.56 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sun, 19 May 2019 14:32:56 -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=MW276PEe; 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]:53949 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSTQN-0000qR-Gq for patch@linaro.org; Sun, 19 May 2019 17:32:55 -0400 Received: from eggs.gnu.org ([209.51.188.92]:51248) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hSSaD-0004Ab-Sd for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hSSaC-00059o-L2 for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:01 -0400 Received: from mail-pg1-x544.google.com ([2607:f8b0:4864:20::544]:34659) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hSSaC-00058x-EW for qemu-devel@nongnu.org; Sun, 19 May 2019 16:39:00 -0400 Received: by mail-pg1-x544.google.com with SMTP id c13so5748377pgt.1 for ; Sun, 19 May 2019 13:39:00 -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=81B5oVWex5Gu+YUrZz7czpuJcnBNioLb7beqWXgK+Ug=; b=MW276PEeOF33ylNFozQxdOOz4TXNh6y0F6sLo8pPFZpkVOf33zi0mx3NAOsdQbdU3+ 7uho8rBFL2KXgpj5fqeWy7CVguXwrPipVelVHIcoKAg+4WL/hjTuDwIBvjKTZ4Q0+ZKX vNYAiXFY+DOKMHCHwESEySq3ZdqaICyfZBhy29W/aa1xUQAV9wpw40srFj2paVYrZf7/ y7x9Cs5PBJtN9MBzlbeWV8qJTcu1j0IMXl2wR5qtS4oc7CNPOnRnOD3muDf2RL/3+TvB 8WkIrnTB1Lx5zaf9Wlljd9AmFWYrw5Pdn6H4RGZd47sn6T2dJDDApZyveZUlYBIrmduo 73Cw== 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=81B5oVWex5Gu+YUrZz7czpuJcnBNioLb7beqWXgK+Ug=; b=Eud5Ar/3PYTi++pMudBeCJnx3ZVyE4BCun9M4vo5E8HhOtKiiJ168IyC5bnHSGOK3a c5mLU6R2IdOpWli2L1kNghnCE1YiGqSZhw+K4/9+kfsN6Et+bRPpzfAvLcS6MWoCra1R QBTZgquNws2PmjoOqNicb/kLqNEAmm+ABlkmoC4VqM2PfKNxo8KBKqo5ZJM0vOzAXFJ5 T3nrBmbDpV6dvfNIuIiXYmeAf7pmO20+bL5eW3jFCOq+gXIUAtNkThsob3bDgDNmGjfP QARoQ758KciYx1DbhaWDXTocpo1FB9uPpVvfoedgZFDpluEgcYTzlwiNFeyGeEUOwdUC oW8w== X-Gm-Message-State: APjAAAVQozMJ5yO9qMG7VrExIoKOgszP4SM3GYH9wdMlZB3/XD7qvTWY Xh3qbrHpagXmZ6c1Cpnd1gVpUH8xr+E= X-Received: by 2002:a63:374b:: with SMTP id g11mr15575741pgn.421.1558298339261; Sun, 19 May 2019 13:38:59 -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.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 19 May 2019 13:38:58 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sun, 19 May 2019 13:37:25 -0700 Message-Id: <20190519203726.20729-74-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::544 Subject: [Qemu-devel] [PATCH v7 73/74] linux-user: Split out truncate, truncate64, ftruncate, ftruncate64 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" Signed-off-by: Richard Henderson --- linux-user/syscall-defs.h | 16 +++++++++++++++ linux-user/syscall-file.inc.c | 32 +++++++++++++++++++++++++++++ linux-user/syscall.c | 38 ----------------------------------- linux-user/strace.list | 12 ----------- 4 files changed, 48 insertions(+), 50 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall-defs.h b/linux-user/syscall-defs.h index 67c908448d..8b2d95d19e 100644 --- a/linux-user/syscall-defs.h +++ b/linux-user/syscall-defs.h @@ -59,6 +59,14 @@ SYSCALL_DEF(futimesat, ARG_ATDIRFD, ARG_STR, ARG_PTR); #ifdef TARGET_NR_fork SYSCALL_DEF(fork); #endif +#ifdef TARGET_NR_ftruncate +SYSCALL_DEF(ftruncate, ARG_DEC, ARG_DEC); +#endif +#ifdef TARGET_NR_ftruncate64 +SYSCALL_DEF_FULL(ftruncate64, .impl = impl_ftruncate, + .args = args_ftruncate64_truncate64, + .arg_type = { ARG_DEC, ARG_DEC64 }); +#endif #ifdef TARGET_NR_gethostname SYSCALL_DEF(gethostname, ARG_PTR, ARG_DEC); #endif @@ -292,6 +300,14 @@ SYSCALL_DEF(syncfs, ARG_DEC); SYSCALL_DEF(time, ARG_PTR); #endif SYSCALL_DEF(times, ARG_PTR); +#ifdef TARGET_NR_truncate +SYSCALL_DEF(truncate, ARG_STR, ARG_DEC); +#endif +#ifdef TARGET_NR_truncate64 +SYSCALL_DEF_FULL(truncate64, .impl = impl_truncate, + .args = args_ftruncate64_truncate64, + .arg_type = { ARG_STR, ARG_DEC64 }); +#endif SYSCALL_DEF(umask, ARG_OCT); #ifdef TARGET_NR_umount SYSCALL_DEF(umount, ARG_STR); diff --git a/linux-user/syscall-file.inc.c b/linux-user/syscall-file.inc.c index bdf42ad437..7697cb304a 100644 --- a/linux-user/syscall-file.inc.c +++ b/linux-user/syscall-file.inc.c @@ -182,6 +182,25 @@ SYSCALL_IMPL(fchmodat) return do_fchmodat(arg1, arg2, arg3); } +#ifdef TARGET_NR_ftruncate64 +# if TARGET_ABI_BITS == 32 +SYSCALL_ARGS(ftruncate64_truncate64) +{ + /* We have already assigned out[0]. */ + int off = regpairs_aligned(cpu_env, TARGET_NR_ftruncate64); + out[1] = target_offset64(in[1 + off], in[2 + off]); + return def; +} +# else +# define args_ftruncate64_truncate64 NULL +# endif +#endif + +SYSCALL_IMPL(ftruncate) +{ + return get_errno(ftruncate(arg1, arg2)); +} + #ifdef TARGET_NR_futimesat SYSCALL_IMPL(futimesat) { @@ -1319,6 +1338,19 @@ SYSCALL_IMPL(syncfs) return get_errno(syncfs(arg1)); } +SYSCALL_IMPL(truncate) +{ + char *p = lock_user_string(arg1); + abi_long ret; + + if (!p) { + return -TARGET_EFAULT; + } + ret = get_errno(truncate(p, arg2)); + unlock_user(p, arg1, 0); + return ret; +} + static abi_long do_umount2(abi_ulong target_path, int flags) { char *p = lock_user_string(target_path); diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 80e8b360a9..1b1d44bf32 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3721,20 +3721,6 @@ static inline abi_long target_truncate64(void *cpu_env, const char *arg1, } #endif -#ifdef TARGET_NR_ftruncate64 -static inline abi_long target_ftruncate64(void *cpu_env, abi_long arg1, - abi_long arg2, - abi_long arg3, - abi_long arg4) -{ - if (regpairs_aligned(cpu_env, TARGET_NR_ftruncate64)) { - arg2 = arg3; - arg3 = arg4; - } - return get_errno(ftruncate64(arg1, target_offset64(arg2, arg3))); -} -#endif - static inline abi_long target_to_host_timespec(struct timespec *host_ts, abi_ulong target_addr) { @@ -4158,18 +4144,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, void *p; switch(num) { -#ifdef TARGET_NR_truncate - case TARGET_NR_truncate: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = get_errno(truncate(p, arg2)); - unlock_user(p, arg1, 0); - return ret; -#endif -#ifdef TARGET_NR_ftruncate - case TARGET_NR_ftruncate: - return get_errno(ftruncate(arg1, arg2)); -#endif case TARGET_NR_getpriority: /* Note that negative values are valid for getpriority, so we must differentiate based on errno settings. */ @@ -5371,18 +5345,6 @@ static abi_long do_syscall1(void *cpu_env, int num, abi_long arg1, return ret; } #endif -#ifdef TARGET_NR_truncate64 - case TARGET_NR_truncate64: - if (!(p = lock_user_string(arg1))) - return -TARGET_EFAULT; - ret = target_truncate64(cpu_env, p, arg2, arg3, arg4); - unlock_user(p, arg1, 0); - return ret; -#endif -#ifdef TARGET_NR_ftruncate64 - case TARGET_NR_ftruncate64: - return target_ftruncate64(cpu_env, arg1, arg2, arg3, arg4); -#endif #ifdef TARGET_NR_stat64 case TARGET_NR_stat64: if (!(p = lock_user_string(arg1))) { diff --git a/linux-user/strace.list b/linux-user/strace.list index 3326541f17..55b617239c 100644 --- a/linux-user/strace.list +++ b/linux-user/strace.list @@ -193,12 +193,6 @@ #ifdef TARGET_NR_ftime { TARGET_NR_ftime, "ftime" , NULL, NULL, NULL }, #endif -#ifdef TARGET_NR_ftruncate -{ TARGET_NR_ftruncate, "ftruncate" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_ftruncate64 -{ TARGET_NR_ftruncate64, "ftruncate64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_futex { TARGET_NR_futex, "futex" , NULL, print_futex, NULL }, #endif @@ -1173,12 +1167,6 @@ #ifdef TARGET_NR_tkill { TARGET_NR_tkill, "tkill" , NULL, print_tkill, NULL }, #endif -#ifdef TARGET_NR_truncate -{ TARGET_NR_truncate, "truncate" , NULL, NULL, NULL }, -#endif -#ifdef TARGET_NR_truncate64 -{ TARGET_NR_truncate64, "truncate64" , NULL, NULL, NULL }, -#endif #ifdef TARGET_NR_tuxcall { TARGET_NR_tuxcall, "tuxcall" , NULL, NULL, NULL }, #endif