- /*
- * finally release direct blocks
- */
- for (i = NDADDR - 1; i>=0; i--) {
- register size;
-
- bn = ip->i_db[i];
- if (bn == (daddr_t)0)
- continue;
- ip->i_db[i] = (daddr_t)0;
- fre(ip, bn, size = (off_t)blksize(fs, ip, i));
-#ifdef QUOTA
- cnt += size / DEV_BSIZE;
-#endif
- }
- ip->i_size = 0;
- /*
- * Inode was written and flags updated above.
- * No need to modify flags here.
- */
-#ifdef QUOTA
- (void) chkdq(ip, -cnt, 0);
-#endif
-}
-
-#ifdef QUOTA
-long
-#endif
-tloop(ip, bn, indflg)
- register struct inode *ip;
- daddr_t bn;
- int indflg;
-{
- register i;
- register struct buf *bp;
- register daddr_t *bap;
- register struct fs *fs;
- daddr_t nb;
-#ifdef QUOTA
- register long cnt = 0;
-#endif
-
- bp = NULL;
- fs = ip->i_fs;
- for (i = NINDIR(fs) - 1; i >= 0; i--) {
- if (bp == NULL) {
- bp = bread(ip->i_dev, fsbtodb(fs, bn), fs->fs_bsize);
- if (bp->b_flags & B_ERROR) {
- brelse(bp);
- return;
- }
- bap = bp->b_un.b_daddr;
- }
- nb = bap[i];
- if (nb == (daddr_t)0)
- continue;
- if (indflg) {
-#ifdef QUOTA
- cnt +=
-#endif
- tloop(ip, nb, 0);
- } else {
- fre(ip, nb, fs->fs_bsize);
-#ifdef QUOTA
- cnt += fs->fs_bsize / DEV_BSIZE;
-#endif
- }
- }
- if (bp != NULL)
- brelse(bp);
- fre(ip, bn, fs->fs_bsize);
-#ifdef QUOTA
- cnt += fs->fs_bsize / DEV_BSIZE;
- return(cnt);
-#endif
-}
-
-/*
- * remove any inodes in the inode cache belonging to dev
- *
- * There should not be any active ones, return error if any are found
- * (nb: this is a user error, not a system err)
- *
- * Also, count the references to dev by block devices - this really
- * has nothing to do with the object of the procedure, but as we have
- * to scan the inode table here anyway, we might as well get the
- * extra benefit.
- *
- * this is called from sumount()/sys3.c when dev is being unmounted
- */
-#ifdef QUOTA
-iflush(dev, iq)
- dev_t dev;
- struct inode *iq;
-#else
-iflush(dev)
- dev_t dev;
-#endif
-{
- register struct inode *ip;
- register open = 0;
-
- for (ip = inode; ip < inodeNINODE; ip++) {
-#ifdef QUOTA
- if (ip != iq && ip->i_dev == dev)
-#else
- if (ip->i_dev == dev)
-#endif
- if (ip->i_count)
- return(-1);
- else {
- remque(ip);
- ip->i_forw = ip;
- ip->i_back = ip;
- /*
- * as i_count == 0, the inode was on the free
- * list already, just leave it there, it will
- * fall off the bottom eventually. We could
- * perhaps move it to the head of the free
- * list, but as umounts are done so
- * infrequently, we would gain very little,
- * while making the code bigger.
- */
-#ifdef QUOTA
- dqrele(ip->i_dquot);
- ip->i_dquot = NODQUOT;
-#endif
- }
- else if (ip->i_count && (ip->i_mode&IFMT)==IFBLK &&
- ip->i_rdev == dev)
- open++;
- }
- return (open);
-}
-
-#ifdef ilock
-#undef ilock