From patchwork Fri Jan 8 02:03:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 564558 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 3493F1402DE for ; Fri, 8 Jan 2016 13:04:17 +1100 (AEDT) Received: from localhost ([::1]:33636 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHMPX-0008Vo-5a for incoming@patchwork.ozlabs.org; Thu, 07 Jan 2016 21:04:15 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:52220) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHMPH-0008EQ-V7 for qemu-devel@nongnu.org; Thu, 07 Jan 2016 21:04:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHMPC-0006fM-Ri for qemu-devel@nongnu.org; Thu, 07 Jan 2016 21:03:59 -0500 Received: from mail113-250.mail.alibaba.com ([205.204.113.250]:59699 helo=us-alimail-mta1.hst.scl.en.alidc.net) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHMPC-0006dk-CY for qemu-devel@nongnu.org; Thu, 07 Jan 2016 21:03:54 -0500 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.1055059|-1; FP=0|0|0|0|0|-1|-1|-1; HT=e01l10435; MF=chengang@emindsoft.com.cn; NM=1; PH=DS; RN=8; RT=7; SR=0; TI=SMTPD_----4QmpHtN_1452218618; Received: from localhost.localdomain(mailfrom:chengang@emindsoft.com.cn ip:36.110.17.42) by smtp.aliyun-inc.com(10.147.39.200); Fri, 08 Jan 2016 10:03:44 +0800 From: chengang@emindsoft.com.cn To: riku.voipio@iki.fi, laurent@vivier.eu Date: Fri, 8 Jan 2016 10:03:06 +0800 Message-Id: <1452218586-4009-1-git-send-email-chengang@emindsoft.com.cn> X-Mailer: git-send-email 1.9.1 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 205.204.113.250 Cc: peter.maydell@linaro.org, Chen Gang , Chen Gang , qemu-devel@nongnu.org, rth@twiddle.net Subject: [Qemu-devel] [PATCH] linux-user: syscall: Add SO_LINGER for setsockopt X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Chen Gang Just implement it according to the other features implementations. Signed-off-by: Chen Gang --- linux-user/syscall.c | 16 +++++++++++++++- linux-user/syscall_defs.h | 5 +++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index f27148a..9f2c871 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1409,6 +1409,9 @@ static abi_long do_setsockopt(int sockfd, int level, int optname, int val; struct ip_mreqn *ip_mreq; struct ip_mreq_source *ip_mreq_source; + struct linger lg; + struct target_linger *tlg; + switch(level) { case SOL_TCP: @@ -1659,7 +1662,19 @@ set_timeout: case TARGET_SO_RCVLOWAT: optname = SO_RCVLOWAT; break; - break; + case TARGET_SO_LINGER: + optname = SO_LINGER; + if (optlen != sizeof(struct target_linger)) { + return -TARGET_EINVAL; + } + 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); + unlock_user_struct(tlg, optval_addr, 0); + return get_errno(setsockopt(sockfd, SOL_SOCKET, optname, + &lg, sizeof(lg))); default: goto unimplemented; } diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index 9d3c537..5a4d565 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -165,6 +165,11 @@ struct target_ip_mreq_source { uint32_t imr_sourceaddr; }; +struct target_linger { + int l_onoff; /* Linger active */ + int l_linger; /* How long to linger for */ +}; + struct target_timeval { abi_long tv_sec; abi_long tv_usec;