diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index dba34c50735c..fbc12e433ffd 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1202,14 +1202,14 @@ ffree(fp) } /* - * Build a new filedesc structure. + * Build a new filedesc structure from another. + * Copy the current, root, and jail root vnode references. */ struct filedesc * -fdinit(td) - struct thread *td; +fdinit(fdp) + struct filedesc *fdp; { register struct filedesc0 *newfdp; - register struct filedesc *fdp = td->td_proc->p_fd; MALLOC(newfdp, struct filedesc0 *, sizeof(struct filedesc0), M_FILEDESC, M_WAITOK | M_ZERO); @@ -1238,13 +1238,13 @@ fdinit(td) * Share a filedesc structure. */ struct filedesc * -fdshare(p) - struct proc *p; +fdshare(fdp) + struct filedesc *fdp; { - FILEDESC_LOCK(p->p_fd); - p->p_fd->fd_refcnt++; - FILEDESC_UNLOCK(p->p_fd); - return (p->p_fd); + FILEDESC_LOCK(fdp); + fdp->fd_refcnt++; + FILEDESC_UNLOCK(fdp); + return (fdp); } /* diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index 1a8e4d25904c..7aa0dc0d935a 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -258,8 +258,8 @@ fork1(td, flags, pages, procp) */ if (flags & RFCFDG) { struct filedesc *fdtmp; - fdtmp = fdinit(td); /* XXXKSE */ - fdfree(td); /* XXXKSE */ + fdtmp = fdinit(td->td_proc->p_fd); + fdfree(td); p1->p_fd = fdtmp; } @@ -445,13 +445,13 @@ again: * arguments or something. */ if (flags & RFCFDG) - fd = fdinit(td); + fd = fdinit(td->td_proc->p_fd); else if (flags & RFFDG) { FILEDESC_LOCK(p1->p_fd); fd = fdcopy(td); FILEDESC_UNLOCK(p1->p_fd); } else - fd = fdshare(p1); + fd = fdshare(p1->p_fd); /* * Make a proc table entry for the new process. diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 7fc5182c8ee3..47fb0435da94 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -150,8 +150,8 @@ void fdcloseexec(struct thread *td); int fdcheckstd(struct thread *td); struct filedesc *fdcopy(struct thread *td); void fdfree(struct thread *td); -struct filedesc *fdinit(struct thread *td); -struct filedesc *fdshare(struct proc *p); +struct filedesc *fdinit(struct filedesc *fdp); +struct filedesc *fdshare(struct filedesc *fdp); void ffree(struct file *fp); static __inline struct file * fget_locked(struct filedesc *fdp, int fd); pid_t fgetown(struct sigio **sigiop);