-/*
- * 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(mntp, ino, vpp)
- struct mount *mntp;
- ino_t ino;
- struct vnode **vpp;
-{
- 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(mntp);
- dev = ump->um_dev;
- if ((*vpp = ufs_ihashget(dev, ino)) != NULL)
- return (0);
-
- /* Translate the inode number to a disk address. */
- fs = ump->um_lfs;
- if (ino == LFS_IFILE_INUM)
- daddr = fs->lfs_idaddr;
- else {
- LFS_IENTRY(ifp, fs, ino, bp);
- daddr = ifp->if_daddr;
- brelse(bp);
- if (daddr == LFS_UNUSED_DADDR)
- return (ENOENT);
- }
-
- /* Allocate new vnode/inode. */
- if (error = lfs_vcreate(mntp, ino, &vp)) {
- *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);
- *vpp = NULL;
- return (error);
- }
- ip->i_din = *lfs_ifind(fs, 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(mntp, &lfs_specops, LFS_FIFOOPS, &vp)) {
- ufs_iput(ip);
- *vpp = NULL;
- return (error);
- }
- /*
- * Finish inode initialization now that aliasing has been resolved.
- */
- ip->i_devvp = ump->um_devvp;
- VREF(ip->i_devvp);
- *vpp = vp;
- return (0);
-}
-