diff options
author | 2018-06-02 10:27:43 +0000 | |
---|---|---|
committer | 2018-06-02 10:27:43 +0000 | |
commit | e19d53e76a47615a43b7017fba112b33916857f5 (patch) | |
tree | 7f7b957be7e490a1f8be94c6aed0b47ed5b6794a /sys/kern/exec_script.c | |
parent | restore one set of quotes i shouldn;t have removed; (diff) | |
download | wireguard-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/exec_script.c')
-rw-r--r-- | sys/kern/exec_script.c | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/sys/kern/exec_script.c b/sys/kern/exec_script.c index 0bfaea0aee0..619d1e18b4d 100644 --- a/sys/kern/exec_script.c +++ b/sys/kern/exec_script.c @@ -1,4 +1,4 @@ -/* $OpenBSD: exec_script.c,v 1.44 2018/05/02 02:24:56 visa Exp $ */ +/* $OpenBSD: exec_script.c,v 1.45 2018/06/02 10:27:43 mpi Exp $ */ /* $NetBSD: exec_script.c,v 1.13 1996/02/04 02:15:06 christos Exp $ */ /* @@ -170,17 +170,20 @@ check_shell: #endif fdplock(p->p_fd); - error = falloc(p, 0, &fp, &epp->ep_fd); - fdpunlock(p->p_fd); - if (error) + error = falloc(p, &fp, &epp->ep_fd); + if (error) { + fdpunlock(p->p_fd); goto fail; + } epp->ep_flags |= EXEC_HASFD; fp->f_type = DTYPE_VNODE; fp->f_ops = &vnops; fp->f_data = (caddr_t) scriptvp; fp->f_flag = FREAD; - FILE_SET_MATURE(fp, p); + fdinsert(p->p_fd, epp->ep_fd, 0, fp); + fdpunlock(p->p_fd); + FRELE(fp, p); } /* set up the parameters for the recursive check_exec() call */ |