missing fsbtodb!
[unix-history] / usr / src / sbin / fsck / utilities.c
index b888a54..3052033 100644 (file)
@@ -5,7 +5,7 @@
  */
 
 #ifndef lint
  */
 
 #ifndef lint
-static char sccsid[] = "@(#)utilities.c        5.11 (Berkeley) %G%";
+static char sccsid[] = "@(#)utilities.c        5.13 (Berkeley) %G%";
 #endif not lint
 
 #include <stdio.h>
 #endif not lint
 
 #include <stdio.h>
@@ -117,6 +117,7 @@ bufinit()
                bufhead.b_next = bp;
                initbarea(bp);
        }
                bufhead.b_next = bp;
                initbarea(bp);
        }
+       bufhead.b_size = i;     /* save number of buffers */
 }
 
 /*
 }
 
 /*
@@ -211,6 +212,7 @@ rwerr(s, blk)
 ckfini()
 {
        register BUFAREA *bp;
 ckfini()
 {
        register BUFAREA *bp;
+       int cnt = 0;
 
        flush(&dfile, &sblk);
        if (havesb && sblk.b_bno != SBOFF / dev_bsize &&
 
        flush(&dfile, &sblk);
        if (havesb && sblk.b_bno != SBOFF / dev_bsize &&
@@ -220,11 +222,15 @@ ckfini()
                flush(&dfile, &sblk);
        }
        flush(&dfile, &cgblk);
                flush(&dfile, &sblk);
        }
        flush(&dfile, &cgblk);
-       for (bp = bufhead.b_prev; bp != &bufhead; bp = bp->b_prev)
+       for (bp = bufhead.b_prev; bp != &bufhead; bp = bp->b_prev) {
+               cnt++;
                flush(&dfile, bp);
                flush(&dfile, bp);
+       }
+       if (bufhead.b_size != cnt)
+               errexit("Panic: lost %d buffers\n", bufhead.b_size - cnt);
        if (debug)
        if (debug)
-               printf("cache hit %d of %d (%d%%)\n", totalreads - diskreads,
-                   totalreads, (totalreads - diskreads) * 100 / totalreads);
+               printf("cache missed %d of %d (%d%%)\n", diskreads,
+                   totalreads, diskreads * 100 / totalreads);
        (void)close(dfile.rfdes);
        (void)close(dfile.wfdes);
 }
        (void)close(dfile.rfdes);
        (void)close(dfile.wfdes);
 }