home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2870 / mounts.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-28  |  2.3 KB  |  97 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[] = "@(#)mounts.c    1.2    22:55:36    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 <sys/filsys.h>
  24. #include <sys/mount.h>
  25. #include <a.out.h>
  26. #include "crash.h"
  27.  
  28. prmounts (items, cnt)
  29. int    *items;
  30. int    cnt;
  31. {
  32.     int    i;
  33.  
  34.     mounts = (struct mount *) malloc (v.v_mount * sizeof (struct mount));
  35.     l_lseek (kmemfd, namelist[NM_MOUNT].xl_value, 0);
  36.     r_read (kmemfd, mounts, sizeof (struct mount) * v.v_mount);
  37.     l_lseek (kmemfd, namelist[NM_BUFFER].xl_value, 0);
  38.     r_read (kmemfd, &bufstart, sizeof bufstart);
  39.  
  40.     printf ("SLOT  MAJ  MIN  INODE  BUF  VOLUME  PACK   BLOCKS INODES  BFREE  IFREE\n");
  41.  
  42.     if (cnt == 0) {
  43.         for (i = 0;i < v.v_mount;i++) {
  44.             if (mounts[i].m_flags == 0)
  45.                 continue;
  46.  
  47.             domount (i);
  48.         }
  49.     } else {
  50.         for (i = 0;i < cnt;i++) {
  51.             if (items[i] >= v.v_mount)
  52.                 printf ("value (%d) out of range\n", items[i]);
  53.             else
  54.                 domount (items[i]);
  55.         }
  56.     }
  57.     free ((char *) mounts);
  58. }
  59.  
  60. domount (i)
  61. int    i;
  62. {
  63.     struct    filsys    filsys;
  64.     struct    buf    buf;
  65.     struct    inode    *ip = (struct inode *) namelist[NM_INODE].xl_value;
  66.  
  67.     printf ("%4d %4o  %03o %6d %4d",
  68.         i, major (mounts[i].m_dev), minor (mounts[i].m_dev),
  69.         mounts[i].m_inodp ?
  70.             mounts[i].m_inodp - ip : 0,
  71.         mounts[i].m_bufp ?
  72.             mounts[i].m_bufp - bufstart : 0);
  73.  
  74.     /*
  75.      * zero before using since unused mount entries don't have
  76.      * buffers and such.
  77.      */
  78.  
  79.     memset (&buf, 0, sizeof buf);
  80.     memset (&filsys, 0, sizeof filsys);
  81.  
  82.     if (mounts[i].m_flags != 0) {
  83.         l_lseek (memfd, (long) mounts[i].m_bufp, 0);
  84.         r_read (memfd, &buf, sizeof buf);
  85.         l_lseek (memfd, (long) buf.b_paddr, 0);
  86.         r_read (memfd, &filsys, sizeof filsys);
  87.     }
  88.     printf ("  %-6.6s  %-6.6s",
  89.         filsys.s_fname, filsys.s_fpack);
  90.  
  91.     printf (" %6ld %6ld %6ld %6ld",
  92.         filsys.s_fsize, INOPB * filsys.s_isize,
  93.         (long) filsys.s_tfree, (long) filsys.s_tinode);
  94.  
  95.     putchar ('\n');
  96. }
  97.