home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2870 / bufs.c next >
Encoding:
C/C++ Source or Header  |  1991-02-28  |  2.1 KB  |  87 lines

  1. /*
  2.  * Copyright 1988, John F. Haugh II
  3.  * All rights reserved.
  4.  *
  5.  * Permission is granted to copy and create derivative works for any
  6.  * non-commercial purpose, provided this copyright notice is preserved
  7.  * in all copies of source code, or included in human readable form
  8.  * and conspicuously displayed on all copies of object code or
  9.  * distribution media.
  10.  */
  11.  
  12. #ifndef    lint
  13. static    char    sccsid[] = "@(#)bufs.c    1.2    22:55:28    2/21/91";
  14. #endif
  15.  
  16. #include <sys/param.h>
  17. #include <sys/sysmacros.h>
  18. #include <sys/types.h>
  19. #include <sys/var.h>
  20. #include <sys/inode.h>
  21. #include <sys/ino.h>
  22. #include <sys/buf.h>
  23. #include <a.out.h>
  24. #include "crash.h"
  25.  
  26. prbufs (items, cnt)
  27. int    *items;
  28. int    cnt;
  29. {
  30.     int    i;
  31.  
  32.     bufs = (struct buf *) malloc (v.v_buf * sizeof (struct buf));
  33.  
  34.     l_lseek (kmemfd, namelist[NM_BUFFER].xl_value, 0);
  35.     r_read (kmemfd, &bufstart, sizeof bufstart);
  36.  
  37.     l_lseek (memfd, bufstart, 0);
  38.     r_read (memfd, bufs, v.v_buf * sizeof (struct buf));
  39.  
  40.     printf (" BUF MAJ  MIN    BLOCK FLAGS\n");
  41.  
  42.     if (cnt == 0) {
  43.         for (i = 0;i < v.v_buf;i++) {
  44.             if (bufs[i].b_flags == 0)
  45.                 continue;
  46.  
  47.             dobuf (i);
  48.         }
  49.     } else {
  50.         for (i = 0;i < cnt;i++) {
  51.             if (items[i] >= v.v_buf)
  52.                 printf ("value (%d) out of range\n", items[i]);
  53.             else
  54.                 dobuf (items[i]);
  55.         }
  56.     }
  57.     free ((char *) bufs);
  58. }
  59.  
  60. dobuf (i)
  61. int    i;
  62. {
  63.     struct    buf    *bp;
  64.  
  65.     bp = &bufs[i];
  66.  
  67.     printf ("%4d %03.3o %04.4o %8d",
  68.         i, major (bp->b_dev) & 0377, minor (bp->b_dev), bp->b_blkno);
  69.  
  70.     if (bp->b_flags & B_READ)    printf (" read");
  71.     if (bp->b_flags & B_DONE)    printf (" done");
  72.     if (bp->b_flags & B_ERROR)    printf (" error");
  73.     if (bp->b_flags & B_BUSY)    printf (" busy");
  74.     if (bp->b_flags & B_PHYS)    printf (" phys");
  75.     if (bp->b_flags & B_MAP)    printf (" map");
  76.     if (bp->b_flags & B_WANTED)    printf (" wanted");
  77.     if (bp->b_flags & B_AGE)    printf (" age");
  78.     if (bp->b_flags & B_ASYNC)    printf (" async");
  79.     if (bp->b_flags & B_DELWRI)    printf (" delwri");
  80.     if (bp->b_flags & B_OPEN)    printf (" open");
  81.     if (bp->b_flags & B_STALE)    printf (" stale");
  82.     if (bp->b_flags & B_NOCROSS)    printf (" nocross");
  83.     if (bp->b_flags & B_FLUSH)    printf (" flush");
  84.  
  85.     putchar ('\n');
  86. }
  87.