From patchwork Fri Jan 8 01:59:09 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Chen Gang X-Patchwork-Id: 564557 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 EFAC4140323 for ; Fri, 8 Jan 2016 13:00:18 +1100 (AEDT) Received: from localhost ([::1]:33627 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHMLg-0007QE-WB for incoming@patchwork.ozlabs.org; Thu, 07 Jan 2016 21:00:17 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49887) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHMLT-00079g-N6 for qemu-devel@nongnu.org; Thu, 07 Jan 2016 21:00:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHMLQ-0004Rz-FV for qemu-devel@nongnu.org; Thu, 07 Jan 2016 21:00:03 -0500 Received: from out21.biz.mail.alibaba.com ([205.204.114.132]:57936) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHMLQ-0004RB-0S for qemu-devel@nongnu.org; Thu, 07 Jan 2016 21:00:00 -0500 X-Alimail-AntiSpam: AC=CONTINUE; BC=0.09880184|-1; FP=0|0|0|0|0|-1|-1|-1; HT=e01l07381; MF=chengang@emindsoft.com.cn; NM=1; PH=DS; RN=7; RT=6; SR=0; TI=SMTPD_----4QmiTv8_1452218381; Received: from localhost.localdomain(mailfrom:chengang@emindsoft.com.cn ip:36.110.17.42) by smtp.aliyun-inc.com(10.147.41.178); Fri, 08 Jan 2016 09:59:47 +0800 From: chengang@emindsoft.com.cn To: riku.voipio@iki.fi, laurent@vivier.eu Date: Fri, 8 Jan 2016 09:59:09 +0800 Message-Id: <1452218349-3793-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.6.x X-Received-From: 205.204.114.132 Cc: peter.maydell@linaro.org, Chen Gang , qemu-devel@nongnu.org, rth@twiddle.net Subject: [Qemu-devel] [PATCH] linux-user/syscall.c: Add SO_RCVTIMEO and SO_SNDTIMEO for getsockopt 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 them according to the other features implementations. Signed-off-by: Chen Gang --- linux-user/syscall.c | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 12a6cd2..f27148a 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1685,6 +1685,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, abi_long ret; int len, val; socklen_t lv; + struct timeval tv; switch(level) { case TARGET_SOL_SOCKET: @@ -1692,10 +1693,30 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, 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: goto unimplemented; + + case TARGET_SO_RCVTIMEO: + optname = SO_RCVTIMEO; + goto time_case; + case TARGET_SO_SNDTIMEO: + optname = SO_SNDTIMEO; + time_case: + if (optlen < sizeof(struct target_timeval)) { + return -TARGET_EINVAL; + } + lv = sizeof(tv); + ret = get_errno(getsockopt(sockfd, level, optname, &tv, &lv)); + if (ret < 0) { + return ret; + } + if (copy_to_user_timeval(optval_addr, &tv)) { + return -TARGET_EFAULT; + } + if (put_user_u32(sizeof(struct target_timeval), optlen)) { + return -TARGET_EFAULT; + } + break; case TARGET_SO_PEERCRED: { struct ucred cr; socklen_t crlen;