Received: from eggs.gnu.org ([208.118.235.92]:57114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1StgA0-000351-9c for qemu-devel@nongnu.org; Tue, 24 Jul 2012 10:32:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Stg9u-00025Q-4e for qemu-devel@nongnu.org; Tue, 24 Jul 2012 10:32:28 -0400 Received: from mail-pb0-f45.google.com ([209.85.160.45]:57248) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Stg9t-00025L-Ua for qemu-devel@nongnu.org; Tue, 24 Jul 2012 10:32:22 -0400 Received: by pbbro12 with SMTP id ro12so12576102pbb.4 for ; Tue, 24 Jul 2012 07:32:21 -0700 (PDT) From: Jing Huang Date: Tue, 24 Jul 2012 22:33:18 +0000 Message-Id: <1343169198-9656-1-git-send-email-jing.huang.pku@gmail.com> In-Reply-To: References: Subject: [Qemu-devel] [PATCH V5 3/3] linux-user: make host_to_target_cmsg support SO_TIMESTAMP cmsg_type List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: peter.maydell@linaro.org, riku.voipio@iki.fi Signed-off-by: Jing Huang Reviewed-by: Peter Maydell --- linux-user/syscall.c | 20 ++++++++++++++++---- 1 files changed, 16 insertions(+), 4 deletions(-) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index cc2a1c3..a5fa7a7 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1347,16 +1347,28 @@ static inline abi_long host_to_target_cmsg(struct target_msghdr *target_msgh, target_cmsg->cmsg_type = tswap32(cmsg->cmsg_type); target_cmsg->cmsg_len = tswapal(TARGET_CMSG_LEN(len)); - if (cmsg->cmsg_level != TARGET_SOL_SOCKET || cmsg->cmsg_type != SCM_RIGHTS) { - gemu_log("Unsupported ancillary data: %d/%d\n", cmsg->cmsg_level, cmsg->cmsg_type); - memcpy(target_data, data, len); - } else { + if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) && + (cmsg->cmsg_type == SCM_RIGHTS)) { int *fd = (int *)data; int *target_fd = (int *)target_data; int i, numfds = len / sizeof(int); for (i = 0; i < numfds; i++) target_fd[i] = tswap32(fd[i]); + } else if ((cmsg->cmsg_level == TARGET_SOL_SOCKET) && + (cmsg->cmsg_type == SO_TIMESTAMP) && + (len == sizeof(struct timeval))) { + /* copy struct timeval to target */ + struct timeval *tv = (struct timeval *)data; + struct target_timeval *target_tv = + (struct target_timeval *)target_data; + + target_tv->tv_sec = tswapl(tv->tv_sec); + target_tv->tv_usec = tswapl(tv->tv_usec); + } else { + gemu_log("Unsupported ancillary data: %d/%d\n", + cmsg->cmsg_level, cmsg->cmsg_type); + memcpy(target_data, data, len); } cmsg = CMSG_NXTHDR(msgh, cmsg); -- 1.7.8.6