Module Name:    src
Committed By:   snj
Date:           Tue Aug  4 17:24:59 UTC 2015

Modified Files:
        src/sys/kern [netbsd-7]: kern_descrip.c

Log Message:
Pull up following revision(s) (requested by christos in ticket #933):
        sys/kern/kern_descrip.c: revision 1.229
1. mask fflags so we don't tack on whateve oflags were passed from userland
2. honor O_CLOEXEC, so the children of daemons that use cloning devices, don't
   end up with the parents descriptors
fd_clone and in general the fd approach of 'allocate' > 'play with guts' >
'attach' should be converted to be more constructor like.


To generate a diff of this commit:
cvs rdiff -u -r1.225 -r1.225.2.1 src/sys/kern/kern_descrip.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/sys/kern/kern_descrip.c
diff -u src/sys/kern/kern_descrip.c:1.225 src/sys/kern/kern_descrip.c:1.225.2.1
--- src/sys/kern/kern_descrip.c:1.225	Fri Jul 25 08:10:40 2014
+++ src/sys/kern/kern_descrip.c	Tue Aug  4 17:24:59 2015
@@ -1,4 +1,4 @@
-/*	$NetBSD: kern_descrip.c,v 1.225 2014/07/25 08:10:40 dholland Exp $	*/
+/*	$NetBSD: kern_descrip.c,v 1.225.2.1 2015/08/04 17:24:59 snj Exp $	*/
 
 /*-
  * Copyright (c) 2008, 2009 The NetBSD Foundation, Inc.
@@ -70,7 +70,7 @@
  */
 
 #include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.225 2014/07/25 08:10:40 dholland Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.225.2.1 2015/08/04 17:24:59 snj Exp $");
 
 #include <sys/param.h>
 #include <sys/systm.h>
@@ -1861,8 +1861,14 @@ int
 fd_clone(file_t *fp, unsigned fd, int flag, const struct fileops *fops,
 	 void *data)
 {
+	fdfile_t *ff;
+	filedesc_t *fdp;
 
-	fp->f_flag = flag;
+	fp->f_flag |= flag & FMASK;
+	fdp = curproc->p_fd;
+	ff = fdp->fd_dt->dt_ff[fd];
+	KASSERT(ff != NULL);
+	ff->ff_exclose = (flag & O_CLOEXEC) != 0;
 	fp->f_type = DTYPE_MISC;
 	fp->f_ops = fops;
 	fp->f_data = data;

Reply via email to