-/*
- * Look up an LFS dinode number to find its incore vnode. If not already
- * in core, read it in from the specified device. Return the inode locked.
- * Detection and handling of mount points must be done by the calling routine.
- */
-int
-lfs_vget (ap)
- struct vop_vget_args *ap;
-{
- register struct lfs *fs;
- register struct inode *ip;
- struct buf *bp;
- struct ifile *ifp;
- struct vnode *vp;
- struct ufsmount *ump;
- daddr_t daddr;
- dev_t dev;
- int error;
-
-#ifdef VERBOSE
- printf("lfs_vget\n");
-#endif
- ump = VFSTOUFS(ap->a_mp);
- dev = ump->um_dev;
- if ((*ap->a_vpp = ufs_ihashget(dev, ap->a_ino)) != NULL)
- return (0);
-
- /* Translate the inode number to a disk address. */
- fs = ump->um_lfs;
- if (ap->a_ino == LFS_IFILE_INUM)
- daddr = fs->lfs_idaddr;
- else {
- LFS_IENTRY(ifp, fs, ap->a_ino, bp);
- daddr = ifp->if_daddr;
- brelse(bp);
- if (daddr == LFS_UNUSED_DADDR)
- return (ENOENT);
- }
-
- /* Allocate new vnode/inode. */
- if (error = lfs_vcreate(ap->a_mp, ap->a_ino, &vp)) {
- *ap->a_vpp = NULL;
- return (error);
- }
-
- /*
- * Put it onto its hash chain and lock it so that other requests for
- * this inode will block if they arrive while we are sleeping waiting
- * for old data structures to be purged or for the contents of the
- * disk portion of this inode to be read.
- */
- ip = VTOI(vp);
- ufs_ihashins(ip);
-
- /*
- * XXX
- * This may not need to be here, logically it should go down with
- * the i_devvp initialization.
- * Ask Kirk.
- */
- ip->i_lfs = ump->um_lfs;
-
- /* Read in the disk contents for the inode, copy into the inode. */
- if (error =
- bread(ump->um_devvp, daddr, (int)fs->lfs_bsize, NOCRED, &bp)) {
- /*
- * The inode does not contain anything useful, so it
- * would be misleading to leave it on its hash chain.
- * Iput() will return it to the free list.
- */
- remque(ip);
- ip->i_forw = ip;
- ip->i_back = ip;
-
- /* Unlock and discard unneeded inode. */
- ufs_iput(ip);
- brelse(bp);
- *ap->a_vpp = NULL;
- return (error);
- }
- ip->i_din = *lfs_ifind(fs, ap->a_ino, bp->b_un.b_dino);
- brelse(bp);
-
- /*
- * Initialize the vnode from the inode, check for aliases. In all
- * cases re-init ip, the underlying vnode/inode may have changed.
- */
- if (error = ufs_vinit(ap->a_mp, lfs_specop_p, LFS_FIFOOPS, &vp)) {
- ufs_iput(ip);
- *ap->a_vpp = NULL;
- return (error);
- }
- /*
- * Finish inode initialization now that aliasing has been resolved.
- */
- ip->i_devvp = ump->um_devvp;
- VREF(ip->i_devvp);
- *ap->a_vpp = vp;
- return (0);
-}
-