date and time created 90/06/25 13:56:22 by bostic
[unix-history] / usr / src / usr.bin / vmstat / vmstat.c
index f684748..b3cba17 100644 (file)
@@ -2,17 +2,7 @@
  * Copyright (c) 1980 The Regents of the University of California.
  * All rights reserved.
  *
  * Copyright (c) 1980 The Regents of the University of California.
  * All rights reserved.
  *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley.  The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
+ * %sccs.include.redist.c%
  */
 
 #ifndef lint
  */
 
 #ifndef lint
@@ -22,7 +12,7 @@ char copyright[] =
 #endif /* not lint */
 
 #ifndef lint
 #endif /* not lint */
 
 #ifndef lint
-static char sccsid[] = "@(#)vmstat.c   5.17 (Berkeley) %G%";
+static char sccsid[] = "@(#)vmstat.c   5.21 (Berkeley) %G%";
 #endif /* not lint */
 
 #include <sys/param.h>
 #endif /* not lint */
 
 #include <sys/param.h>
@@ -30,9 +20,6 @@ static char sccsid[] = "@(#)vmstat.c  5.17 (Berkeley) %G%";
 #include <sys/vm.h>
 #include <sys/dkstat.h>
 #include <sys/buf.h>
 #include <sys/vm.h>
 #include <sys/dkstat.h>
 #include <sys/buf.h>
-#include <sys/time.h>
-#include <sys/vnode.h>
-#include <ufs/inode.h>
 #include <sys/namei.h>
 #include <sys/text.h>
 #include <sys/malloc.h>
 #include <sys/namei.h>
 #include <sys/text.h>
 #include <sys/malloc.h>
@@ -88,19 +75,24 @@ struct nlist nl[] = {
        { "_kmemstats" },
 #define        X_KMEMBUCKETS   22
        { "_bucket" },
        { "_kmemstats" },
 #define        X_KMEMBUCKETS   22
        { "_bucket" },
+#define X_END          22
 #ifdef vax
 #ifdef vax
-#define X_MBDINIT      (X_XSTATS+1)
+#define X_MBDINIT      (X_END+1)
        { "_mbdinit" },
        { "_mbdinit" },
-#define X_UBDINIT      (X_XSTATS+2)
+#define X_UBDINIT      (X_END+2)
        { "_ubdinit" },
 #endif
 #ifdef tahoe
        { "_ubdinit" },
 #endif
 #ifdef tahoe
-#define        X_VBDINIT       (X_XSTATS+1)
+#define        X_VBDINIT       (X_END+1)
        { "_vbdinit" },
        { "_vbdinit" },
-#define        X_CKEYSTATS     (X_XSTATS+2)
+#define        X_CKEYSTATS     (X_END+2)
        { "_ckeystats" },
        { "_ckeystats" },
-#define        X_DKEYSTATS     (X_XSTATS+3)
+#define        X_DKEYSTATS     (X_END+3)
        { "_dkeystats" },
        { "_dkeystats" },
+#endif
+#ifdef hp300
+#define        X_HPDINIT       (X_END+1)
+       { "_hp_dinit" },
 #endif
        { "" },
 };
 #endif
        { "" },
 };
@@ -112,8 +104,12 @@ int        ndrives = 0;
 #ifdef vax
 char   *defdrives[] = { "hp0", "hp1", "hp2",  0 };
 #else
 #ifdef vax
 char   *defdrives[] = { "hp0", "hp1", "hp2",  0 };
 #else
+#ifdef hp300
+char   *defdrives[] = { "rd0", "rd1", "rd2",  0 };
+#else
 char   *defdrives[] = { 0 };
 #endif
 char   *defdrives[] = { 0 };
 #endif
+#endif
 double stat1();
 int    firstfree, maxfree;
 int    hz;
 double stat1();
 int    firstfree, maxfree;
 int    hz;
@@ -586,8 +582,13 @@ char *kmemnames[] = {
        "fhandle",      /* 21 M_FHANDLE */
        "NFS req",      /* 22 M_NFSREQ */
        "NFS mount",    /* 23 M_NFSMNT */
        "fhandle",      /* 21 M_FHANDLE */
        "NFS req",      /* 22 M_NFSREQ */
        "NFS mount",    /* 23 M_NFSMNT */
-       0, 0, 0, 0, 0,
-       0, 0, 0, 0, 0,
+       "vnodes",       /* 24 M_VNODE */
+       "namecache",    /* 25 M_CACHE */
+       "UFS quota",    /* 26 M_DQUOT */
+       "UFS mount",    /* 27 M_UFSMNT */
+       "mapmem",       /* 28 M_MAPMEM */
+       "shm",          /* 29 M_SHM */
+       0, 0, 0, 0,
        0, 0, 0, 0, 0,
        0, 0, 0, 0, 0,
        0, 0, 0, 0, 0,
        0, 0, 0, 0, 0,
        0, 0, 0, 0, 0,
        0, 0, 0, 0, 0,
@@ -713,3 +714,41 @@ read_names()
        }
 }
 #endif
        }
 }
 #endif
+
+#ifdef hp300
+#include <hpdev/device.h>
+
+#define validdisk(cp)  ((cp)[1] == 'd' && ((cp)[0] == 'r' || (cp)[0] == 's'))
+
+read_names()
+{
+       struct hp_device hdev;
+       register struct hp_device *hp;
+       struct driver hdrv;
+       short two_char;
+       char *cp = (char *) &two_char;
+       register char *dp;
+
+       hp = (struct hp_device *) nl[X_HPDINIT].n_value;
+       if (hp == 0) {
+               fprintf(stderr, "vmstat: Disk init info not in namelist\n");
+               exit(1);
+       }
+       for (;;) {
+               steal(hp++, hdev);
+               if (hdev.hp_driver == 0)
+                       break;
+               steal(hdev.hp_driver, hdrv);
+               steal(hdrv.d_name, two_char);
+               /*
+                * hp_dk is meaningless if the device isn't a disk
+                * (d_name not valid) or the disk was not found when
+                * booting (hp_alive == 0).
+                */
+               if (!validdisk(cp) || hdev.hp_alive == 0)
+                       continue;
+               dp = dr_name[hdev.hp_dk];
+               sprintf(dp, "%c%c%d", cp[0], cp[1], hdev.hp_unit);
+       }
+}
+#endif