int layerfs_fhtovp(struct mount *mp, struct fid *fidp, struct vnode **vpp) { struct vnode *vp; int error; error = VFS_FHTOVP(MOUNTTOLAYERMOUNT(mp)->layerm_vfs, fidp, &vp); if (error) { *vpp = NULL; return error; } VOP_UNLOCK(vp); error = layer_node_create(mp, vp, vpp); if (error) { vput(vp); *vpp = NULL; return (error); } error = vn_lock(*vpp, LK_EXCLUSIVE); if (error) { vrele(*vpp); *vpp = NULL; return error; } return 0; }
/* * fhstat_args(struct fhandle *u_fhp, struct dfbsd12_stat *sb) * * MPALMOSTSAFE */ int sys_dfbsd12_fhstat(struct dfbsd12_fhstat_args *uap) { struct thread *td = curthread; struct dfbsd12_stat osb; struct stat sb; fhandle_t fh; struct mount *mp; struct vnode *vp; int error; /* * Must be super user */ error = priv_check(td, PRIV_ROOT); if (error) return (error); error = copyin(uap->u_fhp, &fh, sizeof(fhandle_t)); if (error) return (error); get_mplock(); if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL) { error = ESTALE; goto done; } if ((error = VFS_FHTOVP(mp, NULL, &fh.fh_fid, &vp))) goto done; error = vn_stat(vp, &sb, td->td_ucred); vput(vp); if (error) goto done; cvtstat(&osb, &sb); error = copyout(&osb, uap->sb, sizeof(osb)); done: rel_mplock(); return (error); }
int compat_30_netbsd32_fhstat(struct lwp *l, const struct compat_30_netbsd32_fhstat_args *uap, register_t *retval) { /* { syscallarg(const netbsd32_fhandlep_t) fhp; syscallarg(netbsd32_stat13p_t) sb; } */ struct stat sb; struct netbsd32_stat13 sb32; int error; struct compat_30_fhandle fh; struct mount *mp; struct vnode *vp; /* * Must be super user */ if ((error = kauth_authorize_system(l->l_cred, KAUTH_SYSTEM_FILEHANDLE, 0, NULL, NULL, NULL))) return (error); if ((error = copyin(SCARG_P32(uap, fhp), &fh, sizeof(fh))) != 0) return (error); if ((mp = vfs_getvfs(&fh.fh_fsid)) == NULL) return (ESTALE); if (mp->mnt_op->vfs_fhtovp == NULL) return EOPNOTSUPP; if ((error = VFS_FHTOVP(mp, (struct fid*)&fh.fh_fid, &vp))) return (error); error = vn_stat(vp, &sb); vput(vp); if (error) return (error); netbsd32_from___stat13(&sb, &sb32); error = copyout(&sb32, SCARG_P32(uap, sb), sizeof(sb)); return (error); }
int xfs_fhlookup (d_thread_t *proc, struct xfs_fhandle_t *fhp, struct vnode **vpp) { int error; struct mount *mp; #if !(defined(HAVE_GETFH) && defined(HAVE_FHOPEN)) struct ucred *cred = proc->p_ucred; struct vattr vattr; fsid_t fsid; struct xfs_fh_args *fh_args = (struct xfs_fh_args *)fhp->fhdata; NNPFSDEB(XDEBVFOPS, ("xfs_fhlookup (xfs)\n")); error = xfs_suser (proc); if (error) return EPERM; if (fhp->len < sizeof(struct xfs_fh_args)) return EINVAL; fsid = SCARG(fh_args, fsid); mp = xfs_vfs_getvfs (&fsid); if (mp == NULL) return ENXIO; #ifdef __APPLE__ { uint32_t ino = SCARG(fh_args, fileid); error = VFS_VGET(mp, &ino, vpp); } #else error = VFS_VGET(mp, SCARG(fh_args, fileid), vpp); #endif if (error) return error; if (*vpp == NULL) return ENOENT; error = VOP_GETATTR(*vpp, &vattr, cred, proc); if (error) { vput(*vpp); return error; } if (vattr.va_gen != SCARG(fh_args, gen)) { vput(*vpp); return ENOENT; } #else /* HAVE_GETFH && HAVE_FHOPEN */ { fhandle_t *fh = (fhandle_t *) fhp; NNPFSDEB(XDEBVFOPS, ("xfs_fhlookup (native)\n")); mp = xfs_vfs_getvfs (&fh->fh_fsid); if (mp == NULL) return ESTALE; if ((error = VFS_FHTOVP(mp, &fh->fh_fid, vpp)) != 0) { *vpp = NULL; return error; } } #endif /* HAVE_GETFH && HAVE_FHOPEN */ #ifdef HAVE_KERNEL_VFS_OBJECT_CREATE if ((*vpp)->v_type == VREG && (*vpp)->v_object == NULL) #ifdef HAVE_FREEBSD_THREAD xfs_vfs_object_create (*vpp, proc, proc->td_proc->p_ucred); #else xfs_vfs_object_create (*vpp, proc, proc->p_ucred); #endif #elif __APPLE__ if ((*vpp)->v_type == VREG && (!UBCINFOEXISTS(*vpp))) { ubc_info_init(*vpp); } ubc_hold(*vpp); #endif return 0; }