From patchwork Fri Dec 3 13:36:32 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Riku@afflict.kos.to, Voipio@afflict.kos.to X-Patchwork-Id: 74144 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id BEA6CB7043 for ; Sat, 4 Dec 2010 00:54:22 +1100 (EST) Received: from localhost ([127.0.0.1]:55610 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POW5b-0003VC-Qj for incoming@patchwork.ozlabs.org; Fri, 03 Dec 2010 08:54:19 -0500 Received: from [140.186.70.92] (port=60358 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1POVof-0003oz-MG for qemu-devel@nongnu.org; Fri, 03 Dec 2010 08:36:56 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1POVoc-0008OV-Hw for qemu-devel@nongnu.org; Fri, 03 Dec 2010 08:36:49 -0500 Received: from afflict.kos.to ([92.243.29.197]:44052) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1POVoc-0008Ng-8W for qemu-devel@nongnu.org; Fri, 03 Dec 2010 08:36:46 -0500 Received: by afflict.kos.to (Postfix, from userid 1000) id B77B526679; Fri, 3 Dec 2010 13:36:43 +0000 (UTC) From: Riku@afflict.kos.to, Voipio@afflict.kos.to To: qemu-devel@nongnu.org Date: Fri, 3 Dec 2010 15:36:32 +0200 Message-Id: X-Mailer: git-send-email 1.6.5 In-Reply-To: References: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 3) Cc: Jamie Lentin Subject: [Qemu-devel] [PATCH 05/16] linux-user: Translate getsockopt level option X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Jamie Lentin n setsockopt, the socket level options are translated to the hosts' architecture before the real syscall is called, e.g. TARGET_SO_TYPE -> SO_TYPE. This patch does the same with getsockopt. Tested on a x86 host emulating MIPS. Without it:- $ grep getsockopt host.strace 31311 getsockopt(3, SOL_SOCKET, 0x1007 /* SO_??? */, 0xbff17208, 0xbff17204) = -1 ENOPROTOOPT (Protocol not available) With:- $ grep getsockopt host.strace 25706 getsockopt(3, SOL_SOCKET, SO_ERROR, [0], [4]) = 0 Whitespace cleanup: Riku Voipio Signed-off-by: Jamie Lentin Signed-off-by: Riku Voipio --- linux-user/syscall.c | 71 +++++++++++++++++++++++++++++++++++++++++++------- 1 files changed, 61 insertions(+), 10 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 5761106..070241b 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1374,15 +1374,66 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, switch(level) { case TARGET_SOL_SOCKET: - level = SOL_SOCKET; - switch (optname) { - case TARGET_SO_LINGER: - case TARGET_SO_RCVTIMEO: - case TARGET_SO_SNDTIMEO: - case TARGET_SO_PEERCRED: - case TARGET_SO_PEERNAME: - /* These don't just return a single integer */ - goto unimplemented; + 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_PEERCRED: + case TARGET_SO_PEERNAME: + goto unimplemented; + /* Options with 'int' argument. */ + case TARGET_SO_DEBUG: + optname = SO_DEBUG; + goto int_case; + case TARGET_SO_REUSEADDR: + optname = SO_REUSEADDR; + goto int_case; + case TARGET_SO_TYPE: + optname = SO_TYPE; + goto int_case; + case TARGET_SO_ERROR: + optname = SO_ERROR; + goto int_case; + case TARGET_SO_DONTROUTE: + optname = SO_DONTROUTE; + goto int_case; + case TARGET_SO_BROADCAST: + optname = SO_BROADCAST; + goto int_case; + case TARGET_SO_SNDBUF: + optname = SO_SNDBUF; + goto int_case; + case TARGET_SO_RCVBUF: + optname = SO_RCVBUF; + goto int_case; + case TARGET_SO_KEEPALIVE: + optname = SO_KEEPALIVE; + goto int_case; + case TARGET_SO_OOBINLINE: + optname = SO_OOBINLINE; + goto int_case; + case TARGET_SO_NO_CHECK: + optname = SO_NO_CHECK; + goto int_case; + case TARGET_SO_PRIORITY: + optname = SO_PRIORITY; + goto int_case; +#ifdef SO_BSDCOMPAT + case TARGET_SO_BSDCOMPAT: + optname = SO_BSDCOMPAT; + goto int_case; +#endif + case TARGET_SO_PASSCRED: + optname = SO_PASSCRED; + goto int_case; + case TARGET_SO_TIMESTAMP: + optname = SO_TIMESTAMP; + goto int_case; + case TARGET_SO_RCVLOWAT: + optname = SO_RCVLOWAT; + goto int_case; default: goto int_case; } @@ -1406,7 +1457,7 @@ static abi_long do_getsockopt(int sockfd, int level, int optname, } else { if (put_user_u8(val, optval_addr)) return -TARGET_EFAULT; - } + } if (put_user_u32(len, optlen)) return -TARGET_EFAULT; break;