From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50696) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHZke-0007WS-2R for qemu-devel@nongnu.org; Thu, 05 Sep 2013 09:37:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VHZkU-0005fs-EI for qemu-devel@nongnu.org; Thu, 05 Sep 2013 09:37:35 -0400 Received: from cantor2.suse.de ([195.135.220.15]:43437 helo=mx2.suse.de) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VHZkU-0005ff-59 for qemu-devel@nongnu.org; Thu, 05 Sep 2013 09:37:26 -0400 From: Alexander Graf Date: Thu, 5 Sep 2013 15:37:22 +0200 Message-Id: <1378388242-13114-1-git-send-email-agraf@suse.de> Subject: [Qemu-devel] [PATCH] linux-user: Implement sendmmsg syscall List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel Developers Cc: Peter Maydell , Riku Voipio , Arnd Bergmann Glibc when built for newer kernels assumes that the sendmmsg syscall is available. Without it, dns resolution simply fails to work. Wrap the syscall with existing infrastructure so that we don't have a host dependency on sendmmsg. Signed-off-by: Alexander Graf --- linux-user/syscall.c | 29 +++++++++++++++++++++++++++++ linux-user/syscall_defs.h | 4 ++++ 2 files changed, 33 insertions(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 0272990..59cfdf4 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c @@ -1863,6 +1863,30 @@ out2: return ret; } +#ifdef TARGET_NR_sendmmsg +static abi_long do_sendmmsg(int fd, abi_ulong target_msgvec, + unsigned int vlen, unsigned int flags) +{ + struct target_mmsghdr *mmsgp; + abi_ulong arg2 = target_msgvec; + int i; + + if (!(mmsgp = lock_user(VERIFY_WRITE, target_msgvec, + sizeof(*mmsgp) * vlen, 1))) { + return -TARGET_EFAULT; + } + + for (i = 0; i < vlen; i++) { + mmsgp[i].msg_len = tswap32(do_sendrecvmsg(fd, arg2, flags, 1)); + arg2 += sizeof(struct target_mmsghdr); + } + + unlock_user(mmsgp, target_msgvec, 0); + /* XXX need to handle nonblocking case too */ + return vlen; +} +#endif + /* If we don't have a system accept4() then just call accept. * The callsites to do_accept4() will ensure that they don't * pass a non-zero flags argument in this config. @@ -6973,6 +6997,11 @@ abi_long do_syscall(void *cpu_env, int num, abi_ulong arg1, ret = do_sendrecvmsg(arg1, arg2, arg3, 1); break; #endif +#ifdef TARGET_NR_sendmmsg + case TARGET_NR_sendmmsg: + ret = do_sendmmsg(arg1, arg2, arg3, arg4); + break; +#endif #ifdef TARGET_NR_sendto case TARGET_NR_sendto: ret = do_sendto(arg1, arg2, arg3, arg4, arg5, arg6); diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h index e51ef31..37645de 100644 --- a/linux-user/syscall_defs.h +++ b/linux-user/syscall_defs.h @@ -222,6 +222,10 @@ __target_cmsg_nxthdr (struct target_msghdr *__mhdr, struct target_cmsghdr *__cms return __cmsg; } +struct target_mmsghdr { + struct target_msghdr msg_hdr; /* Message header */ + unsigned int msg_len; /* Number of bytes transmitted */ +}; struct target_rusage { struct target_timeval ru_utime; /* user time used */ -- 1.8.1.4