summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorArtur Grabowski <art@cvs.openbsd.org>2002-11-22 13:40:07 +0000
committerArtur Grabowski <art@cvs.openbsd.org>2002-11-22 13:40:07 +0000
commite034bfb7b177b169e8d4f5ab26e75edd97587540 (patch)
tree4d4ecc1a42edfb522ad906a6cc783e0b7b65eb41 /sys
parent98e23b0a8580dc062de85b996aa4b8e0803590f5 (diff)
Allow fdinit to be called with p == NULL so that we can use
it to properly init filedescs for proc0.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/kern_descrip.c22
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. */