diff options
-rw-r--r-- | sys/kern/kern_descrip.c | 9 | ||||
-rw-r--r-- | sys/kern/kern_exec.c | 2 | ||||
-rw-r--r-- | sys/kern/kern_fork.c | 4 | ||||
-rw-r--r-- | sys/sys/filedesc.h | 2 |
4 files changed, 9 insertions, 8 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 94ff960..bc14c61 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1249,17 +1249,18 @@ fdshare(fdp) /* * Copy a filedesc structure. + * A NULL pointer in returns a NULL reference, this is to ease callers, + * not catch errors. */ struct filedesc * -fdcopy(td) - struct thread *td; +fdcopy(fdp) + struct filedesc *fdp; { - struct filedesc *newfdp, *fdp; + struct filedesc *newfdp; struct file **fpp; int i, j; /* Certain daemons might not have file descriptors. */ - fdp = td->td_proc->p_fd; if (fdp == NULL) return (NULL); diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 58c0f82..acb12ee 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -377,7 +377,7 @@ interpret: if (p->p_fd->fd_refcnt > 1) { struct filedesc *tmp; - tmp = fdcopy(td); + tmp = fdcopy(td->td_proc->p_fd); FILEDESC_UNLOCK(p->p_fd); fdfree(td); p->p_fd = tmp; diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 7aa0dc0..7361757 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -271,7 +271,7 @@ fork1(td, flags, pages, procp) if (p1->p_fd->fd_refcnt > 1) { struct filedesc *newfd; - newfd = fdcopy(td); + newfd = fdcopy(td->td_proc->p_fd); FILEDESC_UNLOCK(p1->p_fd); fdfree(td); p1->p_fd = newfd; @@ -448,7 +448,7 @@ again: fd = fdinit(td->td_proc->p_fd); else if (flags & RFFDG) { FILEDESC_LOCK(p1->p_fd); - fd = fdcopy(td); + fd = fdcopy(td->td_proc->p_fd); FILEDESC_UNLOCK(p1->p_fd); } else fd = fdshare(p1->p_fd); diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 47fb043..254540c 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -148,7 +148,7 @@ int fdalloc(struct thread *p, int want, int *result); int fdavail(struct thread *td, int n); void fdcloseexec(struct thread *td); int fdcheckstd(struct thread *td); -struct filedesc *fdcopy(struct thread *td); +struct filedesc *fdcopy(struct filedesc *fdp); void fdfree(struct thread *td); struct filedesc *fdinit(struct filedesc *fdp); struct filedesc *fdshare(struct filedesc *fdp); |