summaryrefslogtreecommitdiffstats
path: root/sys/kern/kern_exec.c
diff options
context:
space:
mode:
authormpi <mpi@openbsd.org>2018-06-02 10:27:43 +0000
committermpi <mpi@openbsd.org>2018-06-02 10:27:43 +0000
commite19d53e76a47615a43b7017fba112b33916857f5 (patch)
tree7f7b957be7e490a1f8be94c6aed0b47ed5b6794a /sys/kern/kern_exec.c
parentrestore one set of quotes i shouldn;t have removed; (diff)
downloadwireguard-openbsd-e19d53e76a47615a43b7017fba112b33916857f5.tar.xz
wireguard-openbsd-e19d53e76a47615a43b7017fba112b33916857f5.zip
Put file descriptors on shared data structures when they are completely
setup. LARVAL fd still exist, but they are no longer marked with a flag and no longer reachable via `fd_ofiles[]'. This allows us to simplifies a lot code grabbing new references to fds. All of this is now possible because dup2(2) refuses to clone LARVAL fds. Note that the `fdplock' could now be release in all open(2)-like syscalls, just like it is done in accept(2). With inputs from Mathieu -, visa@, guenther@ and art@ ok visa@, bluhm@
Diffstat (limited to 'sys/kern/kern_exec.c')
-rw-r--r--sys/kern/kern_exec.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c
index 10d2eb1bbbc..6a6c40a1167 100644
--- a/sys/kern/kern_exec.c
+++ b/sys/kern/kern_exec.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: kern_exec.c,v 1.195 2018/04/28 03:13:04 visa Exp $ */
+/* $OpenBSD: kern_exec.c,v 1.196 2018/06/02 10:27:43 mpi Exp $ */
/* $NetBSD: kern_exec.c,v 1.75 1996/02/09 18:59:28 christos Exp $ */
/*-
@@ -584,7 +584,7 @@ sys_execve(struct proc *p, void *v, register_t *retval)
struct vnode *vp;
int indx;
- if ((error = falloc(p, 0, &fp, &indx)) != 0)
+ if ((error = falloc(p, &fp, &indx)) != 0)
break;
#ifdef DIAGNOSTIC
if (indx != i)
@@ -607,10 +607,9 @@ sys_execve(struct proc *p, void *v, register_t *retval)
fp->f_type = DTYPE_VNODE;
fp->f_ops = &vnops;
fp->f_data = (caddr_t)vp;
- FILE_SET_MATURE(fp, p);
- } else {
- FRELE(fp, p);
+ fdinsert(p->p_fd, indx, 0, fp);
}
+ FRELE(fp, p);
}
fdpunlock(p->p_fd);
if (error)