From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38605) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHTnn-00087C-Ci for qemu-devel@nongnu.org; Fri, 08 Jan 2016 04:57:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aHTnk-00053x-NI for qemu-devel@nongnu.org; Fri, 08 Jan 2016 04:57:47 -0500 Received: from mout.kundenserver.de ([212.227.17.24]:62380) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aHTnk-00053a-EL for qemu-devel@nongnu.org; Fri, 08 Jan 2016 04:57:44 -0500 References: <1452218586-4009-1-git-send-email-chengang@emindsoft.com.cn> <568F758D.30405@vivier.eu> <568F8557.3000107@emindsoft.com.cn> From: Laurent Vivier Message-ID: <568F8804.8080101@vivier.eu> Date: Fri, 8 Jan 2016 10:57:24 +0100 MIME-Version: 1.0 In-Reply-To: <568F8557.3000107@emindsoft.com.cn> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Subject: Re: [Qemu-devel] [PATCH] linux-user: syscall: Add SO_LINGER for setsockopt List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Chen Gang , riku.voipio@iki.fi Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, rth@twiddle.net Le 08/01/2016 10:45, Chen Gang a écrit : > > On 2016年01月08日 16:38, Laurent Vivier wrote: >> >>> + 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); >>> + unlock_user_struct(tlg, optval_addr, 0); >> >> You can't unlock the structure you're going to use. >> > > OK, thanks. > > >>> + return get_errno(setsockopt(sockfd, SOL_SOCKET, optname, >>> + &lg, sizeof(lg))); >> >> Why do you use "SOL_SOCKET" instead of "level" ? >> > > At present, level is TARGET_SOL_SOCKET, but we need SOL_SOCKET. Yes, you're right... so there is a bug in TARGET_SO_BINDTODEVICE which is using "level" :) > > >>> diff --git a/linux-user/syscall_defs.h b/linux-user/syscall_defs.h >>> index 9d3c537..5a4d565 100644 >>> --- a/linux-user/syscall_defs.h >>> +++ b/linux-user/syscall_defs.h >>> @@ -165,6 +165,11 @@ struct target_ip_mreq_source { >>> uint32_t imr_sourceaddr; >>> }; >>> >>> +struct target_linger { >>> + int l_onoff; /* Linger active */ >>> + int l_linger; /* How long to linger for */ >>> +}; >>> + >> >> Must be "abi_int" to force good alignment for the target. >> > > OK, thanks. > >