void fg_drop(struct fileproc * fp);
void fg_free(struct fileglob *fg);
void fg_ref(struct fileproc * fp);
-int fp_getfpshm(struct proc *p, int fd, struct fileproc **resultfp, struct pshmnode **resultpshm);
static int closef_finish(struct fileproc *fp, struct fileglob *fg, struct proc *p);
/* allocate file lock group attribute and group */
file_lck_grp_attr= lck_grp_attr_alloc_init();
- lck_grp_attr_setstat(file_lck_grp_attr);
file_lck_grp = lck_grp_alloc_init("file", file_lck_grp_attr);
/* Allocate file lock attribute */
file_lck_attr = lck_attr_alloc_init();
- //lck_attr_setdebug(file_lck_attr);
uipc_lock = lck_mtx_alloc_init(file_lck_grp, file_lck_attr);
file_iterate_lcok = lck_mtx_alloc_init(file_lck_grp, file_lck_attr);
}
+
+int
+fp_getfvpandvid(p, fd, resultfp, resultvp, vidp)
+ struct proc *p;
+ int fd;
+ struct fileproc **resultfp;
+ struct vnode **resultvp;
+ uint32_t * vidp;
+{
+ 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_VNODE) {
+ proc_fdunlock(p);
+ return(ENOTSUP);
+ }
+ fp->f_iocount++;
+
+ if (resultfp)
+ *resultfp = fp;
+ if (resultvp)
+ *resultvp = (struct vnode *)fp->f_data;
+ if (vidp)
+ *vidp = (uint32_t)vnode_vid((struct vnode *)fp->f_data);
+ proc_fdunlock(p);
+
+ return (0);
+}
+
/*
* Returns: EBADF The file descriptor is invalid
* EOPNOTSUPP The file descriptor is not a socket
return (0);
}
+
+
+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);
+}
+
int
fp_lookup(p, fd, resultfp, locked)
struct proc *p;