+
+/*
+ * File handle to vnode
+ *
+ * Have to be really careful about stale file handles:
+ * - check that the inode number is valid
+ * - call lfs_vget() to get the locked inode
+ * - check for an unallocated inode (i_mode == 0)
+ * - check that the generation number matches
+ *
+ * XXX
+ * use ifile to see if inode is allocated instead of reading off disk
+ * what is the relationship between my generational number and the NFS
+ * generational number.
+ */
+int
+lfs_fhtovp(mp, fhp, vpp)
+ register struct mount *mp;
+ struct fid *fhp;
+ struct vnode **vpp;
+{
+ register struct inode *ip;
+ register struct ufid *ufhp;
+ struct vnode *nvp;
+ int error;
+
+ ufhp = (struct ufid *)fhp;
+ if (ufhp->ufid_ino < ROOTINO)
+ return (EINVAL);
+ if (error = lfs_vget(mp, ufhp->ufid_ino, &nvp)) {
+ *vpp = NULLVP;
+ return (error);
+ }
+ ip = VTOI(nvp);
+ if (ip->i_mode == 0) {
+ ufs_iput(ip);
+ *vpp = NULLVP;
+ return (EINVAL);
+ }
+ if (ip->i_gen != ufhp->ufid_gen) {
+ ufs_iput(ip);
+ *vpp = NULLVP;
+ return (EINVAL);
+ }
+ *vpp = nvp;
+ return (0);
+}
+
+/*
+ * Vnode pointer to File handle
+ */
+/* ARGSUSED */
+lfs_vptofh(vp, fhp)
+ struct vnode *vp;
+ struct fid *fhp;
+{
+ register struct inode *ip;
+ register struct ufid *ufhp;
+
+ ip = VTOI(vp);
+ ufhp = (struct ufid *)fhp;
+ ufhp->ufid_len = sizeof(struct ufid);
+ ufhp->ufid_ino = ip->i_number;
+ ufhp->ufid_gen = ip->i_gen;
+ return (0);
+}