added vfontinfo vwidth pac
[unix-history] / usr / src / usr.sbin / pstat / pstat.c
index 41d702a..1b90cd9 100644 (file)
@@ -1,4 +1,6 @@
-static char *sccsid = "@(#)pstat.c     4.5 (Berkeley) %G%";
+#ifndef lint
+static char *sccsid = "@(#) (Berkeley) 82/12/24";
+#endif
 /*
  * Print system stuff
  */
 /*
  * Print system stuff
  */
@@ -8,20 +10,21 @@ static char *sccsid = "@(#)pstat.c   4.5 (Berkeley) %G%";
 
 #include <sys/param.h>
 #include <sys/dir.h>
 
 #include <sys/param.h>
 #include <sys/dir.h>
+#define        KERNEL
 #include <sys/file.h>
 #include <sys/file.h>
+#undef KERNEL
 #include <sys/user.h>
 #include <sys/proc.h>
 #include <sys/text.h>
 #include <sys/inode.h>
 #include <sys/map.h>
 #include <sys/user.h>
 #include <sys/proc.h>
 #include <sys/text.h>
 #include <sys/inode.h>
 #include <sys/map.h>
+#include <sys/ioctl.h>
 #include <sys/tty.h>
 #include <sys/conf.h>
 #include <sys/vm.h>
 #include <nlist.h>
 #include <sys/tty.h>
 #include <sys/conf.h>
 #include <sys/vm.h>
 #include <nlist.h>
-#include <sys/pte.h>
-#define        KERNEL
-#include <sys/mx.h>
-#undef KERNEL
+#include <machine/pte.h>
+#include <sys/descrip.h>
 
 char   *fcore  = "/dev/kmem";
 char   *fnlist = "/vmunix";
 
 char   *fcore  = "/dev/kmem";
 char   *fnlist = "/vmunix";
@@ -54,22 +57,18 @@ struct nlist nl[] = {
        { "_dh11" },
 #define        SNDH    12
        { "_ndh11" },
        { "_dh11" },
 #define        SNDH    12
        { "_ndh11" },
-#define        SGROUP  13
-       { "_groups" },
-#define        SCHANS  14
-       { "_chans" },
-#define        SSCHANS 15
-       { "_schans" },
-#define        SNPROC  16
+#define        SNPROC  13
        { "_nproc" },
        { "_nproc" },
-#define        SNTEXT  17
+#define        SNTEXT  14
        { "_ntext" },
        { "_ntext" },
-#define        SNFILE  18
+#define        SNFILE  15
        { "_nfile" },
        { "_nfile" },
-#define        SNINODE 19
+#define        SNINODE 16
        { "_ninode" },
        { "_ninode" },
-#define        SNSWAPMAP 20
+#define        SNSWAPMAP 17
        { "_nswapmap" },
        { "_nswapmap" },
+#define        SPTY    18
+       { "_pt_tty" },
        0,
 };
 
        0,
 };
 
@@ -78,8 +77,6 @@ int   txtf;
 int    prcf;
 int    ttyf;
 int    usrf;
 int    prcf;
 int    ttyf;
 int    usrf;
-int    mpxf;
-int    groupf;
 long   ubase;
 int    filf;
 int    swpf;
 long   ubase;
 int    filf;
 int    swpf;
@@ -96,6 +93,7 @@ main(argc, argv)
 char **argv;
 {
        register char *argp;
 char **argv;
 {
        register char *argp;
+       int allflags;
 
        argc--, argv++;
        while (argc > 0 && **argv == '-') {
 
        argc--, argv++;
        while (argc > 0 && **argv == '-') {
@@ -148,34 +146,31 @@ char **argv;
                case 's':
                        swpf++;
                        break;
                case 's':
                        swpf++;
                        break;
-               case 'm':
-                       mpxf++;
-                       break;
-               case 'g':
-                       groupf++;
-                       break;
+               default:
+                       usage();
+                       exit(1);
                }
        }
                }
        }
-       if (argc>0)
-               fcore = argv[0];
+       if (argc>1)
+               fcore = argv[1];
        if ((fc = open(fcore, 0)) < 0) {
                printf("Can't find %s\n", fcore);
                exit(1);
        }
        if ((fc = open(fcore, 0)) < 0) {
                printf("Can't find %s\n", fcore);
                exit(1);
        }
-       if (argc>1)
-               fnlist = argv[1];
+       if (argc>0)
+               fnlist = argv[0];
        nlist(fnlist, nl);
        nlist(fnlist, nl);
-       if (kflg) {
-               register struct nlist *nlp;
-               for (nlp=nl; nlp < &nl[sizeof (nl)/sizeof(nl[0])]; nlp++)
-                       nlp->n_value = clear(nlp->n_value);
-       }
        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);
        }
        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);
        }
+       allflags = filf | totflg | inof | prcf | txtf | ttyf | usrf | swpf;
+       if (allflags == 0) {
+               printf("pstat: one or more of -[aixptfsu] is required\n");
+               exit(1);
+       }
        if (filf||totflg)
                dofile();
        if (inof||totflg)
        if (filf||totflg)
                dofile();
        if (inof||totflg)
@@ -190,10 +185,12 @@ char **argv;
                dousr();
        if (swpf||totflg)
                doswap();
                dousr();
        if (swpf||totflg)
                doswap();
-       if (mpxf)
-               dompx();
-       if (groupf)
-               dogroup();
+}
+
+usage()
+{
+
+       printf("usage: pstat -[aixptfs] [-u [ubase]] [system] [core]\n");
 }
 
 doinode()
 }
 
 doinode()
@@ -216,25 +213,31 @@ doinode()
                return;
        }
        printf("%d/%d active inodes\n", nin, ninode);
                return;
        }
        printf("%d/%d active inodes\n", nin, ninode);
-       printf("   LOC    FLAGS  CNT DEVICE   INO  MODE  NLK UID   SIZE/DEV\n");
+printf("   LOC      FLAGS    CNT DEVICE  RDC WRC  INO  MODE  NLK UID   SIZE/DEV\n");
        for (ip = xinode; ip < &xinode[ninode]; ip++) {
                if (ip->i_count == 0)
                        continue;
                printf("%8.1x ", ainode + (ip - xinode));
        for (ip = xinode; ip < &xinode[ninode]; ip++) {
                if (ip->i_count == 0)
                        continue;
                printf("%8.1x ", ainode + (ip - xinode));
-               putf(ip->i_flag&ILOCK, 'L');
+               putf(ip->i_flag&ILOCKED, 'L');
                putf(ip->i_flag&IUPD, 'U');
                putf(ip->i_flag&IACC, 'A');
                putf(ip->i_flag&IMOUNT, 'M');
                putf(ip->i_flag&IWANT, 'W');
                putf(ip->i_flag&ITEXT, 'T');
                putf(ip->i_flag&IUPD, 'U');
                putf(ip->i_flag&IACC, 'A');
                putf(ip->i_flag&IMOUNT, 'M');
                putf(ip->i_flag&IWANT, 'W');
                putf(ip->i_flag&ITEXT, 'T');
+               putf(ip->i_flag&ICHG, 'C');
+               putf(ip->i_flag&ISHLOCK, 'S');
+               putf(ip->i_flag&IEXLOCK, 'E');
+               putf(ip->i_flag&ILWAIT, 'Z');
                printf("%4d", ip->i_count&0377);
                printf("%4d,%3d", major(ip->i_dev), minor(ip->i_dev));
                printf("%4d", ip->i_count&0377);
                printf("%4d,%3d", major(ip->i_dev), minor(ip->i_dev));
+               printf("%4d", ip->i_shlockc&0377);
+               printf("%4d", ip->i_exlockc&0377);
                printf("%6d", ip->i_number);
                printf("%6x", ip->i_mode & 0xffff);
                printf("%4d", ip->i_nlink);
                printf("%4d", ip->i_uid);
                if ((ip->i_mode&IFMT)==IFBLK || (ip->i_mode&IFMT)==IFCHR)
                printf("%6d", ip->i_number);
                printf("%6x", ip->i_mode & 0xffff);
                printf("%4d", ip->i_nlink);
                printf("%4d", ip->i_uid);
                if ((ip->i_mode&IFMT)==IFBLK || (ip->i_mode&IFMT)==IFCHR)
-                       printf("%6d,%3d", major(ip->i_un.i_rdev), minor(ip->i_un.i_rdev));
+                       printf("%6d,%3d", major(ip->i_rdev), minor(ip->i_rdev));
                else
                        printf("%10ld", ip->i_size);
                printf("\n");
                else
                        printf("%10ld", ip->i_size);
                printf("\n");
@@ -247,8 +250,12 @@ getw(loc)
 {
        int word;
 
 {
        int word;
 
+       if (kflg)
+               loc &= 0x7fffffff;
        lseek(fc, loc, 0);
        read(fc, &word, sizeof (word));
        lseek(fc, loc, 0);
        read(fc, &word, sizeof (word));
+       if (kflg)
+               word &= 0x7fffffff;
        return (word);
 }
 
        return (word);
 }
 
@@ -354,19 +361,20 @@ doproc()
                printf(" %7x", clear(pp->p_wchan));
                printf(" %7x", clear(pp->p_link));
                printf(" %7x", clear(pp->p_textp));
                printf(" %7x", clear(pp->p_wchan));
                printf(" %7x", clear(pp->p_link));
                printf(" %7x", clear(pp->p_textp));
-               printf("    %u", pp->p_clktim);
                printf("\n");
        }
 }
 
 dotty()
 {
                printf("\n");
        }
 }
 
 dotty()
 {
-       struct tty dz_tty[64];
+       struct tty dz_tty[128];
        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");
+       if (kflg)
+               nl[SKL].n_value = clear(nl[SKL].n_value);
        lseek(fc, (long)nl[SKL].n_value, 0);
        read(fc, dz_tty, sizeof(dz_tty[0]));
        mesg = " # RAW CAN OUT   MODE    ADDR   DEL COL  STATE   PGRP DISC\n";
        lseek(fc, (long)nl[SKL].n_value, 0);
        read(fc, dz_tty, sizeof(dz_tty[0]));
        mesg = " # RAW CAN OUT   MODE    ADDR   DEL COL  STATE   PGRP DISC\n";
@@ -374,23 +382,42 @@ dotty()
        ttyprt(&dz_tty[0], 0);
        if (nl[SNDZ].n_type == 0)
                goto dh;
        ttyprt(&dz_tty[0], 0);
        if (nl[SNDZ].n_type == 0)
                goto dh;
+       if (kflg) {
+               nl[SNDZ].n_value = clear(nl[SNDZ].n_value);
+               nl[SDZ].n_value = clear(nl[SDZ].n_value);
+       }
        lseek(fc, (long)nl[SNDZ].n_value, 0);
        read(fc, &ndz, sizeof(ndz));
        printf("%d dz lines\n", ndz);
        lseek(fc, (long)nl[SDZ].n_value, 0);
        lseek(fc, (long)nl[SNDZ].n_value, 0);
        read(fc, &ndz, sizeof(ndz));
        printf("%d dz lines\n", ndz);
        lseek(fc, (long)nl[SDZ].n_value, 0);
-       read(fc, dz_tty, sizeof(dz_tty));
+       read(fc, dz_tty, ndz * sizeof (struct tty));
        for (tp = dz_tty; tp < &dz_tty[ndz]; tp++)
                ttyprt(tp, tp - dz_tty);
 dh:
        if (nl[SNDH].n_type == 0)
        for (tp = dz_tty; tp < &dz_tty[ndz]; tp++)
                ttyprt(tp, tp - dz_tty);
 dh:
        if (nl[SNDH].n_type == 0)
-               return;
+               goto pty;
+       if (kflg) {
+               nl[SNDH].n_value = clear(nl[SNDH].n_value);
+               nl[SDH].n_value = clear(nl[SDH].n_value);
+       }
        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);
        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));
+       read(fc, dz_tty, ndz * sizeof(struct tty));
        for (tp = dz_tty; tp < &dz_tty[ndz]; tp++)
                ttyprt(tp, tp - dz_tty);
        for (tp = dz_tty; tp < &dz_tty[ndz]; tp++)
                ttyprt(tp, tp - dz_tty);
+pty:
+       if (nl[SPTY].n_type == 0)
+               goto pty;
+       if (kflg) {
+               nl[SPTY].n_value = clear(nl[SPTY].n_value);
+       }
+       printf("32 pty lines\n");
+       lseek(fc, (long)nl[SPTY].n_value, 0);
+       read(fc, dz_tty, 32*sizeof(struct tty));
+       for (tp = dz_tty; tp < &dz_tty[32]; tp++)
+               ttyprt(tp, tp - dz_tty);
 }
 
 ttyprt(atp, line)
 }
 
 ttyprt(atp, line)
@@ -402,32 +429,32 @@ struct tty *atp;
        tp = atp;
        switch (tp->t_line) {
 
        tp = atp;
        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;
        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);
 
        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_flags);
        printf(" %8.1x", tp->t_addr);
        printf("%3d", tp->t_delct);
        printf("%4d ", tp->t_col);
        printf(" %8.1x", tp->t_addr);
        printf("%3d", tp->t_delct);
        printf("%4d ", tp->t_col);
-       putf(tp->t_state&TIMEOUT, 'T');
-       putf(tp->t_state&WOPEN, 'W');
-       putf(tp->t_state&ISOPEN, 'O');
-       putf(tp->t_state&CARR_ON, 'C');
-       putf(tp->t_state&BUSY, 'B');
-       putf(tp->t_state&ASLEEP, 'A');
-       putf(tp->t_state&XCLUDE, 'X');
-/*
-       putf(tp->t_state&HUPCLS, 'H');
- */
+       putf(tp->t_state&TS_TIMEOUT, 'T');
+       putf(tp->t_state&TS_WOPEN, 'W');
+       putf(tp->t_state&TS_ISOPEN, 'O');
+       putf(tp->t_state&TS_CARR_ON, 'C');
+       putf(tp->t_state&TS_BUSY, 'B');
+       putf(tp->t_state&TS_ASLEEP, 'A');
+       putf(tp->t_state&TS_XCLUDE, 'X');
+       putf(tp->t_state&TS_HUPCLS, 'H');
        printf("%6d", tp->t_pgrp);
        switch (tp->t_line) {
 
        printf("%6d", tp->t_pgrp);
        switch (tp->t_line) {
 
@@ -468,7 +495,7 @@ dousr()
        for (i=0; i<sizeof(label_t)/sizeof(int); i++) {
                if (i%5==0)
                        printf("\t");
        for (i=0; i<sizeof(label_t)/sizeof(int); i++) {
                if (i%5==0)
                        printf("\t");
-               printf("%9.1x", U.u_ssav[i]);
+               printf("%9.1x", U.u_ssave.val[i]);
                if (i%5==4)
                        printf("\n");
        }
                if (i%5==4)
                        printf("\n");
        }
@@ -482,7 +509,6 @@ dousr()
        printf("base, count, offset %.1x %.1x %ld\n", U.u_base,
                U.u_count, U.u_offset);
        printf("cdir rdir %.1x %.1x\n", U.u_cdir, U.u_rdir);
        printf("base, count, offset %.1x %.1x %ld\n", U.u_base,
                U.u_count, U.u_offset);
        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("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);
@@ -500,11 +526,11 @@ dousr()
        for (i=10; i<NOFILE; i++)
                printf("%9.1x", U.u_pofile[i]);
        printf("\n");
        for (i=10; i<NOFILE; i++)
                printf("%9.1x", U.u_pofile[i]);
        printf("\n");
-       printf("ssav");
+       printf("ssave");
        for (i=0; i<sizeof(label_t)/sizeof(int); i++) {
                if (i%5==0)
                        printf("\t");
        for (i=0; i<sizeof(label_t)/sizeof(int); i++) {
                if (i%5==0)
                        printf("\t");
-               printf("%9.1x", U.u_ssav[i]);
+               printf("%9.1x", U.u_ssave.val[i]);
                if (i%5==4)
                        printf("\n");
        }
                if (i%5==4)
                        printf("\n");
        }
@@ -514,12 +540,11 @@ dousr()
        for (i=0; i<NSIG; i++)
                printf("%.1x ", U.u_signal[i]);
        printf("\n");
        for (i=0; i<NSIG; i++)
                printf("%.1x ", U.u_signal[i]);
        printf("\n");
-       printf("cfcode\t%.1x\n", U.u_cfcode);
+       printf("code\t%.1x\n", U.u_code);
        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("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");
        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");
@@ -530,17 +555,16 @@ dousr()
        printf("comm %.14s\n", U.u_comm);
        printf("start\t%D\n", U.u_start);
        printf("acflag\t%D\n", U.u_acflag);
        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("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("ru\t");
+       ip = (int *)&U.u_ru;
+       for (i = 0; i < sizeof(U.u_ru)/sizeof(int); i++)
                printf("%D ", ip[i]);
        printf("\n");
                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++)
+       ip = (int *)&U.u_cru;
+       printf("cru\t");
+       for (i = 0; i < sizeof(U.u_cru)/sizeof(int); i++)
                printf("%D ", ip[i]);
        printf("\n");
 /*
                printf("%D ", ip[i]);
        printf("\n");
 /*
@@ -574,6 +598,10 @@ dofile()
        register struct file *fp;
        register nf;
        int loc;
        register struct file *fp;
        register nf;
        int loc;
+       static char *dtypes[] = {
+               "???", "kernel", "fsys", "file", "dir", "bdev",
+               "cdev", "proc", "socket", "domain", "tty"
+       };
 
        nf = 0;
        nfile = getw(nl[SNFILE].n_value);
 
        nf = 0;
        nfile = getw(nl[SNFILE].n_value);
@@ -588,17 +616,24 @@ dofile()
                return;
        }
        printf("%d/%d open files\n", nf, nfile);
                return;
        }
        printf("%d/%d open files\n", nf, nfile);
-       printf("   LOC   FLG  CNT   INO    OFFS\n");
-       for (fp=xfile,loc=nl[SFIL].n_value; fp < &xfile[nfile]; fp++,loc+=sizeof(xfile[0])) {
+       printf("   LOC   TYPE    FLG  CNT   INO    OFFS|SOCK\n");
+       for (fp=xfile,loc=(int)afile; 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);
+               if (fp->f_type <= DTYPE_TERMINAL)
+                       printf("%-8.8s", dtypes[fp->f_type]);
+               else
+                       printf("8d", fp->f_type);
                putf(fp->f_flag&FREAD, 'R');
                putf(fp->f_flag&FWRITE, 'W');
                putf(fp->f_flag&FREAD, 'R');
                putf(fp->f_flag&FWRITE, 'W');
-               putf(fp->f_flag&FPIPE, 'P');
+               putf(fp->f_flag&FAPPEND, 'A');
                printf("%4d", mask(fp->f_count));
                printf("%9.1x", fp->f_inode);
                printf("%4d", mask(fp->f_count));
                printf("%9.1x", fp->f_inode);
-               printf("  %ld\n", fp->f_un.f_offset);
+               if (fp->f_type == DTYPE_SOCKET)
+                       printf("  %x\n", fp->f_socket);
+               else
+                       printf("  %ld\n", fp->f_offset);
        }
 }
 
        }
 }
 
@@ -612,7 +647,7 @@ doswap()
        int nswapmap;
        register struct proc *pp;
        int nswap, used, tused, free;
        int nswapmap;
        register struct proc *pp;
        int nswap, used, tused, free;
-       register struct map *mp;
+       register struct mapent *me;
        register struct text *xp;
 
        nproc = getw(nl[SNPROC].n_value);
        register struct text *xp;
 
        nproc = getw(nl[SNPROC].n_value);
@@ -625,8 +660,9 @@ doswap()
        read(fc, swapmap, nswapmap * sizeof (struct map));
        nswap = getw(nl[SNSWAP].n_value);
        free = 0;
        read(fc, swapmap, nswapmap * sizeof (struct map));
        nswap = getw(nl[SNSWAP].n_value);
        free = 0;
-       for (mp = swapmap; mp < &swapmap[nswapmap]; mp++)
-               free += mp->m_size;
+       for (me = (struct mapent *)(swapmap+1);
+           me < (struct mapent *)&swapmap[nswapmap]; me++)
+               free += me->m_size;
        ntext = getw(nl[SNTEXT].n_value);
        xtext = (struct text *)calloc(ntext, sizeof (struct text));
        lseek(fc, getw(nl[STEXT].n_value), 0);
        ntext = getw(nl[SNTEXT].n_value);
        xtext = (struct text *)calloc(ntext, sizeof (struct text));
        lseek(fc, getw(nl[STEXT].n_value), 0);
@@ -645,13 +681,13 @@ doswap()
                if ((pp->p_flag&SLOAD) == 0)
                        used += vusize(pp);
        }
                if ((pp->p_flag&SLOAD) == 0)
                        used += vusize(pp);
        }
-       /* a DMMAX block goes to argmap */
+       /* a DMMAX/2 block goes to argmap */
        if (totflg) {
                printf("%3d/%3d 00k swap\n", used/2/100, (used+free)/2/100);
                return;
        }
        printf("%d used (%d text), %d free, %d missing\n",
        if (totflg) {
                printf("%3d/%3d 00k swap\n", used/2/100, (used+free)/2/100);
                return;
        }
        printf("%d used (%d text), %d free, %d missing\n",
-           used/2, tused/2, free/2, (nswap - DMMAX - (used + free))/2);
+           used/2, tused/2, free/2, (nswap - DMMAX/2 - (used + free))/2);
 }
 
 up(size)
 }
 
 up(size)
@@ -685,101 +721,3 @@ struct text *xp;
                return (clrnd(xp->x_size + ctopt(xp->x_size)));
        return (xp->x_size);
 }
                return (clrnd(xp->x_size + ctopt(xp->x_size)));
        return (xp->x_size);
 }
-
-dompx()
-{
-       register int i;
-       struct chan chans[NCHANS];
-       struct schan schans[NPORTS];
-
-       lseek(fc, (long)nl[SCHANS].n_value, 0);
-       read(fc, chans, sizeof chans);
-       lseek(fc, (long)nl[SSCHANS].n_value, 0);
-       read(fc, schans, sizeof schans);
-
-       printf("CHAN  FLAGS            INDEX     LINE  GROUP     FILE      TTYP      CTLX      PGRP    OTTYP     OLINE  DATQ      CTLY\n");
-       for (i = 0; i < NCHANS; i++) {
-               printf("%3d   ", i);
-               putf(chans[i].c_flags&INUSE, 'I');
-               putf(chans[i].c_flags&SIOCTL, 'S');
-               putf(chans[i].c_flags&XGRP, 'X');
-               putf(chans[i].c_flags&YGRP, 'Y');
-               putf(chans[i].c_flags&WCLOSE, 'W');
-               putf(chans[i].c_flags&ISGRP, 'i');
-               putf(chans[i].c_flags&BLOCK, 'B');
-               putf(chans[i].c_flags&EOTMARK, 'E');
-               putf(chans[i].c_flags&SIGBLK, 's');
-               putf(chans[i].c_flags&BLKMSG, 'b');
-               putf(chans[i].c_flags&ENAMSG, 'e');
-               putf(chans[i].c_flags&WFLUSH, 'w');
-               putf(chans[i].c_flags&NMBUF, 'N');
-               putf(chans[i].c_flags&PORT, 'P');
-               putf(chans[i].c_flags&ALT, 'A');
-               putf(chans[i].c_flags&FBLOCK, 'F');
-               printf("%8x  ", chans[i].c_index);
-               printf("%3d   ", chans[i].c_line);
-               printf("%8x  ", chans[i].c_group);
-               printf("%8x  ", chans[i].c_fy);
-               printf("%8x  ", chans[i].c_ttyp);
-               printf("%8x  ", chans[i].c_ctlx);
-               printf("%6d  ", chans[i].c_pgrp);
-               printf("%8x  ", chans[i].c_ottyp);
-               printf("%3d   ", chans[i].c_oline);
-               printf("%8x  ", chans[i].cx.datq);
-               printf("%8x\n", chans[i].c_ctly);
-       }
-
-       printf("\nCHAN  FLAGS            INDEX     LINE  GROUP     FILE      TTYP      CTLX      PGRP\n");
-       for (i = 0; i < NPORTS; i++) {
-               printf("%3d  ", i);
-               putf(schans[i].c_flags&INUSE, 'I');
-               putf(schans[i].c_flags&SIOCTL, 'S');
-               putf(schans[i].c_flags&XGRP, 'X');
-               putf(schans[i].c_flags&YGRP, 'Y');
-               putf(schans[i].c_flags&WCLOSE, 'W');
-               putf(schans[i].c_flags&ISGRP, 'i');
-               putf(schans[i].c_flags&BLOCK, 'B');
-               putf(schans[i].c_flags&EOTMARK, 'E');
-               putf(schans[i].c_flags&SIGBLK, 's');
-               putf(schans[i].c_flags&BLKMSG, 'b');
-               putf(schans[i].c_flags&ENAMSG, 'e');
-               putf(schans[i].c_flags&WFLUSH, 'w');
-               putf(schans[i].c_flags&NMBUF, 'N');
-               putf(schans[i].c_flags&PORT, 'P');
-               putf(schans[i].c_flags&ALT, 'A');
-               putf(schans[i].c_flags&FBLOCK, 'F');
-               printf("%8x  ", schans[i].c_index);
-               printf("%3d   ", schans[i].c_line);
-               printf("%8x  ", schans[i].c_group);
-               printf("%8x  ", schans[i].c_fy);
-               printf("%8x  ", schans[i].c_ttyp);
-               printf("%8x  ", schans[i].c_ctlx);
-               printf("%6d\n", schans[i].c_pgrp);
-       }
-}
-
-dogroup()
-{
-       register int i, j;
-       struct group *groups[NGROUPS];
-       struct group g;
-
-       lseek(fc, (long)nl[SGROUP].n_value, 0);
-       read(fc, groups, sizeof groups);
-       printf("GROUP STATE      INDEX     ROT  *GROUP    *INODE    *FILE     ROTM  DATQ\n");
-       for (i = 0; i < NGROUPS; i++) {
-               if (groups[i] == 0)
-                       continue;
-               lseek(fc, (long) groups[i], 0);
-               read(fc, &g, sizeof g);
-               printf("%3d   ", i);
-               printf("%8x  ", g.g_state);
-               printf("%8x  ", g.g_index);
-               printf("%3d  ", g.g_rot);
-               printf("%8x  ", g.g_group);
-               printf("%8x  ", g.g_inode);
-               printf("%8x  ", g.g_file);
-               printf("%3d   ", g.g_rotmask);
-               printf("%3d\n", g.g_datq);
-       }
-}