- vp = ITOV(ip);
- vinit(vp, mntp, IFTOVT(ip->i_mode), &ufs_vnodeops);
- if (vp->v_type == VCHR || vp->v_type == VBLK) {
- vp->v_rdev = ip->i_rdev;
- vp->v_op = &blk_vnodeops;
- }
- if (ino == ROOTINO)
- vp->v_flag |= VROOT;
-#ifdef QUOTA
- if (ip->i_mode != 0)
- ip->i_dquot = inoquota(ip);
-#endif
- *ipp = ip;
- return (0);
-}
-
-/*
- * Allocate a new inode.
- *
- * 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.
- */
-getnewino(dev, ino, ipp)
- dev_t dev;
- ino_t ino;
- struct inode **ipp;
-{
- union ihead *ih;
- register struct inode *ip, *iq;
- register struct vnode *vp;
-
- /*
- * Remove the next inode from the free list.
- */
- if ((ip = ifreeh) == NULL) {
- tablefull("inode");
- *ipp = 0;
- return(ENFILE);
- }
- vp = ITOV(ip);
- if (vp->v_count)
- panic("free inode isn't");
- if (iq = ip->i_freef)
- iq->i_freeb = &ifreeh;
- ifreeh = iq;
- ip->i_freef = NULL;
- ip->i_freeb = NULL;
- /*
- * Now to take inode off the hash chain it was on
- * (initially, or after an iflush, it is on a "hash chain"
- * consisting entirely of itself, and pointed to by no-one)
- * and put it on the chain for its new (ino, dev) pair.
- */
- remque(ip);
- ip->i_dev = dev;
- ip->i_number = ino;
- if (dev != NODEV) {
- ih = &ihead[INOHASH(dev, ino)];
- insque(ip, ih);
- }
- ip->i_flag = ILOCKED;
- ip->i_lastr = 0;
-#endif SECSIZE
- /*
- * Purge old data structures associated with the inode.
- */
- cache_purge(vp);
- if (ip->i_devvp) {
- vrele(ip->i_devvp);
- ip->i_devvp = 0;
- }
-#ifdef QUOTA
- dqrele(ip->i_dquot);
- ip->i_dquot = NODQUOT;
-#endif
- if (vp->v_type == VBLK) {
- if (bdevlisth == ip) {
- bdevlisth = ip->i_devlst;
- } else {
- for (iq = bdevlisth; iq; iq = iq->i_devlst) {
- if (iq->i_devlst != ip)
- continue;
- iq->i_devlst = ip->i_devlst;
- break;
- }
- if (iq == NULL)
- panic("missing bdev");
- }