From b9d32c36faccb227a1f27675dcc25108385dbc57 Mon Sep 17 00:00:00 2001 From: Mateusz Guzik Date: Sat, 28 Jun 2014 05:41:53 +0000 Subject: [PATCH] Make fdunshare accept only td parameter. Proc had to match the thread anyway and 2 parameters were inconsistent with the rest. MFC after: 1 week --- sys/kern/kern_descrip.c | 3 ++- sys/kern/kern_exec.c | 2 +- sys/kern/kern_fork.c | 4 ++-- sys/sys/filedesc.h | 2 +- 4 files changed, 6 insertions(+), 5 deletions(-) diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index f73a4cf874d..0b251c603fe 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1850,9 +1850,10 @@ fdshare(struct filedesc *fdp) * Unshare a filedesc structure, if necessary by making a copy */ void -fdunshare(struct proc *p, struct thread *td) +fdunshare(struct thread *td) { struct filedesc *tmp; + struct proc *p = td->td_proc; if (p->p_fd->fd_refcnt == 1) return; diff --git a/sys/kern/kern_exec.c b/sys/kern/kern_exec.c index 7d3bad9d50c..1d3a46d439a 100644 --- a/sys/kern/kern_exec.c +++ b/sys/kern/kern_exec.c @@ -594,7 +594,7 @@ do_execve(td, args, mac_p) * For security and other reasons, the file descriptor table cannot * be shared after an exec. */ - fdunshare(p, td); + fdunshare(td); /* * Malloc things before we need locks. diff --git a/sys/kern/kern_fork.c b/sys/kern/kern_fork.c index b3d9c243f94..8135afba7e2 100644 --- a/sys/kern/kern_fork.c +++ b/sys/kern/kern_fork.c @@ -341,8 +341,8 @@ fork_norfproc(struct thread *td, int flags) /* * Unshare file descriptors (from parent). */ - if (flags & RFFDG) - fdunshare(p1, td); + if (flags & RFFDG) + fdunshare(td); fail: if (((p1->p_flag & (P_HADTHREADS|P_SYSTEM)) == P_HADTHREADS) && diff --git a/sys/sys/filedesc.h b/sys/sys/filedesc.h index 972cfc92475..d407cd20f44 100644 --- a/sys/sys/filedesc.h +++ b/sys/sys/filedesc.h @@ -152,7 +152,7 @@ int fdcheckstd(struct thread *td); void fdclose(struct filedesc *fdp, struct file *fp, int idx, struct thread *td); void fdcloseexec(struct thread *td); struct filedesc *fdcopy(struct filedesc *fdp); -void fdunshare(struct proc *p, struct thread *td); +void fdunshare(struct thread *td); void fdescfree(struct thread *td); struct filedesc *fdinit(struct filedesc *fdp); struct filedesc *fdshare(struct filedesc *fdp);