FREE(fp, M_FILE);
}
+/*
+ * Build a new filedesc structure.
+ */
+struct filedesc *
+fdinit(p)
+ struct proc *p;
+{
+ register struct filedesc0 *newfdp;
+ register struct filedesc *fdp = p->p_fd;
+ extern int cmask;
+
+ MALLOC(newfdp, struct filedesc0 *, sizeof(struct filedesc0),
+ M_FILEDESC, M_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);
+
+ /* Create the file descriptor table. */
+ newfdp->fd_fd.fd_refcnt = 1;
+ newfdp->fd_fd.fd_cmask = cmask;
+ newfdp->fd_fd.fd_ofiles = newfdp->fd_dfiles;
+ newfdp->fd_fd.fd_ofileflags = newfdp->fd_dfileflags;
+ newfdp->fd_fd.fd_nfiles = NDFILE;
+
+ newfdp->fd_fd.fd_freefile = 0;
+ newfdp->fd_fd.fd_lastfile = 0;
+
+ return (&newfdp->fd_fd);
+}
+
+/*
+ * Share a filedesc structure.
+ */
+struct filedesc *
+fdshare(p)
+ struct proc *p;
+{
+ p->p_fd->fd_refcnt++;
+ return (p->p_fd);
+}
+
/*
* Copy a filedesc structure.
*/
int fdalloc __P((struct proc *p, int want, int *result));
int fdavail __P((struct proc *p, int n));
int falloc __P((struct proc *p, struct file **resultfp, int *resultfd));
+struct filedesc *fdinit __P((struct proc *p));
+struct filedesc *fdshare __P((struct proc *p));
struct filedesc *fdcopy __P((struct proc *p));
void fdfree __P((struct proc *p));
#endif