From owner-svn-src-stable-8@FreeBSD.ORG Fri Apr 1 12:50:30 2011 Return-Path: Delivered-To: svn-src-stable-8@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 434C51065670; Fri, 1 Apr 2011 12:50:30 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 3265C8FC12; Fri, 1 Apr 2011 12:50:30 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id p31CoUkx045358; Fri, 1 Apr 2011 12:50:30 GMT (envelope-from kib@svn.freebsd.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id p31CoULd045353; Fri, 1 Apr 2011 12:50:30 GMT (envelope-from kib@svn.freebsd.org) Message-Id: <201104011250.p31CoULd045353@svn.freebsd.org> From: Konstantin Belousov Date: Fri, 1 Apr 2011 12:50:30 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-8@freebsd.org X-SVN-Group: stable-8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r220241 - in stable/8/sys: kern sys X-BeenThere: svn-src-stable-8@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: SVN commit messages for only the 8-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 01 Apr 2011 12:50:30 -0000 Author: kib Date: Fri Apr 1 12:50:29 2011 New Revision: 220241 URL: http://svn.freebsd.org/changeset/base/220241 Log: MFC r219999: Add O_CLOEXEC flag to open(2) and fhopen(2). Modified: stable/8/sys/kern/kern_descrip.c stable/8/sys/kern/vfs_syscalls.c stable/8/sys/sys/fcntl.h stable/8/sys/sys/filedesc.h Directory Properties: stable/8/sys/ (props changed) stable/8/sys/amd64/include/xen/ (props changed) stable/8/sys/cddl/contrib/opensolaris/ (props changed) stable/8/sys/contrib/dev/acpica/ (props changed) stable/8/sys/contrib/pf/ (props changed) Modified: stable/8/sys/kern/kern_descrip.c ============================================================================== --- stable/8/sys/kern/kern_descrip.c Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/kern/kern_descrip.c Fri Apr 1 12:50:29 2011 (r220241) @@ -1514,7 +1514,7 @@ fdavail(struct thread *td, int n) * release the FILEDESC lock. */ int -falloc(struct thread *td, struct file **resultfp, int *resultfd) +fallocf(struct thread *td, struct file **resultfp, int *resultfd, int flags) { struct proc *p = td->td_proc; struct file *fp; @@ -1557,6 +1557,8 @@ falloc(struct thread *td, struct file ** return (error); } p->p_fd->fd_ofiles[i] = fp; + if ((flags & O_CLOEXEC) != 0) + p->p_fd->fd_ofileflags[i] |= UF_EXCLOSE; FILEDESC_XUNLOCK(p->p_fd); if (resultfp) *resultfp = fp; @@ -1565,6 +1567,13 @@ falloc(struct thread *td, struct file ** return (0); } +int +falloc(struct thread *td, struct file **resultfp, int *resultfd) +{ + + return (fallocf(td, resultfp, resultfd, 0)); +} + /* * Build a new filedesc structure from another. * Copy the current, root, and jail root vnode references. Modified: stable/8/sys/kern/vfs_syscalls.c ============================================================================== --- stable/8/sys/kern/vfs_syscalls.c Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/kern/vfs_syscalls.c Fri Apr 1 12:50:29 2011 (r220241) @@ -1069,7 +1069,7 @@ kern_openat(struct thread *td, int fd, c else flags = FFLAGS(flags); - error = falloc(td, &nfp, &indx); + error = fallocf(td, &nfp, &indx, flags); if (error) return (error); /* An extra reference on `nfp' has been held for us by falloc(). */ @@ -4478,7 +4478,7 @@ fhopen(td, uap) * end of vn_open code */ - if ((error = falloc(td, &nfp, &indx)) != 0) { + if ((error = fallocf(td, &nfp, &indx, fmode)) != 0) { if (fmode & FWRITE) vp->v_writecount--; goto bad; Modified: stable/8/sys/sys/fcntl.h ============================================================================== --- stable/8/sys/sys/fcntl.h Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/sys/fcntl.h Fri Apr 1 12:50:29 2011 (r220241) @@ -123,9 +123,11 @@ typedef __pid_t pid_t; #define FEXEC O_EXEC #endif -/* Defined by POSIX 1003.1-2008; BSD default, but reserve for future use. */ #if __POSIX_VISIBLE >= 200809 +/* Defined by POSIX 1003.1-2008; BSD default, but reserve for future use. */ #define O_TTY_INIT 0x00080000 /* Restore default termios attributes */ + +#define O_CLOEXEC 0x00100000 #endif /* Modified: stable/8/sys/sys/filedesc.h ============================================================================== --- stable/8/sys/sys/filedesc.h Fri Apr 1 11:39:13 2011 (r220240) +++ stable/8/sys/sys/filedesc.h Fri Apr 1 12:50:29 2011 (r220241) @@ -112,6 +112,8 @@ int closef(struct file *fp, struct threa int dupfdopen(struct thread *td, struct filedesc *fdp, int indx, int dfd, int mode, int error); int falloc(struct thread *td, struct file **resultfp, int *resultfd); +int fallocf(struct thread *td, struct file **resultfp, int *resultfd, + int flags); int fdalloc(struct thread *td, int minfd, int *result); int fdavail(struct thread *td, int n); int fdcheckstd(struct thread *td);