date and time created 90/06/25 13:56:22 by bostic
[unix-history] / usr / src / usr.bin / vmstat / vmstat.c
index 074358d..b3cba17 100644 (file)
@@ -1,19 +1,32 @@
+/*
+ * Copyright (c) 1980 The Regents of the University of California.
+ * All rights reserved.
+ *
+ * %sccs.include.redist.c%
+ */
+
 #ifndef lint
 #ifndef lint
-static char *sccsid = "@(#)vmstat.c    4.17 (Berkeley) %G%";
-#endif
+char copyright[] =
+"@(#) Copyright (c) 1980 The Regents of the University of California.\n\
+ All rights reserved.\n";
+#endif /* not lint */
 
 
-#include <stdio.h>
-#include <ctype.h>
-#include <nlist.h>
+#ifndef lint
+static char sccsid[] = "@(#)vmstat.c   5.21 (Berkeley) %G%";
+#endif /* not lint */
 
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/vm.h>
 
 #include <sys/param.h>
 #include <sys/file.h>
 #include <sys/vm.h>
-#include <sys/dk.h>
+#include <sys/dkstat.h>
 #include <sys/buf.h>
 #include <sys/buf.h>
-#include <sys/dir.h>
-#include <sys/inode.h>
 #include <sys/namei.h>
 #include <sys/namei.h>
+#include <sys/text.h>
+#include <sys/malloc.h>
+#include <stdio.h>
+#include <ctype.h>
+#include <nlist.h>
+#include <paths.h>
 
 struct nlist nl[] = {
 #define        X_CPTIME        0
 
 struct nlist nl[] = {
 #define        X_CPTIME        0
@@ -56,11 +69,30 @@ struct nlist nl[] = {
        { "_eintrcnt" },
 #define        X_DK_NDRIVE     19
        { "_dk_ndrive" },
        { "_eintrcnt" },
 #define        X_DK_NDRIVE     19
        { "_dk_ndrive" },
+#define        X_XSTATS        20
+       { "_xstats" },
+#define        X_KMEMSTAT      21
+       { "_kmemstats" },
+#define        X_KMEMBUCKETS   22
+       { "_bucket" },
+#define X_END          22
 #ifdef vax
 #ifdef vax
-#define X_MBDINIT      20
+#define X_MBDINIT      (X_END+1)
        { "_mbdinit" },
        { "_mbdinit" },
-#define X_UBDINIT      21
+#define X_UBDINIT      (X_END+2)
        { "_ubdinit" },
        { "_ubdinit" },
+#endif
+#ifdef tahoe
+#define        X_VBDINIT       (X_END+1)
+       { "_vbdinit" },
+#define        X_CKEYSTATS     (X_END+2)
+       { "_ckeystats" },
+#define        X_DKEYSTATS     (X_END+3)
+       { "_dkeystats" },
+#endif
+#ifdef hp300
+#define        X_HPDINIT       (X_END+1)
+       { "_hp_dinit" },
 #endif
        { "" },
 };
 #endif
        { "" },
 };
@@ -72,18 +104,18 @@ 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;
 int    phz;
 int    HZ;
 
 double stat1();
 int    firstfree, maxfree;
 int    hz;
 int    phz;
 int    HZ;
 
-#ifdef vax
-#define        INTS(x) ((x) - (hz + phz))
-#endif
-
 struct {
        int     busy;
        long    time[CPUSTATES];
 struct {
        int     busy;
        long    time[CPUSTATES];
@@ -101,33 +133,33 @@ struct {
 #define        forkstat        s.Forkstat
 
 struct vmmeter osum;
 #define        forkstat        s.Forkstat
 
 struct vmmeter osum;
-int    zero;
 int    deficit;
 double etime;
 int    mf;
 time_t now, boottime;
 int    printhdr();
 int    deficit;
 double etime;
 int    mf;
 time_t now, boottime;
 int    printhdr();
+int    lines = 1;
+
+#define        INTS(x) ((x) - (hz + phz))
 
 main(argc, argv)
        int argc;
        char **argv;
 {
 
 main(argc, argv)
        int argc;
        char **argv;
 {
-       int lines;
        extern char *ctime();
        extern char *ctime();
-       register i,j;
+       register i;
        int iter, nintv, iflag = 0;
        int iter, nintv, iflag = 0;
-       double f1, f2;
        long t;
        long t;
-       char *arg, **cp, name[6], buf[BUFSIZ];
+       char *arg, **cp, buf[BUFSIZ];
 
 
-       nlist("/vmunix", nl);
+       nlist(_PATH_UNIX, nl);
        if(nl[0].n_type == 0) {
        if(nl[0].n_type == 0) {
-               printf("no /vmunix namelist\n");
+               fprintf(stderr, "vmstat: no %s namelist\n", _PATH_UNIX);
                exit(1);
        }
                exit(1);
        }
-       mf = open("/dev/kmem", 0);
+       mf = open(_PATH_KMEM, 0);
        if(mf < 0) {
        if(mf < 0) {
-               printf("cannot open /dev/kmem\n");
+               fprintf(stderr, "vmstat: cannot open %s\n", _PATH_KMEM);
                exit(1);
        }
        iter = 0;
                exit(1);
        }
        iter = 0;
@@ -143,7 +175,7 @@ main(argc, argv)
 
                case 'z':
                        close(mf);
 
                case 'z':
                        close(mf);
-                       mf = open("/dev/kmem", 2);
+                       mf = open(_PATH_KMEM, 2);
                        lseek(mf, (long)nl[X_SUM].n_value, L_SET);
                        write(mf, &z.Sum, sizeof z.Sum);
                        exit(0);
                        lseek(mf, (long)nl[X_SUM].n_value, L_SET);
                        write(mf, &z.Sum, sizeof z.Sum);
                        exit(0);
@@ -152,6 +184,10 @@ main(argc, argv)
                        doforkst();
                        exit(0);
                
                        doforkst();
                        exit(0);
                
+               case 'm':
+                       domem();
+                       exit(0);
+
                case 's':
                        dosum();
                        exit(0);
                case 's':
                        dosum();
                        exit(0);
@@ -162,7 +198,7 @@ main(argc, argv)
 
                default:
                        fprintf(stderr,
 
                default:
                        fprintf(stderr,
-                           "usage: vmstat [ -fsi ] [ interval ] [ count]\n");
+                           "usage: vmstat [ -fsim ] [ interval ] [ count]\n");
                        exit(1);
                }
        }
                        exit(1);
                }
        }
@@ -179,14 +215,14 @@ main(argc, argv)
                read(mf, &phz, sizeof phz);
        }
        HZ = phz ? phz : hz;
                read(mf, &phz, sizeof phz);
        }
        HZ = phz ? phz : hz;
-       if (nl[DK_NDRIVE].n_value == 0) {
-               printf("dk_ndrive undefined in system\n");
+       if (nl[X_DK_NDRIVE].n_value == 0) {
+               fprintf(stderr, "dk_ndrive undefined in system\n");
                exit(1);
        }
        lseek(mf, nl[X_DK_NDRIVE].n_value, L_SET);
        read(mf, &dk_ndrive, sizeof (dk_ndrive));
        if (dk_ndrive <= 0) {
                exit(1);
        }
        lseek(mf, nl[X_DK_NDRIVE].n_value, L_SET);
        read(mf, &dk_ndrive, sizeof (dk_ndrive));
        if (dk_ndrive <= 0) {
-               printf("dk_ndrive %d\n", dk_ndrive);
+               fprintf(stderr, "dk_ndrive %d\n", dk_ndrive);
                exit(1);
        }
        dr_select = (int *)calloc(dk_ndrive, sizeof (int));
                exit(1);
        }
        dr_select = (int *)calloc(dk_ndrive, sizeof (int));
@@ -204,7 +240,8 @@ main(argc, argv)
        time(&now);
        nintv = now - boottime;
        if (nintv <= 0 || nintv > 60*60*24*365*10) {
        time(&now);
        nintv = now - boottime;
        if (nintv <= 0 || nintv > 60*60*24*365*10) {
-               printf("Time makes no sense... namelist must be wrong.\n");
+               fprintf(stderr,
+                   "Time makes no sense... namelist must be wrong.\n");
                exit(1);
        }
        if (iflag) {
                exit(1);
        }
        if (iflag) {
@@ -247,11 +284,9 @@ main(argc, argv)
        if (argc > 1)
                iter = atoi(argv[1]);
        signal(SIGCONT, printhdr);
        if (argc > 1)
                iter = atoi(argv[1]);
        signal(SIGCONT, printhdr);
-reprint:
-       lines = 20;
-       /* s1 = z; */
-       printhdr();
 loop:
 loop:
+       if (--lines == 0)
+               printhdr();
        lseek(mf, (long)nl[X_CPTIME].n_value, L_SET);
        read(mf, s.time, sizeof s.time);
        lseek(mf, (long)nl[X_DKXFER].n_value, L_SET);
        lseek(mf, (long)nl[X_CPTIME].n_value, L_SET);
        read(mf, s.time, sizeof s.time);
        lseek(mf, (long)nl[X_DKXFER].n_value, L_SET);
@@ -284,7 +319,7 @@ loop:
                etime = 1.;
        printf("%2d%2d%2d", total.t_rq, total.t_dw+total.t_pw, total.t_sw);
 #define pgtok(a) ((a)*NBPG/1024)
                etime = 1.;
        printf("%2d%2d%2d", total.t_rq, total.t_dw+total.t_pw, total.t_sw);
 #define pgtok(a) ((a)*NBPG/1024)
-       printf("%6d%5d", pgtok(total.t_avm), pgtok(total.t_free));
+       printf("%6d%6d", pgtok(total.t_avm), pgtok(total.t_free));
        printf("%4d%3d", (rate.v_pgrec - (rate.v_xsfrec+rate.v_xifrec))/nintv,
            (rate.v_xsfrec+rate.v_xifrec)/nintv);
        printf("%4d", pgtok(rate.v_pgpgin)/nintv);
        printf("%4d%3d", (rate.v_pgrec - (rate.v_xsfrec+rate.v_xifrec))/nintv,
            (rate.v_xsfrec+rate.v_xifrec)/nintv);
        printf("%4d", pgtok(rate.v_pgpgin)/nintv);
@@ -306,14 +341,9 @@ loop:
        }
        printf("\n");
        fflush(stdout);
        }
        printf("\n");
        fflush(stdout);
-contin:
        nintv = 1;
        nintv = 1;
-       --iter;
-       if(iter)
-       if(argc > 0) {
+       if (--iter &&argc > 0) {
                sleep(atoi(argv[0]));
                sleep(atoi(argv[0]));
-               if (--lines <= 0)
-                       goto reprint;
                goto loop;
        }
 }
                goto loop;
        }
 }
@@ -322,7 +352,7 @@ printhdr()
 {
        register int i, j;
 
 {
        register int i, j;
 
-       printf(" procs    memory              page           ");
+       printf(" procs     memory              page           ");
        i = (ndrives * 3 - 6) / 2;
        if (i < 0)
                i = 0;
        i = (ndrives * 3 - 6) / 2;
        if (i < 0)
                i = 0;
@@ -333,11 +363,12 @@ printhdr()
        for (j = 0; j < i; j++)
                putchar(' ');
        printf("               cpu\n");
        for (j = 0; j < i; j++)
                putchar(' ');
        printf("               cpu\n");
-       printf(" r b w   avm  fre  re at  pi  po  fr  de  sr ");
+       printf(" r b w   avm   fre  re at  pi  po  fr  de  sr ");
        for (i = 0; i < dk_ndrive; i++)
                if (dr_select[i])
                        printf("%c%c ", dr_name[i][0], dr_name[i][2]);  
        printf(" in  sy  cs us sy id\n");
        for (i = 0; i < dk_ndrive; i++)
                if (dr_select[i])
                        printf("%c%c ", dr_name[i][0], dr_name[i][2]);  
        printf(" in  sy  cs us sy id\n");
+       lines = 19;
 }
 
 dotimes()
 }
 
 dotimes()
@@ -356,10 +387,18 @@ dotimes()
        printf("average: %8.1f msec / page in\n", s.pgintime/(sum.v_pgin*10.0));
 }
 
        printf("average: %8.1f msec / page in\n", s.pgintime/(sum.v_pgin*10.0));
 }
 
+#if defined(tahoe)
+#include <tahoe/cpu.h>
+#endif
+
 dosum()
 {
        struct nchstats nchstats;
 dosum()
 {
        struct nchstats nchstats;
+       struct xstats xstats;
        long nchtotal;
        long nchtotal;
+#if defined(tahoe)
+       struct keystats keystats;
+#endif
 
        lseek(mf, (long)nl[X_SUM].n_value, L_SET);
        read(mf, &sum, sizeof sum);
 
        lseek(mf, (long)nl[X_SUM].n_value, L_SET);
        read(mf, &sum, sizeof sum);
@@ -374,7 +413,7 @@ dosum()
        printf("%9d pages paged out\n", sum.v_pgpgout);
        printf("%9d sequential process pages freed\n", sum.v_seqfree);
        printf("%9d total reclaims (%d%% fast)\n", sum.v_pgrec,
        printf("%9d pages paged out\n", sum.v_pgpgout);
        printf("%9d sequential process pages freed\n", sum.v_seqfree);
        printf("%9d total reclaims (%d%% fast)\n", sum.v_pgrec,
-           (sum.v_fastpgrec * 100) / (sum.v_pgrec == 0 ? 1 : sum.v_pgrec));
+           pct(sum.v_fastpgrec, sum.v_pgrec));
        printf("%9d reclaims from free list\n", sum.v_pgfrec);
        printf("%9d intransit blocking page faults\n", sum.v_intrans);
        printf("%9d zero fill pages created\n", sum.v_nzfod / CLSIZE);
        printf("%9d reclaims from free list\n", sum.v_pgfrec);
        printf("%9d intransit blocking page faults\n", sum.v_intrans);
        printf("%9d zero fill pages created\n", sum.v_nzfod / CLSIZE);
@@ -392,21 +431,51 @@ dosum()
        printf("%9d device interrupts\n", sum.v_intr);
        printf("%9d software interrupts\n", sum.v_soft);
 #ifdef vax
        printf("%9d device interrupts\n", sum.v_intr);
        printf("%9d software interrupts\n", sum.v_soft);
 #ifdef vax
-       printf("%9d pseduo-dma dz interrupts\n", sum.v_pdma);
+       printf("%9d pseudo-dma dz interrupts\n", sum.v_pdma);
 #endif
        printf("%9d traps\n", sum.v_trap);
        printf("%9d system calls\n", sum.v_syscall);
        lseek(mf, (long)nl[X_NCHSTATS].n_value, 0);
        read(mf, &nchstats, sizeof nchstats);
 #endif
        printf("%9d traps\n", sum.v_trap);
        printf("%9d system calls\n", sum.v_syscall);
        lseek(mf, (long)nl[X_NCHSTATS].n_value, 0);
        read(mf, &nchstats, sizeof nchstats);
-       nchtotal = nchstats.ncs_goodhits + nchstats.ncs_badhits +
-           nchstats.ncs_falsehits + nchstats.ncs_miss + nchstats.ncs_long;
-       printf("%9d total name lookups", nchtotal);
-#define        nz(x)   ((x) ? (x) : 1)
-       printf(" (cache hits %d%% system %d%% per-process)\n",
-           nchstats.ncs_goodhits * 100 / nz(nchtotal),
-           nchstats.ncs_pass2 * 100 / nz(nchtotal));
-       printf("%9s badhits %d, falsehits %d, toolong %d\n", "",
-           nchstats.ncs_badhits, nchstats.ncs_falsehits, nchstats.ncs_long);
+       nchtotal = nchstats.ncs_goodhits + nchstats.ncs_neghits +
+           nchstats.ncs_badhits + nchstats.ncs_falsehits +
+           nchstats.ncs_miss + nchstats.ncs_long;
+       printf("%9d total name lookups\n", nchtotal);
+       printf("%9s cache hits (%d%% pos + %d%% neg) system %d%% per-process\n",
+           "", pct(nchstats.ncs_goodhits, nchtotal),
+           pct(nchstats.ncs_neghits, nchtotal),
+           pct(nchstats.ncs_pass2, nchtotal));
+       printf("%9s deletions %d%%, falsehits %d%%, toolong %d%%\n", "",
+           pct(nchstats.ncs_badhits, nchtotal),
+           pct(nchstats.ncs_falsehits, nchtotal),
+           pct(nchstats.ncs_long, nchtotal));
+       lseek(mf, (long)nl[X_XSTATS].n_value, 0);
+       read(mf, &xstats, sizeof xstats);
+       printf("%9d total calls to xalloc (cache hits %d%%)\n",
+           xstats.alloc, pct(xstats.alloc_cachehit, xstats.alloc));
+       printf("%9s sticky %d flushed %d unused %d\n", "",
+           xstats.alloc_inuse, xstats.alloc_cacheflush, xstats.alloc_unused);
+       printf("%9d total calls to xfree", xstats.free);
+       printf(" (sticky %d cached %d swapped %d)\n",
+           xstats.free_inuse, xstats.free_cache, xstats.free_cacheswap);
+#if defined(tahoe)
+       lseek(mf, (long)nl[X_CKEYSTATS].n_value, 0);
+       read(mf, &keystats, sizeof keystats);
+       printf("%9d %s (free %d%% norefs %d%% taken %d%% shared %d%%)\n",
+           keystats.ks_allocs, "code cache keys allocated",
+           pct(keystats.ks_allocfree, keystats.ks_allocs),
+           pct(keystats.ks_norefs, keystats.ks_allocs),
+           pct(keystats.ks_taken, keystats.ks_allocs),
+           pct(keystats.ks_shared, keystats.ks_allocs));
+       lseek(mf, (long)nl[X_DKEYSTATS].n_value, 0);
+       read(mf, &keystats, sizeof keystats);
+       printf("%9d %s (free %d%% norefs %d%% taken %d%% shared %d%%)\n",
+           keystats.ks_allocs, "data cache keys allocated",
+           pct(keystats.ks_allocfree, keystats.ks_allocs),
+           pct(keystats.ks_norefs, keystats.ks_allocs),
+           pct(keystats.ks_taken, keystats.ks_allocs),
+           pct(keystats.ks_shared, keystats.ks_allocs));
+#endif
 }
 
 doforkst()
 }
 
 doforkst()
@@ -484,6 +553,86 @@ dointr(nintv)
        printf("Total        %8ld %8ld\n", inttotal, inttotal / nintv);
 }
 
        printf("Total        %8ld %8ld\n", inttotal, inttotal / nintv);
 }
 
+/*
+ * These names must be kept in sync with
+ * the types defined in <sys/malloc.h>.
+ */
+char *kmemnames[] = {
+       "free",         /* 0 M_FREE */
+       "mbuf",         /* 1 M_MBUF */
+       "devbuf",       /* 2 M_DEVBUF */
+       "socket",       /* 3 M_SOCKET */
+       "pcb",          /* 4 M_PCB */
+       "routetbl",     /* 5 M_RTABLE */
+       "hosttbl",      /* 6 M_HTABLE */
+       "fragtbl",      /* 7 M_FTABLE */
+       "zombie",       /* 8 M_ZOMBIE */
+       "ifaddr",       /* 9 M_IFADDR */
+       "soopts",       /* 10 M_SOOPTS */
+       "soname",       /* 11 M_SONAME */
+       "namei",        /* 12 M_NAMEI */
+       "gprof",        /* 13 M_GPROF */
+       "ioctlops",     /* 14 M_IOCTLOPS */
+       "superblk",     /* 15 M_SUPERBLK */
+       "cred",         /* 16 M_CRED */
+       "pgrp",         /* 17 M_PGRP */
+       "session",      /* 18 M_SESSION */
+       "iov",          /* 19 M_IOV */
+       "mount",        /* 20 M_MOUNT */
+       "fhandle",      /* 21 M_FHANDLE */
+       "NFS req",      /* 22 M_NFSREQ */
+       "NFS mount",    /* 23 M_NFSMNT */
+       "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,
+       "temp",         /* 49 M_TEMP */
+};
+
+domem()
+{
+       struct kmemstats kmemstats[M_LAST];
+       struct kmembuckets buckets[MINBUCKET + 16];
+       register struct kmembuckets *kp;
+       register struct kmemstats *ks;
+       int i;
+
+       lseek(mf, (long)nl[X_KMEMBUCKETS].n_value, L_SET);
+       read(mf, buckets, sizeof buckets);
+       printf("Memory statistics by bucket size\n");
+       printf("    Size   In Use   Free   Requests  HighWater  Couldfree\n");
+       for (i = MINBUCKET, kp = &buckets[i]; i < MINBUCKET + 16; i++, kp++) {
+               if (kp->kb_calls == 0)
+                       continue;
+               printf("%8d%9d%7d%11d%8d%11d\n", 1 << i, 
+                       kp->kb_total - kp->kb_totalfree,
+                       kp->kb_totalfree, kp->kb_calls,
+                       kp->kb_highwat, kp->kb_couldfree);
+               
+       }
+       lseek(mf, (long)nl[X_KMEMSTAT].n_value, L_SET);
+       read(mf, kmemstats, sizeof kmemstats);
+       printf("Memory statistics by type\n");
+       printf("     Type   In Use  MemUse   HighUse  Limit  Requests %s\n",
+               "TypeLimit KernLimit");
+       for (i = 0, ks = &kmemstats[0]; i < M_LAST; i++, ks++) {
+               if (ks->ks_calls == 0)
+                       continue;
+               printf("%10s%7d%8dK%9dK%6dK%9d%7d%10d\n",
+                       kmemnames[i] ? kmemnames[i] : "undefined",
+                       ks->ks_inuse, (ks->ks_memuse + 1023) / 1024,
+                       (ks->ks_maxused + 1023) / 1024,
+                       (ks->ks_limit + 1023) / 1024, ks->ks_calls,
+                       ks->ks_limblocks, ks->ks_mapblocks);
+       }
+}
+
 #define steal(where, var) \
        lseek(mf, where, L_SET); read(mf, &var, sizeof var);
 /*
 #define steal(where, var) \
        lseek(mf, where, L_SET); read(mf, &var, sizeof var);
 /*
@@ -533,3 +682,73 @@ read_names()
        }
 }
 #endif
        }
 }
 #endif
+
+#ifdef tahoe
+#include <tahoevba/vbavar.h>
+
+/*
+ * Read the drive names out of kmem.
+ */
+read_names()
+{
+       struct vba_device udev, *up;
+       struct vba_driver udrv;
+       short two_char;
+       char *cp = (char *)&two_char;
+
+       up = (struct vba_device *) nl[X_VBDINIT].n_value;
+       if (up == 0) {
+               fprintf(stderr, "vmstat: Disk init info not in namelist\n");
+               exit(1);
+       }
+       for (;;) {
+               steal(up++, udev);
+               if (udev.ui_driver == 0)
+                       break;
+               if (udev.ui_dk < 0 || udev.ui_alive == 0)
+                       continue;
+               steal(udev.ui_driver, udrv);
+               steal(udrv.ud_dname, two_char);
+               sprintf(dr_name[udev.ui_dk], "%c%c%d",
+                    cp[0], cp[1], udev.ui_unit);
+       }
+}
+#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