Received: from eggs.gnu.org ([2001:4830:134:3::10]:54221) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIYHM-0001Hg-El for qemu-devel@nongnu.org; Mon, 11 Jan 2016 03:56:45 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aIYHJ-0004NR-8Z for qemu-devel@nongnu.org; Mon, 11 Jan 2016 03:56:44 -0500 Received: from mout.kundenserver.de ([212.227.126.131]:58618) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aIYHI-0004Mq-VE for qemu-devel@nongnu.org; Mon, 11 Jan 2016 03:56:41 -0500 References: <1452494868-11056-1-git-send-email-chengang@emindsoft.com.cn> From: Laurent Vivier Message-ID: <56936E34.1090706@vivier.eu> Date: Mon, 11 Jan 2016 09:56:20 +0100 MIME-Version: 1.0 In-Reply-To: <1452494868-11056-1-git-send-email-chengang@emindsoft.com.cn> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH v2] linux-user: syscall: Add SO_LINGER for setsockopt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: chengang@emindsoft.com.cn, riku.voipio@iki.fi Cc: peter.maydell@linaro.org, Chen Gang , qemu-devel@nongnu.org, rth@twiddle.net Le 11/01/2016 07:47, chengang@emindsoft.com.cn a écrit : > From: Chen Gang > > Just implement it according to the other features implementations. > > Signed-off-by: Chen Gang > --- > linux-user/syscall.c | 18 +++++++++++++++++- > linux-user/syscall_defs.h | 5 +++++ > 2 files changed, 22 insertions(+), 1 deletion(-) > > diff --git a/linux-user/syscall.c b/linux-user/syscall.c > index 4c68800..fcdca2a 100644 > --- a/linux-user/syscall.c > +++ b/linux-user/syscall.c > @@ -1410,6 +1410,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: > @@ -1661,7 +1664,20 @@ 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); > + ret = get_errno(setsockopt(sockfd, SOL_SOCKET, optname, > + &lg, sizeof(lg))); > + unlock_user_struct(tlg, optval_addr, 0); > + return ret; I think it should be moved before the "/* Options with 'int' argument */" comment. Except that, it is good. > default: > goto unimplemented; > } > diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h > index f996acf..6591e74 100644 > --- a/linux-user/syscall_defs.h > +++ b/linux-user/syscall_defs.h > @@ -166,6 +166,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; >