X-Git-Url: https://git.saurik.com/apple/xnu.git/blobdiff_plain/13fec9890cf095cc781fdf7b8917cb03bf32dd4c..c0fea4742e91338fffdcf79f86a7c1d5e2b97eb1:/bsd/kern/kern_descrip.c diff --git a/bsd/kern/kern_descrip.c b/bsd/kern/kern_descrip.c index 1ec789877..7cff95e66 100644 --- a/bsd/kern/kern_descrip.c +++ b/bsd/kern/kern_descrip.c @@ -106,7 +106,6 @@ int fdgetf_noref(struct proc *p, int fd, struct fileproc **resultfp); 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); @@ -149,13 +148,11 @@ file_lock_init(void) /* 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); @@ -1502,6 +1499,42 @@ fp_getfvp(p, fd, resultfp, resultvp) } + +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 @@ -1640,6 +1673,74 @@ fp_getfpsem(p, fd, resultfp, resultpsem) 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;