From patchwork Sun Jun 10 03:01:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 138129 Delivered-To: patch@linaro.org Received: by 2002:a2e:970d:0:0:0:0:0 with SMTP id r13-v6csp2595051lji; Sat, 9 Jun 2018 20:41:13 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIuiRfT7C728ThP4KF0ybie9lbOHekebXVu+ctQL5UjAt8qvNZavm078bqXJBbtI89yDfkQ X-Received: by 2002:ac8:4603:: with SMTP id p3-v6mr11767453qtn.418.1528602073367; Sat, 09 Jun 2018 20:41:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1528602073; cv=none; d=google.com; s=arc-20160816; b=mwYU2NFZVbFJys/KWnrCdIeA+YHbeMGqfVQJvlvnMSw6SXRdrVepE4EK5tfYWX+jh9 Vp7Rlpj0Ufh374kOsc/LtirXxrnbreVcPxMBRD+sriUiQBqxasgNRiKDros/OCjXoWs2 /OwE8dH++yyO+CcDL1j4QwMs/LTna2M8HLYIsUE9gdXIyRqOirYFtbLXd1cA7N2pYhRm mrus7wtwvn3UM0SeRRyYvS8anKRFDRQcNCngvt0Bi1ovy2lbvt/UOJm4/ZdSDZnzZ96s OGMk9pari+lJcoZrgFHYRLET4/hZ7ufDkLDsK7+rb72+4bwwf1kQTt2X3d3vos0CfwuD HRlg== 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:arc-authentication-results; bh=kc0hgGrcRSKNkw5JFcIBERDb7+5rWbSVFM7jobrTo9w=; b=mkDZhrJo5EpNf9iqwVlz4Tlozh76QMc+SXeNcxS0oeuXFzIaNCZ1wJgdOiOP5DYx/i WJq1ydwUmfjDd0cLJJuglg73xNXeqv4eGbvPPaCN+wpPufABUPDK/+3c3NGDovJ9VPFw W/+MT2o5N+Unjuy73mXSTP3FPDVgwpiRJJfxuWsW46UNRm6zh975xeJi6Ep0LWm+jH6f zGucx2dK0BtEm1k1S4XUVHtL+zZkHLpahQTG5saIZ82XJMArxeQWxgvZZdZfddoAfjq9 KvROdlYni4WgjbC0U37kWzoh4AhT9nMQgvzOvMdlwK7TjUg2lejVUh3B64XNwJsJTGGy Wa9g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QF6539FI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id m42-v6si7794755qvm.136.2018.06.09.20.41.13 for (version=TLS1 cipher=AES128-SHA bits=128/128); Sat, 09 Jun 2018 20:41:13 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@linaro.org header.s=google header.b=QF6539FI; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 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 ([::1]:42388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRrE8-0002WM-PI for patch@linaro.org; Sat, 09 Jun 2018 23:41:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41093) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fRqf3-0003hf-Ey for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fRqf0-00048T-6v for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:57 -0400 Received: from mail-pg0-x22a.google.com ([2607:f8b0:400e:c05::22a]:34313) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fRqf0-00047e-1k for qemu-devel@nongnu.org; Sat, 09 Jun 2018 23:04:54 -0400 Received: by mail-pg0-x22a.google.com with SMTP id q4-v6so7075239pgr.1 for ; Sat, 09 Jun 2018 20:04:53 -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=kc0hgGrcRSKNkw5JFcIBERDb7+5rWbSVFM7jobrTo9w=; b=QF6539FIIfR9jbBCp97gR1i7qTsurZtQuXlhZk2XEBsPi9VvDJmJM7+D4YaEAN9VNR w93dxJnZwXDcCDTbBpm8kUB3NsKhxXyDCCwvDksdV+/IpyeFhJD+ZLVz1AimU8yYQFY0 qK3leQd/FJ3HjBfTt1CBnMPtFNUFDLPVUnUK4= 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=kc0hgGrcRSKNkw5JFcIBERDb7+5rWbSVFM7jobrTo9w=; b=YDgxJMP5jw6fZnQ9N4CYrS+3XKpRYN6Tz9zWb8vmAenS+yjWDP4mFjE7sSPdwUj9TY G8edpxlIH7S/g0KqF/HA+pSY2aaOFWK6c6VO9xeshilzED2gpg33n7Pb2l3XbsRKB0Yj Luft6YZX7Nvc+L4o5RvodgUYCOthGtNvHw6ABbtDG2lrIy73EXiM6xsgxrlBJzFB/iO6 7HOZdcRq71veFreiOgJ7aeHZ8Klc0Nz4F+FnUx7QkqJItQZm+7Yc96FQPbwRYoCNOYCQ dmN06p3WjUPuVxzEmcS0eMQH1nVuSVLaR6K+Hwnz2EyE02IkjFGxtOM5e2Na5c5gwATg FjIg== X-Gm-Message-State: APt69E3b2HmiJ4iIe5q5A+cuSFCNLqwA80cMSLgB6Vi60SFAbJ0fHRI+ mPN8xD9w8GbrRrVJnvrF45WibgQ43Bw= X-Received: by 2002:a63:83c3:: with SMTP id h186-v6mr10120702pge.298.1528599892796; Sat, 09 Jun 2018 20:04:52 -0700 (PDT) Received: from cloudburst.twiddle.net (rrcs-173-198-77-219.west.biz.rr.com. [173.198.77.219]) by smtp.gmail.com with ESMTPSA id y17-v6sm31712718pfe.33.2018.06.09.20.04.51 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Sat, 09 Jun 2018 20:04:51 -0700 (PDT) From: Richard Henderson To: qemu-devel@nongnu.org Date: Sat, 9 Jun 2018 17:01:41 -1000 Message-Id: <20180610030220.3777-70-richard.henderson@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180610030220.3777-1-richard.henderson@linaro.org> References: <20180610030220.3777-1-richard.henderson@linaro.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::22a Subject: [Qemu-devel] [PATCH v2 069/108] linux-user: Split out sendfile, sendfile64 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.c | 92 +++++++++++++++++++++++--------------------- 1 file changed, 48 insertions(+), 44 deletions(-) -- 2.17.1 diff --git a/linux-user/syscall.c b/linux-user/syscall.c index c906719152..39e416db0b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -10284,6 +10284,48 @@ IMPL(send) } #endif +#ifdef CONFIG_SENDFILE +IMPL(sendfile) +{ + abi_long ret; + off_t off; + + if (!arg3) { + return get_errno(sendfile(arg1, arg2, NULL, arg4)); + } + + if (get_user_sal(off, arg3)) { + return -TARGET_EFAULT; + } + ret = get_errno(sendfile(arg1, arg2, &off, arg4)); + if (!is_error(ret) && arg3 && put_user_sal(off, arg3)) { + return -TARGET_EFAULT; + } + return ret; +} + +# ifdef TARGET_NR_sendfile64 +IMPL(sendfile64) +{ + abi_long ret; + off_t off; + + if (!arg3) { + return get_errno(sendfile(arg1, arg2, NULL, arg4)); + } + + if (get_user_s64(off, arg3)) { + return -TARGET_EFAULT; + } + ret = get_errno(sendfile(arg1, arg2, &off, arg4)); + if (!is_error(ret) && arg3 && put_user_s64(off, arg3)) { + return -TARGET_EFAULT; + } + return ret; +} +# endif +#endif /* CONFIG_SENDFILE */ + #ifdef TARGET_NR_sendmsg IMPL(sendmsg) { @@ -11265,50 +11307,6 @@ static abi_long do_syscall1(void *cpu_env, unsigned num, abi_long arg1, void *p; switch(num) { -#ifdef CONFIG_SENDFILE - case TARGET_NR_sendfile: - { - off_t *offp = NULL; - off_t off; - if (arg3) { - ret = get_user_sal(off, arg3); - if (is_error(ret)) { - return ret; - } - offp = &off; - } - ret = get_errno(sendfile(arg1, arg2, offp, arg4)); - if (!is_error(ret) && arg3) { - abi_long ret2 = put_user_sal(off, arg3); - if (is_error(ret2)) { - ret = ret2; - } - } - return ret; - } -#ifdef TARGET_NR_sendfile64 - case TARGET_NR_sendfile64: - { - off_t *offp = NULL; - off_t off; - if (arg3) { - ret = get_user_s64(off, arg3); - if (is_error(ret)) { - return ret; - } - offp = &off; - } - ret = get_errno(sendfile(arg1, arg2, offp, arg4)); - if (!is_error(ret) && arg3) { - abi_long ret2 = put_user_s64(off, arg3); - if (is_error(ret2)) { - ret = ret2; - } - } - return ret; - } -#endif -#endif #ifdef TARGET_NR_vfork case TARGET_NR_vfork: return get_errno(do_fork(cpu_env, @@ -13270,6 +13268,12 @@ static impl_fn *syscall_table(unsigned num) #ifdef TARGET_NR_send SYSCALL(send); #endif +#ifdef CONFIG_SENDFILE + SYSCALL(sendfile); +# ifdef TARGET_NR_sendfile64 + SYSCALL(sendfile64); +# endif +#endif #ifdef TARGET_NR_sendmmsg SYSCALL(sendmmsg); #endif