Module Name: src
Committed By: christos
Date: Mon Aug 3 04:55:15 UTC 2015
Modified Files:
src/sys/kern: kern_descrip.c
Log Message:
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.
XXX: pullup-{6,7}
To generate a diff of this commit:
cvs rdiff -u -r1.228 -r1.229 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.228 src/sys/kern/kern_descrip.c:1.229
--- src/sys/kern/kern_descrip.c:1.228 Sun Sep 21 13:17:15 2014
+++ src/sys/kern/kern_descrip.c Mon Aug 3 00:55:15 2015
@@ -1,4 +1,4 @@
-/* $NetBSD: kern_descrip.c,v 1.228 2014/09/21 17:17:15 christos Exp $ */
+/* $NetBSD: kern_descrip.c,v 1.229 2015/08/03 04:55:15 christos 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.228 2014/09/21 17:17:15 christos Exp $");
+__KERNEL_RCSID(0, "$NetBSD: kern_descrip.c,v 1.229 2015/08/03 04:55:15 christos 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;