home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2870 / inodes.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-28  |  2.3 KB  |  95 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[] = "@(#)inodes.c    1.2    22:55:34    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 <a.out.h>
  22. #include "crash.h"
  23.  
  24. prinodes (items, cnt)
  25. int    *items;
  26. int    cnt;
  27. {
  28.     int    i;
  29.  
  30.     inodes = (struct inode *) malloc (v.v_inode * sizeof (struct inode));
  31.     l_lseek (kmemfd, namelist[NM_INODE].xl_value, 0);
  32.     r_read (kmemfd, inodes, sizeof (struct inode) * v.v_inode);
  33.  
  34.     printf ("SLOT MAJ  MIN INUMB REF LINK  UID  GID     SIZE    MODE SMAJ SMIN FLAGS\n");
  35.  
  36.     if (cnt == 0) {
  37.         for (i = 0;i < v.v_inode;i++) {
  38.             if (inodes[i].i_count == 0)
  39.                 continue;
  40.  
  41.             doinode (i);
  42.         }
  43.     } else {
  44.         for (i = 0;i < cnt;i++) {
  45.             if (items[i] >= v.v_inode)
  46.                 printf ("value (%d) out of range\n", items[i]);
  47.             else
  48.                 doinode (items[i]);
  49.         }
  50.     }
  51.     free ((char *) inodes);
  52. }
  53.     
  54. doinode (i)
  55. int    i;
  56. {
  57.     char    *modes = " pcCd bBf";
  58.     struct    inode    *ip;
  59.  
  60.     ip = &inodes[i];
  61.  
  62.     printf ("%4d %03o %04o %5d %3d %4d%5d%5d %8ld %c%c%c%c%03o",
  63.         i, major (ip->i_dev), minor (ip->i_dev), ip->i_number,
  64.         ip->i_count, ip->i_nlink, ip->i_uid, ip->i_gid,
  65.         ip->i_size,
  66.         modes[(ip->i_mode & IFMT) >> 12],
  67.         (ip->i_mode & ISUID) ? 'u':'-',
  68.         (ip->i_mode & ISGID) ? 'g':'-',
  69.         (ip->i_mode & ISVTX) ? 't':'-',
  70.         (ip->i_mode & 0777));
  71.  
  72.     if (! (((ip->i_mode & IFMT) == IFDIR) ||
  73.         ((ip->i_mode & IFMT) == IFREG) ||
  74.         ((ip->i_mode & IFMT) == IFIFO)))
  75.         printf (" %04o %04o", major (ip->i_rdev),
  76.                     minor (ip->i_rdev));
  77.     else
  78.         printf ("    -    -");    /* special file stuff */
  79.     if (ip->i_flag & IUPD)        printf (" upd");
  80.     if (ip->i_flag & IACC)        printf (" acc");
  81.     if (ip->i_flag & ICHG)        printf (" chg");
  82.     if (ip->i_flag & IMOUNT)    printf (" mnt");
  83.     if (ip->i_flag & ITEXT)        printf (" txt");
  84.     if (ip->i_flag & ILOCK)        printf (" lck");
  85. #ifdef    ISYN
  86.     if (ip->i_flag & ISYN)        printf (" syn");
  87. #endif
  88. #ifdef    IRMT
  89.     if (ip->i_flag & IRMT)        printf (" rmt");
  90. #endif
  91.     if (ip->i_flag & IWANT)        printf (" wnt");
  92.  
  93.     printf ("\n");
  94. }
  95.