-
-/*
- * make sure all write-behind blocks
- * on dev (or NODEV for all)
- * are flushed out.
- * (from umount and update)
- * (and temporarily pagein)
- */
-bflush(dev)
- dev_t dev;
-{
- register struct buf *bp;
- register struct buf *flist;
- int s;
-
-loop:
- s = spl6();
- for (flist = bfreelist; flist < &bfreelist[BQUEUES]; flist++)
- for (bp = flist->av_forw; bp != flist; bp = bp->av_forw) {
- if ((bp->b_flags & B_DELWRI) == 0)
- continue;
- if (dev == NODEV || dev == bp->b_dev) {
- bp->b_flags |= B_ASYNC;
- notavail(bp);
- bwrite(bp);
- goto loop;
- }
- }
- splx(s);
-}
-
-/*
- * Pick up the device's error number and pass it to the user;
- * if there is an error but the number is 0 set a generalized
- * code. Actually the latter is always true because devices
- * don't yet return specific errors.
- */
-geterror(bp)
- register struct buf *bp;
-{
-
- if (bp->b_flags&B_ERROR)
- if ((u.u_error = bp->b_error)==0)
- u.u_error = EIO;
-}
-
-/*
- * Invalidate in core blocks belonging to closed or umounted filesystem
- *
- * This is not nicely done at all - the buffer ought to be removed from the
- * hash chains & have its dev/blkno fields clobbered, but unfortunately we
- * can't do that here, as it is quite possible that the block is still
- * being used for i/o. Eventually, all disc drivers should be forced to
- * have a close routine, which ought ensure that the queue is empty, then
- * properly flush the queues. Until that happy day, this suffices for
- * correctness. ... kre
- */
-binval(dev)
- dev_t dev;
-{
- register struct buf *bp;
- register struct bufhd *hp;
-#define dp ((struct buf *)hp)
-
- for (hp = bufhash; hp < &bufhash[BUFHSZ]; hp++)
- for (bp = dp->b_forw; bp != dp; bp = bp->b_forw)
- if (bp->b_dev == dev)
- bp->b_flags |= B_INVAL;
-}