Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/kern 1. mask fflags so we don't tack on whateve oflags w...
details: https://anonhg.NetBSD.org/src/rev/e1327dc5ddbe
branches: trunk
changeset: 339681:e1327dc5ddbe
user: christos <christos%NetBSD.org@localhost>
date: Mon Aug 03 04:55:15 2015 +0000
description:
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}
diffstat:
sys/kern/kern_descrip.c | 12 +++++++++---
1 files changed, 9 insertions(+), 3 deletions(-)
diffs (34 lines):
diff -r f8421dbe1d46 -r e1327dc5ddbe sys/kern/kern_descrip.c
--- a/sys/kern/kern_descrip.c Mon Aug 03 04:16:10 2015 +0000
+++ b/sys/kern/kern_descrip.c Mon Aug 03 04:55:15 2015 +0000
@@ -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 @@
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;
Home |
Main Index |
Thread Index |
Old Index