+
+
+int
+fp_getfpipe(p, fd, resultfp, resultpipe)
+ struct proc *p;
+ int fd;
+ struct fileproc **resultfp;
+ struct pipe **resultpipe;
+{
+ struct filedesc *fdp = p->p_fd;
+ struct fileproc *fp;
+
+ proc_fdlock(p);
+ if (fd < 0 || fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL ||
+ (fdp->fd_ofileflags[fd] & UF_RESERVED)) {
+ proc_fdunlock(p);
+ return (EBADF);
+ }
+ if (fp->f_type != DTYPE_PIPE) {
+ proc_fdunlock(p);
+ return(EBADF);
+ }
+ fp->f_iocount++;
+
+ if (resultfp)
+ *resultfp = fp;
+ if (resultpipe)
+ *resultpipe = (struct pipe *)fp->f_data;
+ proc_fdunlock(p);
+
+ return (0);
+}
+
+
+#define DTYPE_ATALK -1
+int
+fp_getfatalk(p, fd, resultfp, resultatalk)
+ struct proc *p;
+ int fd;
+ struct fileproc **resultfp;
+ struct atalk **resultatalk;
+{
+ struct filedesc *fdp = p->p_fd;
+ struct fileproc *fp;
+
+ proc_fdlock(p);
+ if (fd < 0 || fd >= fdp->fd_nfiles ||
+ (fp = fdp->fd_ofiles[fd]) == NULL ||
+ (fdp->fd_ofileflags[fd] & UF_RESERVED)) {
+ proc_fdunlock(p);
+ return (EBADF);
+ }
+ if (fp->f_type != (DTYPE_ATALK+1)) {
+ proc_fdunlock(p);
+ return(EBADF);
+ }
+ fp->f_iocount++;
+
+ if (resultfp)
+ *resultfp = fp;
+ if (resultatalk)
+ *resultatalk = (struct atalk *)fp->f_data;
+ proc_fdunlock(p);
+
+ return (0);
+}
+