src/sys/fs/ext2fs/ext2_vfsops.c
/*
 * File handle to vnode
 *
 * Have to be really careful about stale file handles:
 * - check that the inode number is valid
 * - call ext2_vget() to get the locked inode
 * - check for an unallocated inode (i_mode == 0)
 * - check that the given client host has export rights and return
 *   those rights via. exflagsp and credanonp
 */
File handle to vnode
Have to be really careful about stale file handles:
- check that the inode number is valid
- call ext2_vget() to get the locked inode
- check for an unallocated inode (i_mode == 0)
- check that the given client host has export rights and return
those rights via. exflagsp and credanonp
File handle to vnode Have to be really careful about stale file handles : - check that the inode number is valid - call ext2_vget () to get the locked inode - check for an unallocated inode ( i_mode == 0 ) - check that the given client host has export rights and return those rights via . exflagsp and credanonp
static int
ext2_fhtovp(struct mount *mp, struct fid *fhp, int flags, struct vnode **vpp)
{
	struct inode *ip;
	struct ufid *ufhp;
	struct vnode *nvp;
	struct m_ext2fs *fs;
	int error;
	ufhp = (struct ufid *)fhp;
	fs = VFSTOEXT2(mp)->um_e2fs;
	if (ufhp->ufid_ino < EXT2_ROOTINO ||
	    ufhp->ufid_ino > fs->e2fs_gcount * fs->e2fs->e2fs_ipg)
		return (ESTALE);
	error = VFS_VGET(mp, ufhp->ufid_ino, LK_EXCLUSIVE, &nvp);
	if (error) {
		*vpp = NULLVP;
		return (error);
	}
	ip = VTOI(nvp);
	if (ip->i_mode == 0 ||
	    ip->i_gen != ufhp->ufid_gen || ip->i_nlink <= 0) {
		vput(nvp);
		*vpp = NULLVP;
		return (ESTALE);
	}
	*vpp = nvp;
	vnode_create_vobject(*vpp, 0, curthread);
	return (0);
}
static int ext2_fhtovp ( struct mount * mp , struct fid * fhp , int flags , struct vnode * * vpp ) { struct inode * ip ; struct ufid * ufhp ; struct vnode * nvp ; struct m_ext2fs * fs ; int error ; ufhp = ( struct ufid * ) fhp ; fs = VFSTOEXT2 ( mp ) -> um_e2fs ; if ( ufhp -> ufid_ino < EXT2_ROOTINO || ufhp -> ufid_ino > fs -> e2fs_gcount * fs -> e2fs -> e2fs_ipg ) return ( ESTALE ) ; error = VFS_VGET ( mp , ufhp -> ufid_ino , LK_EXCLUSIVE , & nvp ) ; if ( error ) { * vpp = NULLVP ; return ( error ) ; } ip = VTOI ( nvp ) ; if ( ip -> i_mode == 0 || ip -> i_gen != ufhp -> ufid_gen || ip -> i_nlink <= 0 ) { vput ( nvp ) ; * vpp = NULLVP ; return ( ESTALE ) ; } * vpp = nvp ; vnode_create_vobject ( * vpp , 0 , curthread ) ; return ( 0 ) ; }
File handle to vnode
 Have to be really careful about stale file handles:
 - check that the inode number is valid
 - call ext2_vget() to get the locked inode
 - check for an unallocated inode (i_mode == 0)
 - check that the given client host has export rights and return
   those rights via.
File handle to vnode Have to be really careful about stale file handles : - check that the inode number is valid - call ext2_vget () to get the locked inode - check for an unallocated inode ( i_mode == 0 ) - check that the given client host has export rights and return those rights via .