BSD 4 release
[unix-history] / usr / src / cmd / pstat.c
index 536f6b9..2455dc7 100644 (file)
@@ -1,3 +1,4 @@
+static char *sccsid = "@(#)pstat.c     4.3 (Berkeley) 11/15/80";
 /*
  * Print system stuff
  */
 /*
  * Print system stuff
  */
 #include <sys/tty.h>
 #include <sys/conf.h>
 #include <sys/vm.h>
 #include <sys/tty.h>
 #include <sys/conf.h>
 #include <sys/vm.h>
+#include <nlist.h>
+#include <sys/pte.h>
 
 char   *fcore  = "/dev/kmem";
 char   *fnlist = "/vmunix";
 int    fc;
 
 
 char   *fcore  = "/dev/kmem";
 char   *fnlist = "/vmunix";
 int    fc;
 
-struct setup {
-       char    name[8];
-       int     type;
-       unsigned        value;
-} setup[] = {
+struct nlist nl[] = {
 #define        SINODE  0
 #define        SINODE  0
-       "_inode", 0, 0,
+       { "_inode" },
 #define        STEXT   1
 #define        STEXT   1
-       "_text", 0, 0,
+       { "_text" },
 #define        SPROC   2
 #define        SPROC   2
-       "_proc", 0, 0,
+       { "_proc" },
 #define        SDZ     3
 #define        SDZ     3
-       "_dz_tty", 0, 0,
+       { "_dz_tty" },
 #define        SNDZ    4
 #define        SNDZ    4
-       "_dz_cnt", 0, 0,
+       { "_dz_cnt" },
 #define        SKL     5
 #define        SKL     5
-       "_cons", 0, 0,
+       { "_cons" },
 #define        SFIL    6
 #define        SFIL    6
-       "_file", 0, 0,
-#define        SMPXC   7
-       "_mpx_cha", 0, 0,
-#define        SMPXM   8
-       "_mpx_mac", 0, 0,
-#define        SMPXB1  9
-       "_mptbc", 0, 0,
-#define        SMPXB2  10
-       "_mptbuf", 0, 0,
-#define        SMPSM   11
-       "_mpsm", 0, 0,
+       { "_file" },
+#define        USRPTMA 7
+       { "_Usrptmap" },
+#define        USRPT   8
+       { "_usrpt" },
+#define        SNSWAP  9
+       { "_nswap" },
+#define        SWAPMAP 10
+       { "_swapmap" },
+#define        SDH     11
+       { "_dh11" },
+#define        SNDH    12
+       { "_ndh11" },
        0,
 };
 
        0,
 };
 
@@ -57,15 +58,18 @@ int inof;
 int    txtf;
 int    prcf;
 int    ttyf;
 int    txtf;
 int    prcf;
 int    ttyf;
-int    mpxf;
 int    usrf;
 long   ubase;
 int    filf;
 int    usrf;
 long   ubase;
 int    filf;
+int    swpf;
+int    totflg;
 char   partab[1];
 struct cdevsw  cdevsw[1];
 struct bdevsw  bdevsw[1];
 int    allflg;
 int    kflg;
 char   partab[1];
 struct cdevsw  cdevsw[1];
 struct bdevsw  bdevsw[1];
 int    allflg;
 int    kflg;
+struct pte *Usrptma;
+struct pte *usrpt;
 
 main(argc, argv)
 char **argv;
 
 main(argc, argv)
 char **argv;
@@ -80,6 +84,10 @@ char **argv;
                while (*argp++)
                switch (argp[-1]) {
 
                while (*argp++)
                switch (argp[-1]) {
 
+               case 'T':
+                       totflg++;
+                       break;
+
                case 'a':
                        allflg++;
                        break;
                case 'a':
                        allflg++;
                        break;
@@ -96,6 +104,7 @@ char **argv;
                case 'x':
                        txtf++;
                        break;
                case 'x':
                        txtf++;
                        break;
+
                case 'p':
                        prcf++;
                        break;
                case 'p':
                        prcf++;
                        break;
@@ -104,10 +113,6 @@ char **argv;
                        ttyf++;
                        break;
 
                        ttyf++;
                        break;
 
-               case 'm':
-                       mpxf++;
-                       break;
-
                case 'u':
                        if (argc == 0)
                                break;
                case 'u':
                        if (argc == 0)
                                break;
@@ -119,6 +124,9 @@ char **argv;
                case 'f':
                        filf++;
                        break;
                case 'f':
                        filf++;
                        break;
+               case 's':
+                       swpf++;
+                       break;
                }
        }
        if (argc>0)
                }
        }
        if (argc>0)
@@ -129,32 +137,32 @@ char **argv;
        }
        if (argc>1)
                fnlist = argv[1];
        }
        if (argc>1)
                fnlist = argv[1];
-       nlist(fnlist, setup);
+       nlist(fnlist, nl);
        if (kflg) {
        if (kflg) {
-               register struct setup *sp;
-               for (sp=setup; sp->value; sp++)
-                       sp->value &= 0x7fffffff;
+               register struct nlist *nlp;
+               for (nlp=nl; nlp < &nl[sizeof (nl)/sizeof(nl[0])]; nlp++)
+                       nlp->n_value = clear(nlp->n_value);
        }
        }
-       if (setup[SINODE].type == -1) {
+       usrpt = (struct pte *)nl[USRPT].n_value;
+       Usrptma = (struct pte *)nl[USRPTMA].n_value;
+       if (nl[0].n_type == 0) {
                printf("no namelist\n");
                exit(1);
        }
                printf("no namelist\n");
                exit(1);
        }
-       if (inof)
+       if (filf||totflg)
+               dofil();
+       if (inof||totflg)
                doinode();
                doinode();
-       if (txtf)
+       if (prcf||totflg)
+               doproc();
+       if (txtf||totflg)
                dotext();
        if (ttyf)
                dotty();
                dotext();
        if (ttyf)
                dotty();
-       if (prcf)
-               doproc();
        if (usrf)
                dousr();
        if (usrf)
                dousr();
-       if (filf)
-               dofil();
-/*
-       if(mpxf)
-               dompx();
-*/
+       if (swpf||totflg)
+               doswap();
 }
 
 doinode()
 }
 
 doinode()
@@ -164,14 +172,18 @@ doinode()
        register int nin, loc;
 
        nin = 0;
        register int nin, loc;
 
        nin = 0;
-       lseek(fc, (long)setup[SINODE].value, 0);
+       lseek(fc, (long)nl[SINODE].n_value, 0);
        read(fc, xinode, sizeof(xinode));
        for (ip = xinode; ip < &xinode[NINODE]; ip++)
                if (ip->i_count)
                        nin++;
        read(fc, xinode, sizeof(xinode));
        for (ip = xinode; ip < &xinode[NINODE]; ip++)
                if (ip->i_count)
                        nin++;
-       printf("%d active xinodes\n", nin);
-       printf("   LOC    FLAGS  CNT DEVICE  INO  MODE  NLK UID   SIZE/DEV\n");
-       loc = setup[SINODE].value;
+       if (totflg) {
+               printf("%3d/%3d inodes\n", nin, NINODE);
+               return;
+       }
+       printf("%d/%d active xinodes\n", nin, NINODE);
+       printf("   LOC    FLAGS  CNT DEVICE   INO  MODE  NLK UID   SIZE/DEV\n");
+       loc = nl[SINODE].n_value;
        for (ip = xinode; ip < &xinode[NINODE]; ip++, loc += sizeof(xinode[0])) {
                if (ip->i_count == 0)
                        continue;
        for (ip = xinode; ip < &xinode[NINODE]; ip++, loc += sizeof(xinode[0])) {
                if (ip->i_count == 0)
                        continue;
@@ -184,7 +196,7 @@ doinode()
                putf(ip->i_flag&ITEXT, 'T');
                printf("%4d", ip->i_count&0377);
                printf("%4d,%3d", major(ip->i_dev), minor(ip->i_dev));
                putf(ip->i_flag&ITEXT, 'T');
                printf("%4d", ip->i_count&0377);
                printf("%4d,%3d", major(ip->i_dev), minor(ip->i_dev));
-               printf("%5l", ip->i_number);
+               printf("%6d", ip->i_number);
                printf("%6x", ip->i_mode & 0xffff);
                printf("%4d", ip->i_nlink);
                printf("%4d", ip->i_uid);
                printf("%6x", ip->i_mode & 0xffff);
                printf("%4d", ip->i_nlink);
                printf("%4d", ip->i_uid);
@@ -212,14 +224,17 @@ dotext()
        int ntx;
 
        ntx = 0;
        int ntx;
 
        ntx = 0;
-       lseek(fc, (long)setup[STEXT].value, 0);
+       lseek(fc, (long)nl[STEXT].n_value, 0);
        read(fc, xtext, sizeof(xtext));
        for (xp = xtext; xp < &xtext[NTEXT]; xp++)
                if (xp->x_iptr!=NULL)
                        ntx++;
        read(fc, xtext, sizeof(xtext));
        for (xp = xtext; xp < &xtext[NTEXT]; xp++)
                if (xp->x_iptr!=NULL)
                        ntx++;
-       printf("%d text segments\n", ntx);
-       printf("   LOC   FLAGS  DADDR   CADDR  RSS   SIZE   IPTR    CNT CCNT\n");
-       loc = setup[STEXT].value;
+       if (totflg) {
+               printf("%3d/%3d texts\n", ntx, NTEXT);
+               return;
+       }
+       printf("   LOC   FLAGS DADDR      CADDR  RSS SIZE      IPTR  CNT CCNT\n");
+       loc = nl[STEXT].n_value;
        for (xp = xtext; xp < &xtext[NTEXT]; xp++, loc+=sizeof(xtext[0])) {
                if (xp->x_iptr == NULL)
                        continue;
        for (xp = xtext; xp < &xtext[NTEXT]; xp++, loc+=sizeof(xtext[0])) {
                if (xp->x_iptr == NULL)
                        continue;
@@ -231,13 +246,13 @@ dotext()
                putf(xp->x_flag&XLOAD, 'L');
                putf(xp->x_flag&XLOCK, 'K');
                putf(xp->x_flag&XWANT, 'w');
                putf(xp->x_flag&XLOAD, 'L');
                putf(xp->x_flag&XLOCK, 'K');
                putf(xp->x_flag&XWANT, 'w');
-               printf("%5x", xp->x_daddr);
+               printf("%5x", xp->x_daddr[0]);
                printf("%11x", xp->x_caddr);
                printf("%5d", xp->x_rssize);
                printf("%5d", xp->x_size);
                printf("%10.1x", xp->x_iptr);
                printf("%5d", xp->x_count&0377);
                printf("%11x", xp->x_caddr);
                printf("%5d", xp->x_rssize);
                printf("%5d", xp->x_size);
                printf("%10.1x", xp->x_iptr);
                printf("%5d", xp->x_count&0377);
-               printf("%4d", xp->x_ccount);
+               printf("%5d", xp->x_ccount);
                printf("\n");
        }
 }
                printf("\n");
        }
 }
@@ -247,16 +262,21 @@ doproc()
        struct proc xproc[NPROC];
        register struct proc *pp;
        register loc, np;
        struct proc xproc[NPROC];
        register struct proc *pp;
        register loc, np;
+       struct pte apte;
 
 
-       lseek(fc, (long)setup[SPROC].value, 0);
+       lseek(fc, (long)nl[SPROC].n_value, 0);
        read(fc, xproc, sizeof(xproc));
        np = 0;
        for (pp=xproc; pp < &xproc[NPROC]; pp++)
                if (pp->p_stat)
                        np++;
        read(fc, xproc, sizeof(xproc));
        np = 0;
        for (pp=xproc; pp < &xproc[NPROC]; pp++)
                if (pp->p_stat)
                        np++;
-       printf("%d processes\n", np);
-       printf("   LOC    S    F POIP PRI SIG  UID  SLP TIM  CPU  NI    PGRP   PID   PPID    ADDR   RSS  SRSS SIZE   WCHAN    LINK   TEXTP CLKT\n");
-       for (loc=setup[SPROC].value,pp=xproc; pp<&xproc[NPROC]; pp++,loc+=sizeof(xproc[0])) {
+       if (totflg) {
+               printf("%3d/%3d processes\n", np, NPROC);
+               return;
+       }
+       printf("%d/%d processes\n", np, NPROC);
+       printf("   LOC    S    F POIP PRI      SIG  UID SLP TIM  CPU  NI   PGRP    PID   PPID    ADDR   RSS SRSS SIZE    WCHAN    LINK   TEXTP CLKT\n");
+       for (loc=nl[SPROC].n_value,pp=xproc; pp<&xproc[NPROC]; pp++,loc+=sizeof(xproc[0])) {
                if (pp->p_stat==0 && allflg==0)
                        continue;
                printf("%8x", loc);
                if (pp->p_stat==0 && allflg==0)
                        continue;
                printf("%8x", loc);
@@ -264,7 +284,7 @@ doproc()
                printf(" %4x", pp->p_flag & 0xffff);
                printf(" %4d", pp->p_poip);
                printf(" %3d", pp->p_pri);
                printf(" %4x", pp->p_flag & 0xffff);
                printf(" %4d", pp->p_poip);
                printf(" %3d", pp->p_pri);
-               printf(" %4x", pp->p_sig);
+               printf(" %8x", pp->p_sig);
                printf(" %4d", pp->p_uid);
                printf(" %3d", pp->p_slptime);
                printf(" %3d", pp->p_time);
                printf(" %4d", pp->p_uid);
                printf(" %3d", pp->p_slptime);
                printf(" %3d", pp->p_time);
@@ -273,7 +293,11 @@ doproc()
                printf(" %6d", pp->p_pgrp);
                printf(" %6d", pp->p_pid);
                printf(" %6d", pp->p_ppid);
                printf(" %6d", pp->p_pgrp);
                printf(" %6d", pp->p_pid);
                printf(" %6d", pp->p_ppid);
-               printf(" %8x", pp->p_addr[0]);
+               if (kflg)
+                       pp->p_addr = (struct pte *)clear((int)pp->p_addr);
+               lseek(fc, (long)(Usrptma+btokmx(pp->p_addr)), 0);
+               read(fc, &apte, sizeof(apte));
+               printf(" %8x", ctob(apte.pg_pfnum+1) - sizeof(struct pte) * UPAGES);
                printf(" %4x", pp->p_rssize);
                printf(" %4x", pp->p_swrss);
                printf(" %5x", pp->p_dsize+pp->p_ssize);
                printf(" %4x", pp->p_rssize);
                printf(" %4x", pp->p_swrss);
                printf(" %5x", pp->p_dsize+pp->p_ssize);
@@ -287,36 +311,58 @@ doproc()
 
 dotty()
 {
 
 dotty()
 {
-       struct tty dz_tty[32];
+       struct tty dz_tty[64];
        int ndz;
        register struct tty *tp;
        register char *mesg;
 
        printf("1 cons\n");
        int ndz;
        register struct tty *tp;
        register char *mesg;
 
        printf("1 cons\n");
-       lseek(fc, (long)setup[SKL].value, 0);
+       lseek(fc, (long)nl[SKL].n_value, 0);
        read(fc, dz_tty, sizeof(dz_tty[0]));
        read(fc, dz_tty, sizeof(dz_tty[0]));
-       mesg = " RAW CAN OUT   MODE    ADDR   DEL COL  STATE   PGRP\n";
+       mesg = " # RAW CAN OUT   MODE    ADDR   DEL COL  STATE   PGRP DISC\n";
        printf(mesg);
        printf(mesg);
-       ttyprt(&dz_tty[0]);
-       if (setup[SNDZ].type == -1)
-               return;
-       lseek(fc, (long)setup[SNDZ].value, 0);
+       ttyprt(&dz_tty[0], 0);
+       if (nl[SNDZ].n_type == 0)
+               goto dh;
+       lseek(fc, (long)nl[SNDZ].n_value, 0);
        read(fc, &ndz, sizeof(ndz));
        printf("%d dz lines\n", ndz);
        read(fc, &ndz, sizeof(ndz));
        printf("%d dz lines\n", ndz);
-       lseek(fc, (long)setup[SDZ].value, 0);
+       lseek(fc, (long)nl[SDZ].n_value, 0);
        read(fc, dz_tty, sizeof(dz_tty));
        for (tp = dz_tty; tp < &dz_tty[ndz]; tp++)
        read(fc, dz_tty, sizeof(dz_tty));
        for (tp = dz_tty; tp < &dz_tty[ndz]; tp++)
-               ttyprt(tp);
+               ttyprt(tp, tp - dz_tty);
+dh:
+       if (nl[SNDH].n_type == 0)
+               return;
+       lseek(fc, (long)nl[SNDH].n_value, 0);
+       read(fc, &ndz, sizeof(ndz));
+       printf("%d dh lines\n", ndz);
+       lseek(fc, (long)nl[SDH].n_value, 0);
+       read(fc, dz_tty, sizeof(dz_tty));
+       for (tp = dz_tty; tp < &dz_tty[ndz]; tp++)
+               ttyprt(tp, tp - dz_tty);
 }
 
 }
 
-ttyprt(atp)
+ttyprt(atp, line)
 struct tty *atp;
 {
        register struct tty *tp;
 
 struct tty *atp;
 {
        register struct tty *tp;
 
+       printf("%2d", line);
        tp = atp;
        tp = atp;
-       printf("%4d", tp->t_rawq.c_cc);
-       printf("%4d", tp->t_canq.c_cc);
+       switch (tp->t_line) {
+
+       case NETLDISC:
+               if (tp->t_rec)
+                       printf("%4d%4d", 0, tp->t_inbuf);
+               else
+                       printf("%4d%4d", tp->t_inbuf, 0);
+               break;
+
+       default:
+               printf("%4d", tp->t_rawq.c_cc);
+               printf("%4d", tp->t_canq.c_cc);
+       }
        printf("%4d", tp->t_outq.c_cc);
        printf("%8.1o", tp->t_flags);
        printf(" %8.1x", tp->t_addr);
        printf("%4d", tp->t_outq.c_cc);
        printf("%8.1o", tp->t_flags);
        printf(" %8.1x", tp->t_addr);
@@ -333,6 +379,16 @@ struct tty *atp;
        putf(tp->t_state&HUPCLS, 'H');
  */
        printf("%6d", tp->t_pgrp);
        putf(tp->t_state&HUPCLS, 'H');
  */
        printf("%6d", tp->t_pgrp);
+       switch (tp->t_line) {
+
+       case NTTYDISC:
+               printf(" ntty");
+               break;
+
+       case NETLDISC:
+               printf(" net");
+               break;
+       }
        printf("\n");
 }
 
        printf("\n");
 }
 
@@ -344,63 +400,99 @@ dousr()
        /* This wins only if PAGSIZ > sizeof (struct user) */
        lseek(fc, ubase * NBPG, 0);
        read(fc, &U, sizeof(U));
        /* This wins only if PAGSIZ > sizeof (struct user) */
        lseek(fc, ubase * NBPG, 0);
        read(fc, &U, sizeof(U));
-/*
-       printf("rsav %.1o %.1o\n", U.u_rsav[0], U.u_rsav[1]);
- */
-       printf("segflg, error %d, %d\n", U.u_segflg, U.u_error);
-       printf("uids %d,%d,%d,%d\n", U.u_uid,U.u_gid,U.u_ruid,U.u_rgid);
-       printf("procp %.1x\n", U.u_procp);
+       printf("pcb");
+       ip = (int *)&U.u_pcb;
+       while (ip < &U.u_arg[0]) {
+               if ((ip - (int *)&U.u_pcb) % 4 == 0)
+                       printf("\t");
+               printf("%x ", *ip++);
+               if ((ip - (int *)&U.u_pcb) % 4 == 0)
+                       printf("\n");
+       }
+       if ((ip - (int *)&U.u_pcb) % 4 != 0)
+               printf("\n");
+       printf("arg\t");
+       for (i=0; i<5; i++)
+               printf(" %.1x", U.u_arg[i]);
+       printf("\n");
+       for (i=0; i<sizeof(label_t)/sizeof(int); i++) {
+               if (i%5==0)
+                       printf("\t");
+               printf("%9.1x", U.u_ssav[i]);
+               if (i%5==4)
+                       printf("\n");
+       }
+       if (i%5)
+               printf("\n");
+       printf("segflg\t%d\nerror %d\n", U.u_segflg, U.u_error);
+       printf("uids\t%d,%d,%d,%d\n", U.u_uid,U.u_gid,U.u_ruid,U.u_rgid);
+       printf("procp\t%.1x\n", U.u_procp);
+       printf("ap\t%.1x\n", U.u_ap);
+       printf("r_val?\t%.1x %.1x\n", U.u_r.r_val1, U.u_r.r_val2);
        printf("base, count, offset %.1x %.1x %ld\n", U.u_base,
                U.u_count, U.u_offset);
        printf("base, count, offset %.1x %.1x %ld\n", U.u_base,
                U.u_count, U.u_offset);
-       printf("cdir %.1x\n", U.u_cdir);
+       printf("cdir rdir %.1x %.1x\n", U.u_cdir, U.u_rdir);
        printf("dbuf %.14s\n", U.u_dbuf);
        printf("dirp %.1x\n", U.u_dirp);
        printf("dent %d %.14s\n", U.u_dent.d_ino, U.u_dent.d_name);
        printf("pdir %.1o\n", U.u_pdir);
        printf("dbuf %.14s\n", U.u_dbuf);
        printf("dirp %.1x\n", U.u_dirp);
        printf("dent %d %.14s\n", U.u_dent.d_ino, U.u_dent.d_name);
        printf("pdir %.1o\n", U.u_pdir);
-/*
-       printf("dseg");
-       for (i=0; i<8; i++)
-               printf("%8.1o", U.u_uisa[i]);
-       printf("\n    ");
-       for (i=0; i<8; i++)
-               printf("%8.1o", U.u_uisd[i]);
-       if (U.u_sep) {
-               printf("\ntseg");
-               for (i=8; i<16; i++)
-                       printf("%8.1o", U.u_uisa[i]);
-               printf("\n    ");
-               for (i=8; i<16; i++)
-                       printf("%8.1o", U.u_uisd[i]);
-       }
- */
-       printf("\nfile");
+       printf("file\t");
        for (i=0; i<10; i++)
                printf("%9.1x", U.u_ofile[i]);
        for (i=0; i<10; i++)
                printf("%9.1x", U.u_ofile[i]);
-       printf("\n    ");
+       printf("\n\t");
        for (i=10; i<NOFILE; i++)
                printf("%9.1x", U.u_ofile[i]);
        for (i=10; i<NOFILE; i++)
                printf("%9.1x", U.u_ofile[i]);
-       printf("\nargs");
-       for (i=0; i<5; i++)
-               printf(" %.1x", U.u_arg[i]);
-       printf("\nsizes %.1x %.1x %.1x\n", U.u_tsize, U.u_dsize, U.u_ssize);
-       printf("sep %d\n", U.u_sep);
-       printf("qsav %.1x %.1x\n", U.u_qsav[0], U.u_qsav[1]);
-       printf("ssav %.1x %.1x\n", U.u_ssav[0], U.u_ssav[1]);
-       printf("sigs");
+       printf("\n");
+       printf("pofile\t");
+       for (i=0; i<10; i++)
+               printf("%9.1x", U.u_pofile[i]);
+       printf("\n\t");
+       for (i=10; i<NOFILE; i++)
+               printf("%9.1x", U.u_pofile[i]);
+       printf("\n");
+       printf("ssav");
+       for (i=0; i<sizeof(label_t)/sizeof(int); i++) {
+               if (i%5==0)
+                       printf("\t");
+               printf("%9.1x", U.u_ssav[i]);
+               if (i%5==4)
+                       printf("\n");
+       }
+       if (i%5)
+               printf("\n");
+       printf("sigs\t");
        for (i=0; i<NSIG; i++)
        for (i=0; i<NSIG; i++)
-               printf(" %.1x", U.u_signal[i]);
-       printf("\ntimes %ld %ld\n", U.u_utime/60, U.u_stime/60);
-       printf("ctimes %ld %ld\n", U.u_cutime/60, U.u_cstime/60);
-       printf("ar0 %.1x\n", U.u_ar0);
-/*
-       printf("prof");
-       for (i=0; i<4; i++)
-               printf(" %.1o", U.u_prof[i]);
-*/
-       printf("\nintflg %d\n", U.u_intflg);
-       printf("ttyp %.1x\n", U.u_ttyp);
-       printf("ttydev %d,%d\n", major(U.u_ttyd), minor(U.u_ttyd));
+               printf("%.1x ", U.u_signal[i]);
+       printf("\n");
+       printf("cfcode\t%.1x\n", U.u_cfcode);
+       printf("ar0\t%.1x\n", U.u_ar0);
+       printf("prof\t%X %X %X %X\n", U.u_prof.pr_base, U.u_prof.pr_size,
+           U.u_prof.pr_off, U.u_prof.pr_scale);
+       printf("\neosys\t%d\n", U.u_eosys);
+       printf("sep\t%d\n", U.u_sep);
+       printf("ttyp\t%.1x\n", U.u_ttyp);
+       printf("ttyd\t%d,%d\n", major(U.u_ttyd), minor(U.u_ttyd));
+       printf("exdata\t");
+       ip = (int *)&U.u_exdata;
+       for (i = 0; i < 8; i++)
+               printf("%.1D ", *ip++);
+       printf("\n");
        printf("comm %.14s\n", U.u_comm);
        printf("comm %.14s\n", U.u_comm);
+       printf("start\t%D\n", U.u_start);
+       printf("acflag\t%D\n", U.u_acflag);
+       printf("fpflag\t%D\n", U.u_fpflag);
+       printf("cmask\t%D\n", U.u_cmask);
+       printf("sizes\t%.1x %.1x %.1x\n", U.u_tsize, U.u_dsize, U.u_ssize);
+       printf("vm\t");
+       ip = (int *)&U.u_vm;
+       for (i = 0; i < sizeof(U.u_vm)/sizeof(int); i++)
+               printf("%D ", ip[i]);
+       printf("\n");
+       ip = (int *)&U.u_cvm;
+       printf("cvm\t");
+       for (i = 0; i < sizeof(U.u_vm)/sizeof(int); i++)
+               printf("%D ", ip[i]);
+       printf("\n");
 /*
        i =  U.u_stack - &U;
        while (U[++i] == 0);
 /*
        i =  U.u_stack - &U;
        while (U[++i] == 0);
@@ -433,14 +525,18 @@ dofil()
        int loc;
 
        nf = 0;
        int loc;
 
        nf = 0;
-       lseek(fc, (long)setup[SFIL].value, 0);
+       lseek(fc, (long)nl[SFIL].n_value, 0);
        read(fc, xfile, sizeof(xfile));
        for (fp=xfile; fp < &xfile[NFILE]; fp++)
                if (fp->f_count)
                        nf++;
        read(fc, xfile, sizeof(xfile));
        for (fp=xfile; fp < &xfile[NFILE]; fp++)
                if (fp->f_count)
                        nf++;
-       printf("%d open files\n", nf);
+       if (totflg) {
+               printf("%3d/%3d files\n", nf, NFILE);
+               return;
+       }
+       printf("%d/%d open files\n", nf, NFILE);
        printf("   LOC   FLG  CNT   INO    OFFS\n");
        printf("   LOC   FLG  CNT   INO    OFFS\n");
-       for (fp=xfile,loc=setup[SFIL].value; fp < &xfile[NFILE]; fp++,loc+=sizeof(xfile[0])) {
+       for (fp=xfile,loc=nl[SFIL].n_value; fp < &xfile[NFILE]; fp++,loc+=sizeof(xfile[0])) {
                if (fp->f_count==0)
                        continue;
                printf("%8x ", loc);
                if (fp->f_count==0)
                        continue;
                printf("%8x ", loc);
@@ -453,106 +549,78 @@ dofil()
        }
 }
 
        }
 }
 
-/*********
-#include <sys/mpx.h>
-dompx()
+doswap()
 {
 {
-       struct chan chan[C];
-       struct mach mach[M];
-       struct line line[M-1];
-       int mptbc;
-       char mptbuf[TBSIZ];
-       register struct chan *cp;
-       register struct mach *mp;
-       register struct line *lp;
-       int loc, nc;
-
-       lseek(fc, (long)setup[SMPXC].value, 0);
-       read(fc, chan, sizeof(chan));
-       lseek(fc, (long)setup[SMPXM].value, 0);
-       read(fc, mach, sizeof(mach));
-       lseek(fc, (long)setup[SMPXB1].value, 0);
-       read(fc, &mptbc, sizeof(mptbc));
-       lseek(fc, (long)setup[SMPXB2].value, 0);
-       read(fc, mptbuf, sizeof(mptbuf));
-       lseek(fc, (long)setup[SMPSM].value, 0);
-       read(fc, line, sizeof(line));
-       nc = 0;
-       for(cp=chan; cp < &chan[C]; cp++)
-               if(cp->cflag&ALLOC)
-                       nc++;
-       printf("%d mpx channels\n", nc);
-       printf("   LOC      FLG M   C    DEST\n");
-       for(cp=chan,loc=setup[SMPXC].value; cp < &chan[C]; cp++,loc=+sizeof(chan[0])) {
-               if((cp->cflag&ALLOC) == 0)
-                       continue;
-               printf("%7.1o ", loc);
-               putf(cp->cflag&BLOCK, 'B');
-               putf(cp->cflag&WWAIT, 'B');
-               putf(cp->cflag&CRUN, 'R');
-               putf(cp->cflag&RWAIT, 'W');
-               putf(cp->cflag&ALLOC, 'A');
-               putf(cp->cflag&DIS, 'D');
-               putf(cp->cflag&DLY, 'D');
-               printf(" %1d %3d ", mask(cp->m), mask(cp->c));
-               printf("%7.1o ", cp->dest);
-               printf("\n");
-       }
+       struct proc proc[NPROC];
+       struct text xtext[NTEXT];
+       struct map swapmap[SMAPSIZ];
+       register struct proc *pp;
+       int nswap, used, tused, free;
+       register struct map *mp;
+       register struct text *xp;
 
 
-       printf("%d mpx machines\n", M);
-       printf("   LOC  FLG RCH RCN XCH XCN\n");
-       for(mp=mach,loc=setup[SMPXM].value; mp < &mach[M]; mp++,loc=+sizeof(mach[0])) {
-               printf("%7.1o ", loc);
-               putf(mp->mflag&RNEXT, 'N');
-               putf(mp->mflag&MRUN, 'R');
-               putf(mp->mflag&XNEXT, 'N');
-               printf(" %3d", mask(mp->rchan));
-               printf(" %3d", mask(mp->rcount));
-               printf(" %3d", mask(mp->xchan));
-               printf(" %3d", mask(mp->xcount));
-               for(nc=0; nc<128; nc++) {
-                       cp = mp->chanp[nc];
-                       if(cp == 0)
-                               continue;
-                       printf(" %d-%o", nc, cp);
-               }
-               printf("\n");
+       lseek(fc, (long)nl[SPROC].n_value, 0);
+       read(fc, proc, sizeof(proc));
+       lseek(fc, (long)nl[SWAPMAP].n_value, 0);
+       read(fc, swapmap, sizeof(swapmap));
+       lseek(fc, (long)nl[SNSWAP].n_value, 0);
+       read(fc, &nswap, sizeof(nswap));
+       free = 0;
+       for (mp = swapmap; mp < &swapmap[SMAPSIZ]; mp++)
+               free += mp->m_size;
+       lseek(fc, (long)nl[STEXT].n_value, 0);
+       read(fc, xtext, sizeof(xtext));
+       tused = 0;
+       for (xp = xtext; xp < &xtext[NTEXT]; xp++)
+               if (xp->x_iptr!=NULL)
+                       tused += xdsize(xp);
+       used = tused;
+       for (pp = proc; pp < &proc[NPROC]; pp++) {
+               if (pp->p_stat == 0 || pp->p_stat == SZOMB)
+                       continue;
+               if (pp->p_flag & SSYS)
+                       continue;
+               used += up(pp->p_dsize) + up(pp->p_ssize);
+               if ((pp->p_flag&SLOAD) == 0)
+                       used += vusize(pp);
        }
        }
-       printf("%d mpx lines\n", M-1);
-       printf("   LOC  RSQ XSQ AKF XMF STE TIM SUM\n");
-       for(lp=line,loc=setup[SMPSM].value; lp < &line[M-1]; lp++, loc =+ sizeof(line[0])) {
-               printf("%7.1o ", loc);
-               printf("%3o ", lp->rseq);
-               printf("%3o ", lp->xseq);
-               printf("%3o ", lp->ackf);
-               printf("%3o ", lp->xflag);
-               printf("%3d ", lp->state);
-               printf("%3d ", lp->time);
-               printf("%7o\n", lp->sum);
+       /* a DMMAX block goes to argmap */
+       if (totflg) {
+               printf("%3d/%3d 00k swap\n", used/2/100, (used+free)/2/100);
+               return;
        }
        }
-       printf("last characters recieved\n");
-       nc = -1;
-       loc = mptbc;
-       for(;;) {
-               if(nc != mptbuf[loc]) {
-                       if(nc >= 0)
-                               printf(")\n");
-                       nc = mptbuf[loc];
-                       printf("%d(", nc);
-               } else
-                       printf(",");
-               loc++;
-               if(loc >= TBSIZ)
-                       loc = 0;
-               if(loc == mptbc)
-                       break;
-               printf("%o", mask(mptbuf[loc]));
-               loc++;
-               if(loc >= TBSIZ)
-                       loc = 0;
-               if(loc == mptbc)
-                       break;
+       printf("%d used (%d text), %d free, %d missing\n",
+           used/2, tused/2, free/2, (nswap - DMMAX - (used + free))/2);
+}
+
+up(size)
+       register int size;
+{
+       register int i, block;
+
+       i = 0;
+       block = DMMIN;
+       while (i < size) {
+               i += block;
+               if (block < DMMAX)
+                       block *= 2;
        }
        }
-       printf(")\n");
+       return (i);
+}
+
+vusize(p)
+struct proc *p;
+{
+       register int tsz = p->p_tsize / NPTEPG;
+
+       return (clrnd(UPAGES + clrnd(ctopt(p->p_tsize+p->p_dsize+p->p_ssize+UPAGES)) - tsz));
+}
+
+xdsize(xp)
+struct text *xp;
+{
+
+       if (xp->x_flag & XPAGI)
+               return (clrnd(xp->x_size + ctopt(xp->x_size)));
+       return (xp->x_size);
 }
 }
-*********/