diff options
Diffstat (limited to 'sys/kern/kern_descrip.c')
-rw-r--r-- | sys/kern/kern_descrip.c | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/sys/kern/kern_descrip.c b/sys/kern/kern_descrip.c index 21d403e08a1..4638e6c216c 100644 --- a/sys/kern/kern_descrip.c +++ b/sys/kern/kern_descrip.c @@ -1,4 +1,4 @@ -/* $OpenBSD: kern_descrip.c,v 1.61 2002/11/08 18:38:00 art Exp $ */ +/* $OpenBSD: kern_descrip.c,v 1.62 2002/11/22 13:40:06 art Exp $ */ /* $NetBSD: kern_descrip.c,v 1.42 1996/03/30 22:24:38 christos Exp $ */ /* @@ -855,20 +855,22 @@ restart: * Build a new filedesc structure. */ struct filedesc * -fdinit(p) - struct proc *p; +fdinit(struct proc *p) { - register struct filedesc0 *newfdp; - register struct filedesc *fdp = p->p_fd; + struct filedesc0 *newfdp; extern int cmask; newfdp = pool_get(&fdesc_pool, PR_WAITOK); bzero(newfdp, sizeof(struct filedesc0)); - newfdp->fd_fd.fd_cdir = fdp->fd_cdir; - VREF(newfdp->fd_fd.fd_cdir); - newfdp->fd_fd.fd_rdir = fdp->fd_rdir; - if (newfdp->fd_fd.fd_rdir) - VREF(newfdp->fd_fd.fd_rdir); + if (p != NULL) { + struct filedesc *fdp = p->p_fd; + + newfdp->fd_fd.fd_cdir = fdp->fd_cdir; + VREF(newfdp->fd_fd.fd_cdir); + newfdp->fd_fd.fd_rdir = fdp->fd_rdir; + if (newfdp->fd_fd.fd_rdir) + VREF(newfdp->fd_fd.fd_rdir); + } lockinit(&newfdp->fd_fd.fd_lock, PLOCK, "fdexpand", 0, 0); /* Create the file descriptor table. */ |