From patchwork Tue Sep 19 23:06:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Carlo_Marcelo_Arenas_Bel=C3=B3n?= X-Patchwork-Id: 9960471 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CA3FB6038F for ; Tue, 19 Sep 2017 23:08:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id BD3BB28EC5 for ; Tue, 19 Sep 2017 23:08:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B228228ECC; Tue, 19 Sep 2017 23:08:31 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 6B56928EC5 for ; Tue, 19 Sep 2017 23:08:31 +0000 (UTC) Received: from localhost ([::1]:45800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duRd0-00056a-KS for patchwork-qemu-devel@patchwork.kernel.org; Tue, 19 Sep 2017 19:08:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duRbn-00054O-DG for qemu-devel@nongnu.org; Tue, 19 Sep 2017 19:07:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duRbj-00017p-JI for qemu-devel@nongnu.org; Tue, 19 Sep 2017 19:07:15 -0400 Received: from mail-it0-x243.google.com ([2607:f8b0:4001:c0b::243]:35923) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1duRbj-00017g-EI for qemu-devel@nongnu.org; Tue, 19 Sep 2017 19:07:11 -0400 Received: by mail-it0-x243.google.com with SMTP id e134so576517ite.3 for ; Tue, 19 Sep 2017 16:07:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=z4hSSACXCraJebw58pteGr05psbmD0sks3tMHxxg2a4=; b=U32Gq4smk1pE/8F6um+4w4Ij7NdW7j6wJRew1EpJV/CNH0dc5wdUKFg1S23QIUhj73 MHa3gzY+cQAQbfFrOB9LmKYpfqSQHvYx9smzUmKu4xmvY5opss86S9fCoHXeZGA9+kOs XgPNShPTv+ZWfgmh3XVg3KB2SomQ1AXhZPgcC7t5JuVx8tmYndYIfiOwtlq0Vfe/TY5K OQTJdanKOBVgIWSxjHLjHf2j7tNwdSMEHpXO+aDBV5+6oAm3N+7EM9tzi7b1pWjmfqgk 08bT7+/+Axmtye0TLjtBFJkwZgpVssTvF0+Zvgg/5cYCKltADv3T+Z+MGZI/UXJnFQHp gj+w== 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:mime-version:content-transfer-encoding; bh=z4hSSACXCraJebw58pteGr05psbmD0sks3tMHxxg2a4=; b=b2m38H44eFTxWl50lya16TP2WD1///uby7ClWDOtHZdtEr4s13n6A7AGd38BDKWzwB gNYWcIoB8H4daGpibOBmZo5/dzagPdG4udvlJVBPnOnUfZHJqsBpGTYf07XVbM8Wsl/1 XI5+O7B8A2kzRgh4lrXvBBZe6rMVsps0yHMUNLpfm7JoU8ZrNcu49pqDdPvip1jM5f9f ZgckVrl3iunV5h0hQE3kxqp+Rys11gJJ3NIYQAGJlHyZKmaFFiVeWxijbMiCRsTCPhZ6 dunEPZ14e6EjR9eeSjDnH3dtZzvukXTytS8YjMBWR6AFQMQUxtx8RZF/ugSYBbQLMf8t erCA== X-Gm-Message-State: AHPjjUjwaYR3eFz+VJn7g2upr23QEZQOE/Ha6IbIYS3rXsl0/Ph2erlD j7Y4c8F3jhbRljEGc6OJgPk9rpbJ X-Google-Smtp-Source: AOwi7QCrVJBkU5QRL3UEA60M+VDg/+G5CPYoQLyQ0HyYfPg7A8OYmb4lIfYxrzyGzR4odV8OS+23PQ== X-Received: by 10.36.181.22 with SMTP id v22mr293012ite.139.1505862430711; Tue, 19 Sep 2017 16:07:10 -0700 (PDT) Received: from 172-11-32-171.lightspeed.mmphtn.sbcglobal.net (50-207-95-178-static.hfc.comcastbusiness.net. [50.207.95.178]) by smtp.gmail.com with ESMTPSA id z63sm1544033itf.23.2017.09.19.16.07.09 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Sep 2017 16:07:09 -0700 (PDT) From: =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= To: qemu-devel@nongnu.org Date: Tue, 19 Sep 2017 16:06:43 -0700 Message-Id: <20170919230643.87425-3-carenas@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170919230643.87425-1-carenas@gmail.com> References: <20170919230643.87425-1-carenas@gmail.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4001:c0b::243 Subject: [Qemu-devel] [PATCH 3/3] linux-user: add SO_LINGER to getsockopt 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: peter.maydell@linaro.org, gang.chen.5i5j@gmail.com, riku.voipio@iki.fi, laurent@vivier.eu, =?UTF-8?q?Carlo=20Marcelo=20Arenas=20Bel=C3=B3n?= , rth@twiddle.net Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Carlo Marcelo Arenas Belón Reviewed-by: Laurent Vivier --- linux-user/syscall.c | 34 +++++++++++++++++++++++++++++++++- 1 file changed, 33 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index ad689dad50..91bd27c63a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3178,7 +3178,6 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, level = SOL_SOCKET; switch (optname) { /* These don't just return a single integer */ - case TARGET_SO_LINGER: case TARGET_SO_RCVTIMEO: case TARGET_SO_SNDTIMEO: case TARGET_SO_PEERNAME: @@ -3216,6 +3215,39 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, } break; } + case TARGET_SO_LINGER: + { + struct linger lg; + socklen_t lglen; + struct target_linger *tlg; + + if (get_user_u32(len, optlen)) { + return -TARGET_EFAULT; + } + if (len < 0) { + return -TARGET_EINVAL; + } + + lglen = sizeof(lg); + ret = get_errno(getsockopt(sockfd, level, SO_LINGER, + &lg, &lglen)); + if (ret < 0) { + return ret; + } + if (len > lglen) { + len = lglen; + } + if (!lock_user_struct(VERIFY_WRITE, tlg, optval_addr, 0)) { + return -TARGET_EFAULT; + } + __put_user(lg.l_onoff, &tlg->l_onoff); + __put_user(lg.l_linger, &tlg->l_linger); + unlock_user_struct(tlg, optval_addr, 1); + if (put_user_u32(len, optlen)) { + return -TARGET_EFAULT; + } + break; + } /* Options with 'int' argument. */ case TARGET_SO_DEBUG: optname = SO_DEBUG;