home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2870 / files.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-28  |  1.8 KB  |  76 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[] = "@(#)files.c    1.2    22:55:32    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/file.h>
  22. #include <sys/page.h>
  23. #include <sys/seg.h>
  24. #include <sys/signal.h>
  25. #include <sys/dir.h>
  26. #include <sys/user.h>
  27. #include "crash.h"
  28.  
  29. prfiles (items, cnt)
  30. int    *items;
  31. int    cnt;
  32. {
  33.     int    i;
  34.  
  35.     files = (struct file *) malloc (v.v_file * sizeof (struct file));
  36.     l_lseek (kmemfd, namelist[NM_FILE].xl_value, 0);
  37.     r_read (kmemfd, files, sizeof (struct file) * v.v_file);
  38.  
  39.     printf ("SLOT    FLAG          COUNT  INODE      OFFSET\n");
  40.     if (cnt == 0) {
  41.         for (i = 0;i < v.v_file;i++) {
  42.             if (files[i].f_count == 0 || files[i].f_flag == 0)
  43.                 continue;
  44.  
  45.             dofile (i);
  46.         }
  47.     } else {
  48.         for (i = 0;i < cnt;i++) {
  49.             if (items[i] >= v.v_file)
  50.                 printf ("value (%d) out of range\n", items[i]);
  51.             else
  52.                 dofile (items[i]);
  53.         }
  54.     }
  55.     free ((char *) files);
  56. }
  57.  
  58.  
  59. dofile (i)
  60. int    i;
  61. {
  62.     printf ("%4d    %03o %c%c%c%c%c%c%c%c  %5d  %5d  %10ld\n",
  63.         i, files[i].f_flag & FMASK,
  64.         (files[i].f_flag & FREAD) ? 'R':' ',
  65.         (files[i].f_flag & FWRITE) ? 'W':' ',
  66.         (files[i].f_flag & FNDELAY) ? 'N':' ',
  67.         (files[i].f_flag & FAPPEND) ? 'A':' ',
  68.         (files[i].f_flag & FSYNC) ? 'S':' ',
  69.         (files[i].f_flag & FCREAT) ? 'C':' ',
  70.         (files[i].f_flag & FTRUNC) ? 'T':' ',
  71.         (files[i].f_flag & FEXCL) ? 'X':' ',
  72.         files[i].f_count,
  73.         files[i].f_inode - (struct inode *) namelist[NM_INODE].xl_value,
  74.         files[i].f_offset);
  75. }
  76.