From e034bfb7b177b169e8d4f5ab26e75edd97587540 Mon Sep 17 00:00:00 2001 From: Artur Grabowski Date: Fri, 22 Nov 2002 13:40:07 +0000 Subject: Allow fdinit to be called with p == NULL so that we can use it to properly init filedescs for proc0. --- sys/kern/kern_descrip.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) (limited to 'sys/kern') 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. */ -- cgit v1.2.3