From patchwork Tue Sep 19 23:06:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Carlo Arenas X-Patchwork-Id: 815931 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Qjg/tL4S"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxdng4jYbz9s7F for ; Wed, 20 Sep 2017 09:07:42 +1000 (AEST) Received: from localhost ([::1]:45798 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duRc8-0004zh-Kx for incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 19:07:36 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duRbc-0004zS-C5 for qemu-devel@nongnu.org; Tue, 19 Sep 2017 19:07:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duRbX-0000tI-Ag for qemu-devel@nongnu.org; Tue, 19 Sep 2017 19:07:04 -0400 Received: from mail-it0-x243.google.com ([2607:f8b0:4001:c0b::243]:35921) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1duRbX-0000sC-5A for qemu-devel@nongnu.org; Tue, 19 Sep 2017 19:06:59 -0400 Received: by mail-it0-x243.google.com with SMTP id e134so576348ite.3 for ; Tue, 19 Sep 2017 16:06:59 -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=WBV0AzFZLn44L9sTSYD0gdxn/vLIZD0JvpG2stRHh88=; b=Qjg/tL4SCDrcXdZan4bJYOJVaksqKgNDgq+aWzA+oAmaWfSX6vDFB/CxSELVLQLKQc U5XdIOp5zIE4VP1rVZ6AapY1vQvQRmzaGEC8NzTTVjefTaKmAZzXv3bTf4OrtPADq8E5 qZxl6a1m+pYoF4Ei5sAVKRgVfQ9Ks9eRM6bjHWRvlLrknXn0xCb3IUKFGwQpF/mH/TEE doti5AE4gmFf8Hsyie7M0s8qxpWw/XjAXMDpl/RDglYN01EwBF1J16Yo7A8D2EQqRpbg 8agxc/GNmSuRrQunmNWr650zDQaYXdWPP/V+rQMKhDA0CkOmRuOjk5uIrfWP2NpL8QKC b6Bw== 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=WBV0AzFZLn44L9sTSYD0gdxn/vLIZD0JvpG2stRHh88=; b=GcTBT9BNdLGmeFiQfGb3V9ysLFCLQPv1ZxUfDXfA9wMvaMwcX97/DUJeAupYypJz1p zRKiz8mCI1zor/cZ0p5Xj7wmL/KNzDqn8eoXsUV3SEuFXzDHNqVFKXIzkGWKS7Gci9U6 o0HN1qnvy/aQlHsz1Knr0yOP7BtMHI3iyiqO/x7x9XfpSsWGmUm8q7wYg9hWPrOAAzhR PaHrn5QmKs1mNIJaxj1ZLWKnZ+DD1USEfHqtZV3JCz1s4Ik9s2e3ES6ftGQcSQG1fod0 TY+XVWHj0mEwmqSu9k6gE80ZA1ENSh1rqOgcuCaam4aO+z8/Mt4WrbbcTfHlNlrO93ld AK6Q== X-Gm-Message-State: AHPjjUgo1ydPA/DNRYeGXYDXe340Fe0B/My/yRr9dqKiQAHiZor3Dcjt K6TQu2YJe93iScb+JANkRDcTfMAn X-Google-Smtp-Source: AOwi7QBlChk1ko6MsyUldWKzoHfBlEQMLYMMcM1qsbrIb2duDjJMvRt2pkmsbKrhlaOU66WI7SequQ== X-Received: by 10.36.95.10 with SMTP id r10mr291430itb.73.1505862418007; Tue, 19 Sep 2017 16:06:58 -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.06.56 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Sep 2017 16:06:57 -0700 (PDT) From: =?utf-8?q?Carlo_Marcelo_Arenas_Bel=C3=B3n?= To: qemu-devel@nongnu.org Date: Tue, 19 Sep 2017 16:06:41 -0700 Message-Id: <20170919230643.87425-1-carenas@gmail.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: References: 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 1/3] linux-user: fix TARGET_SO_LINGER for sparc 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_Marcelo_Arenas_Bel=C3=B3n?= , rth@twiddle.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Signed-off-by: Carlo Marcelo Arenas Belón --- linux-user/socket.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/linux-user/socket.h b/linux-user/socket.h index 7051cd2cf4..129f9b4713 100644 --- a/linux-user/socket.h +++ b/linux-user/socket.h @@ -246,8 +246,12 @@ #define TARGET_SOCK_MAX (TARGET_SOCK_PACKET + 1) #define TARGET_SOCK_TYPE_MASK 0xf /* Covers up to TARGET_SOCK_MAX-1. */ + #define TARGET_SO_LINGER 0x0080 + #define TARGET_SO_PASSSEC 31 #else + #define TARGET_SO_LINGER 13 + #define TARGET_SO_PASSSEC 34 #endif @@ -268,7 +272,7 @@ #define TARGET_SO_OOBINLINE 10 #define TARGET_SO_NO_CHECK 11 #define TARGET_SO_PRIORITY 12 - #define TARGET_SO_LINGER 13 + #define TARGET_SO_BSDCOMPAT 14 /* To add :#define TARGET_SO_REUSEPORT 15 */ #if defined(TARGET_PPC) From patchwork Tue Sep 19 23:06:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Carlo Arenas X-Patchwork-Id: 815932 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Ebrt3lEb"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxdnq5WFBz9s7F for ; Wed, 20 Sep 2017 09:07:59 +1000 (AEST) Received: from localhost ([::1]:45799 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duRcT-00054i-Lp for incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 19:07:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:32888) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duRbh-00051A-Ku for qemu-devel@nongnu.org; Tue, 19 Sep 2017 19:07:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1duRbg-00015M-NT for qemu-devel@nongnu.org; Tue, 19 Sep 2017 19:07:09 -0400 Received: from mail-io0-x244.google.com ([2607:f8b0:4001:c06::244]:35503) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1duRbg-00014s-HX for qemu-devel@nongnu.org; Tue, 19 Sep 2017 19:07:08 -0400 Received: by mail-io0-x244.google.com with SMTP id d16so1153269ioj.2 for ; Tue, 19 Sep 2017 16:07:08 -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=11R+z2KKJ5gPRkpvOVi8PqWysi5cQNtTuZU6eVx1NTA=; b=Ebrt3lEb4JTbE6M9eaQ3vyxV2lLH2koF+ZLAHD2QkgSK/dfkUMbjBOhAdIcjDlCSDP a3aKjKFSZUkwzvXNYC6Rw5YDJFsy7LQ3aCMG9N5b15AtnA2g+vPUOa58U6k1aOU/i+rr RL1GwGLeXXE3GBhNnAR4Mb3SaFA6ISZC5qYh3Vo1b+cjozYRi/t9q2z9k5AABaAF0V8F VBxXe6t5vqhiZHl5bzz4nH/ieGgHYEsU2YdOIlBYjRc0qc4Vw6W5dsql8sGAJ2l9/4Ms IXkCcHmBWN6FhJ2u43F0IwaRvicSOHqfF5v/1yTgYh9IJCCSypeksFzvx6G9ulK5jzXP sa3A== 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=11R+z2KKJ5gPRkpvOVi8PqWysi5cQNtTuZU6eVx1NTA=; b=oRjP/OnQ2c3YzxgUfmaZwTDp3bqDlvSYe+VXLpXPNmqzj8B2QqraaReHpYvU/vlfgD jM9QvgrIrThKlDY0Mcq/wO1kQMktMreIJfMObxPS69Z7B3XCUQladtSpz0YScVYluJZG /0gjvdZNTC1VwlZ4CY3eU9JyFicDiKgdbAXnkEQd3XHMRmydhjZ/w2oargnZIpXbdrdm CRDrhvRqISndTDAost2xkleZ5nJ4AqdEX1L9EMoni4P64Fe1Ob2VDWGmNDhl8nQiMUjJ 7xXj+eIz2F/Xb+BZomGcWyG/EIK5qkaCZH/Jlsmf+BCybEO59ZjnKExXYJOnaqu0a+PN rkRA== X-Gm-Message-State: AHPjjUhGr0h/JeQt6IIFfTbRYHY07ass5ODaJqrKzn6syhraXD1a6IRF actxlBAzIOfTt9wm3hhBL35xYv+K X-Google-Smtp-Source: AOwi7QB2nGhSCtztsQcACSsoMwC7wB0JNeEtNP3pKmWUHPPD9oxw4bSEv0gjVBzIKlbJy87g2gmpkA== X-Received: by 10.107.38.202 with SMTP id m193mr4591610iom.98.1505862427648; Tue, 19 Sep 2017 16:07:07 -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.05 (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 19 Sep 2017 16:07:06 -0700 (PDT) From: =?utf-8?q?Carlo_Marcelo_Arenas_Bel=C3=B3n?= To: qemu-devel@nongnu.org Date: Tue, 19 Sep 2017 16:06:42 -0700 Message-Id: <20170919230643.87425-2-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:c06::244 Subject: [Qemu-devel] [PATCH 2/3] linux-user: add SO_LINGER to setsockopt 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_Marcelo_Arenas_Bel=C3=B3n?= , rth@twiddle.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Original implementation by Chen Gang; all bugs mine Signed-off-by: Chen Gang Signed-off-by: Carlo Marcelo Arenas Belón --- linux-user/syscall.c | 15 +++++++++++++++ linux-user/syscall_defs.h | 5 +++++ 2 files changed, 20 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 9b6364a266..ad689dad50 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -3071,6 +3071,21 @@ set_timeout: unlock_user (dev_ifname, optval_addr, 0); return ret; } + case TARGET_SO_LINGER: + { + struct linger lg; + struct target_linger *tlg; + + if (!lock_user_struct(VERIFY_READ, tlg, optval_addr, 1)) { + return -TARGET_EFAULT; + } + __get_user(lg.l_onoff, &tlg->l_onoff); + __get_user(lg.l_linger, &tlg->l_linger); + ret = get_errno(setsockopt(sockfd, SOL_SOCKET, SO_LINGER, + &lg, optlen)); + unlock_user_struct(tlg, optval_addr, 0); + return ret; + } /* Options with 'int' argument. */ case TARGET_SO_DEBUG: optname = SO_DEBUG; diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 40c5027e93..a60d6bb163 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -202,6 +202,11 @@ struct target_ip_mreq_source { uint32_t imr_sourceaddr; }; +struct target_linger { + abi_int l_onoff; /* Linger active */ + abi_int l_linger; /* How long to linger for */ +}; + struct target_timeval { abi_long tv_sec; abi_long tv_usec; 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: Carlo Arenas X-Patchwork-Id: 815933 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="U32Gq4sm"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xxdnt5ZtNz9s7F for ; Wed, 20 Sep 2017 09:08:02 +1000 (AEST) Received: from localhost ([::1]:45800 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1duRcW-00056a-Rz for incoming@patchwork.ozlabs.org; Tue, 19 Sep 2017 19:08:00 -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_Marcelo_Arenas_Bel=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_Marcelo_Arenas_Bel=C3=B3n?= , rth@twiddle.net Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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;