From owner-svn-src-head@FreeBSD.ORG Mon May 18 04:07:46 2009 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id F08F4106566B; Mon, 18 May 2009 04:07:46 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id C4D718FC08; Mon, 18 May 2009 04:07:46 +0000 (UTC) (envelope-from dchagin@FreeBSD.org) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id n4I47k6c048821; Mon, 18 May 2009 04:07:46 GMT (envelope-from dchagin@svn.freebsd.org) Received: (from dchagin@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id n4I47kIf048819; Mon, 18 May 2009 04:07:46 GMT (envelope-from dchagin@svn.freebsd.org) Message-Id: <200905180407.n4I47kIf048819@svn.freebsd.org> From: Dmitry Chagin Date: Mon, 18 May 2009 04:07:46 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r192284 - head/sys/compat/linux X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 18 May 2009 04:07:47 -0000 Author: dchagin Date: Mon May 18 04:07:46 2009 New Revision: 192284 URL: http://svn.freebsd.org/changeset/base/192284 Log: Implement MSG_CMSG_CLOEXEC flag for linux_recvmsg(). Approved by: kib (mentor) MFC after: 1 month Modified: head/sys/compat/linux/linux_socket.c head/sys/compat/linux/linux_socket.h Modified: head/sys/compat/linux/linux_socket.c ============================================================================== --- head/sys/compat/linux/linux_socket.c Mon May 18 02:40:11 2009 (r192283) +++ head/sys/compat/linux/linux_socket.c Mon May 18 04:07:46 2009 (r192284) @@ -1148,7 +1148,7 @@ linux_recvmsg(struct thread *td, struct struct mbuf **controlp; caddr_t outbuf; void *data; - int error; + int error, i, fd, fds, *fdp; error = copyin(PTRIN(args->msg), &linux_msg, sizeof(linux_msg)); if (error) @@ -1217,15 +1217,30 @@ linux_recvmsg(struct thread *td, struct data = CMSG_DATA(cm); datalen = (caddr_t)cm + cm->cmsg_len - (caddr_t)data; - if (outlen + LINUX_CMSG_LEN(datalen) > - linux_msg.msg_controllen) { - if (outlen == 0) { - error = EMSGSIZE; - goto bad; - } else { - linux_msg.msg_flags |= LINUX_MSG_CTRUNC; - goto out; + switch (linux_cmsg->cmsg_type) + { + case LINUX_SCM_RIGHTS: + if (outlen + LINUX_CMSG_LEN(datalen) > + linux_msg.msg_controllen) { + if (outlen == 0) { + error = EMSGSIZE; + goto bad; + } else { + linux_msg.msg_flags |= + LINUX_MSG_CTRUNC; + goto out; + } + } + if (args->flags & LINUX_MSG_CMSG_CLOEXEC) { + fds = datalen / sizeof(int); + fdp = data; + for (i = 0; i < fds; i++) { + fd = *fdp++; + (void)kern_fcntl(td, fd, + F_SETFD, FD_CLOEXEC); + } } + break; } linux_cmsg->cmsg_len = LINUX_CMSG_LEN(datalen); Modified: head/sys/compat/linux/linux_socket.h ============================================================================== --- head/sys/compat/linux/linux_socket.h Mon May 18 02:40:11 2009 (r192283) +++ head/sys/compat/linux/linux_socket.h Mon May 18 04:07:46 2009 (r192284) @@ -48,6 +48,7 @@ #define LINUX_MSG_RST 0x1000 #define LINUX_MSG_ERRQUEUE 0x2000 #define LINUX_MSG_NOSIGNAL 0x4000 +#define LINUX_MSG_CMSG_CLOEXEC 0x40000000 /* Socket-level control message types */