|
|
1.1 ! root 1: /* ! 2: * Print system stuff ! 3: */ ! 4: ! 5: #define mask(x) (x&0377) ! 6: #define clear(x) ((int)x&0x7fffffff) ! 7: ! 8: #include <sys/param.h> ! 9: #include <sys/dir.h> ! 10: #include <sys/file.h> ! 11: #include <sys/user.h> ! 12: #include <sys/proc.h> ! 13: #include <sys/text.h> ! 14: #include <sys/inode.h> ! 15: #include <sys/map.h> ! 16: #include <sys/tty.h> ! 17: #include <sys/conf.h> ! 18: #include <sys/vm.h> ! 19: ! 20: char *fcore = "/dev/kmem"; ! 21: char *fnlist = "/vmunix"; ! 22: int fc; ! 23: ! 24: struct setup { ! 25: char name[8]; ! 26: int type; ! 27: unsigned value; ! 28: } setup[] = { ! 29: #define SINODE 0 ! 30: "_inode", 0, 0, ! 31: #define STEXT 1 ! 32: "_text", 0, 0, ! 33: #define SPROC 2 ! 34: "_proc", 0, 0, ! 35: #define SDZ 3 ! 36: "_dz_tty", 0, 0, ! 37: #define SNDZ 4 ! 38: "_dz_cnt", 0, 0, ! 39: #define SKL 5 ! 40: "_cons", 0, 0, ! 41: #define SFIL 6 ! 42: "_file", 0, 0, ! 43: #define SMPXC 7 ! 44: "_mpx_cha", 0, 0, ! 45: #define SMPXM 8 ! 46: "_mpx_mac", 0, 0, ! 47: #define SMPXB1 9 ! 48: "_mptbc", 0, 0, ! 49: #define SMPXB2 10 ! 50: "_mptbuf", 0, 0, ! 51: #define SMPSM 11 ! 52: "_mpsm", 0, 0, ! 53: 0, ! 54: }; ! 55: ! 56: int inof; ! 57: int txtf; ! 58: int prcf; ! 59: int ttyf; ! 60: int mpxf; ! 61: int usrf; ! 62: long ubase; ! 63: int filf; ! 64: char partab[1]; ! 65: struct cdevsw cdevsw[1]; ! 66: struct bdevsw bdevsw[1]; ! 67: int allflg; ! 68: int kflg; ! 69: ! 70: main(argc, argv) ! 71: char **argv; ! 72: { ! 73: register char *argp; ! 74: ! 75: argc--, argv++; ! 76: while (argc > 0 && **argv == '-') { ! 77: argp = *argv++; ! 78: argp++; ! 79: argc--; ! 80: while (*argp++) ! 81: switch (argp[-1]) { ! 82: ! 83: case 'a': ! 84: allflg++; ! 85: break; ! 86: ! 87: case 'i': ! 88: inof++; ! 89: break; ! 90: ! 91: case 'k': ! 92: kflg++; ! 93: fcore = "/vmcore"; ! 94: break; ! 95: ! 96: case 'x': ! 97: txtf++; ! 98: break; ! 99: case 'p': ! 100: prcf++; ! 101: break; ! 102: ! 103: case 't': ! 104: ttyf++; ! 105: break; ! 106: ! 107: case 'm': ! 108: mpxf++; ! 109: break; ! 110: ! 111: case 'u': ! 112: if (argc == 0) ! 113: break; ! 114: argc--; ! 115: usrf++; ! 116: sscanf( *argv++, "%x", &ubase); ! 117: break; ! 118: ! 119: case 'f': ! 120: filf++; ! 121: break; ! 122: } ! 123: } ! 124: if (argc>0) ! 125: fcore = argv[0]; ! 126: if ((fc = open(fcore, 0)) < 0) { ! 127: printf("Can't find %s\n", fcore); ! 128: exit(1); ! 129: } ! 130: if (argc>1) ! 131: fnlist = argv[1]; ! 132: nlist(fnlist, setup); ! 133: if (kflg) { ! 134: register struct setup *sp; ! 135: for (sp=setup; sp->value; sp++) ! 136: sp->value &= 0x7fffffff; ! 137: } ! 138: if (setup[SINODE].type == -1) { ! 139: printf("no namelist\n"); ! 140: exit(1); ! 141: } ! 142: if (inof) ! 143: doinode(); ! 144: if (txtf) ! 145: dotext(); ! 146: if (ttyf) ! 147: dotty(); ! 148: if (prcf) ! 149: doproc(); ! 150: if (usrf) ! 151: dousr(); ! 152: if (filf) ! 153: dofil(); ! 154: /* ! 155: if(mpxf) ! 156: dompx(); ! 157: */ ! 158: } ! 159: ! 160: doinode() ! 161: { ! 162: register struct inode *ip; ! 163: struct inode xinode[NINODE]; ! 164: register int nin, loc; ! 165: ! 166: nin = 0; ! 167: lseek(fc, (long)setup[SINODE].value, 0); ! 168: read(fc, xinode, sizeof(xinode)); ! 169: for (ip = xinode; ip < &xinode[NINODE]; ip++) ! 170: if (ip->i_count) ! 171: nin++; ! 172: printf("%d active xinodes\n", nin); ! 173: printf(" LOC FLAGS CNT DEVICE INO MODE NLK UID SIZE/DEV\n"); ! 174: loc = setup[SINODE].value; ! 175: for (ip = xinode; ip < &xinode[NINODE]; ip++, loc += sizeof(xinode[0])) { ! 176: if (ip->i_count == 0) ! 177: continue; ! 178: printf("%8.1x ", loc); ! 179: putf(ip->i_flag&ILOCK, 'L'); ! 180: putf(ip->i_flag&IUPD, 'U'); ! 181: putf(ip->i_flag&IACC, 'A'); ! 182: putf(ip->i_flag&IMOUNT, 'M'); ! 183: putf(ip->i_flag&IWANT, 'W'); ! 184: putf(ip->i_flag&ITEXT, 'T'); ! 185: printf("%4d", ip->i_count&0377); ! 186: printf("%4d,%3d", major(ip->i_dev), minor(ip->i_dev)); ! 187: printf("%5l", ip->i_number); ! 188: printf("%6x", ip->i_mode & 0xffff); ! 189: printf("%4d", ip->i_nlink); ! 190: printf("%4d", ip->i_uid); ! 191: if ((ip->i_mode&IFMT)==IFBLK || (ip->i_mode&IFMT)==IFCHR) ! 192: printf("%6d,%3d", major(ip->i_un.i_rdev), minor(ip->i_un.i_rdev)); ! 193: else ! 194: printf("%10ld", ip->i_size); ! 195: printf("\n"); ! 196: } ! 197: } ! 198: ! 199: putf(v, n) ! 200: { ! 201: if (v) ! 202: printf("%c", n); ! 203: else ! 204: printf(" "); ! 205: } ! 206: ! 207: dotext() ! 208: { ! 209: register struct text *xp; ! 210: struct text xtext[NTEXT]; ! 211: register loc; ! 212: int ntx; ! 213: ! 214: ntx = 0; ! 215: lseek(fc, (long)setup[STEXT].value, 0); ! 216: read(fc, xtext, sizeof(xtext)); ! 217: for (xp = xtext; xp < &xtext[NTEXT]; xp++) ! 218: if (xp->x_iptr!=NULL) ! 219: ntx++; ! 220: printf("%d text segments\n", ntx); ! 221: printf(" LOC FLAGS DADDR CADDR RSS SIZE IPTR CNT CCNT\n"); ! 222: loc = setup[STEXT].value; ! 223: for (xp = xtext; xp < &xtext[NTEXT]; xp++, loc+=sizeof(xtext[0])) { ! 224: if (xp->x_iptr == NULL) ! 225: continue; ! 226: printf("%8.1x", loc); ! 227: printf(" "); ! 228: putf(xp->x_flag&XPAGI, 'P'); ! 229: putf(xp->x_flag&XTRC, 'T'); ! 230: putf(xp->x_flag&XWRIT, 'W'); ! 231: putf(xp->x_flag&XLOAD, 'L'); ! 232: putf(xp->x_flag&XLOCK, 'K'); ! 233: putf(xp->x_flag&XWANT, 'w'); ! 234: printf("%5x", xp->x_daddr); ! 235: printf("%11x", xp->x_caddr); ! 236: printf("%5d", xp->x_rssize); ! 237: printf("%5d", xp->x_size); ! 238: printf("%10.1x", xp->x_iptr); ! 239: printf("%5d", xp->x_count&0377); ! 240: printf("%4d", xp->x_ccount); ! 241: printf("\n"); ! 242: } ! 243: } ! 244: ! 245: doproc() ! 246: { ! 247: struct proc xproc[NPROC]; ! 248: register struct proc *pp; ! 249: register loc, np; ! 250: ! 251: lseek(fc, (long)setup[SPROC].value, 0); ! 252: read(fc, xproc, sizeof(xproc)); ! 253: np = 0; ! 254: for (pp=xproc; pp < &xproc[NPROC]; pp++) ! 255: if (pp->p_stat) ! 256: np++; ! 257: printf("%d processes\n", np); ! 258: printf(" LOC S F POIP PRI SIG UID SLP TIM CPU NI PGRP PID PPID ADDR RSS SRSS SIZE WCHAN LINK TEXTP CLKT\n"); ! 259: for (loc=setup[SPROC].value,pp=xproc; pp<&xproc[NPROC]; pp++,loc+=sizeof(xproc[0])) { ! 260: if (pp->p_stat==0 && allflg==0) ! 261: continue; ! 262: printf("%8x", loc); ! 263: printf(" %2d", pp->p_stat); ! 264: printf(" %4x", pp->p_flag & 0xffff); ! 265: printf(" %4d", pp->p_poip); ! 266: printf(" %3d", pp->p_pri); ! 267: printf(" %4x", pp->p_sig); ! 268: printf(" %4d", pp->p_uid); ! 269: printf(" %3d", pp->p_slptime); ! 270: printf(" %3d", pp->p_time); ! 271: printf(" %4d", pp->p_cpu&0377); ! 272: printf(" %3d", pp->p_nice); ! 273: printf(" %6d", pp->p_pgrp); ! 274: printf(" %6d", pp->p_pid); ! 275: printf(" %6d", pp->p_ppid); ! 276: printf(" %8x", pp->p_addr[0]); ! 277: printf(" %4x", pp->p_rssize); ! 278: printf(" %4x", pp->p_swrss); ! 279: printf(" %5x", pp->p_dsize+pp->p_ssize); ! 280: printf(" %7x", clear(pp->p_wchan)); ! 281: printf(" %7x", clear(pp->p_link)); ! 282: printf(" %7x", clear(pp->p_textp)); ! 283: printf(" %u", pp->p_clktim); ! 284: printf("\n"); ! 285: } ! 286: } ! 287: ! 288: dotty() ! 289: { ! 290: struct tty dz_tty[32]; ! 291: int ndz; ! 292: register struct tty *tp; ! 293: register char *mesg; ! 294: ! 295: printf("1 cons\n"); ! 296: lseek(fc, (long)setup[SKL].value, 0); ! 297: read(fc, dz_tty, sizeof(dz_tty[0])); ! 298: mesg = " RAW CAN OUT MODE ADDR DEL COL STATE PGRP\n"; ! 299: printf(mesg); ! 300: ttyprt(&dz_tty[0]); ! 301: if (setup[SNDZ].type == -1) ! 302: return; ! 303: lseek(fc, (long)setup[SNDZ].value, 0); ! 304: read(fc, &ndz, sizeof(ndz)); ! 305: printf("%d dz lines\n", ndz); ! 306: lseek(fc, (long)setup[SDZ].value, 0); ! 307: read(fc, dz_tty, sizeof(dz_tty)); ! 308: for (tp = dz_tty; tp < &dz_tty[ndz]; tp++) ! 309: ttyprt(tp); ! 310: } ! 311: ! 312: ttyprt(atp) ! 313: struct tty *atp; ! 314: { ! 315: register struct tty *tp; ! 316: ! 317: tp = atp; ! 318: printf("%4d", tp->t_rawq.c_cc); ! 319: printf("%4d", tp->t_canq.c_cc); ! 320: printf("%4d", tp->t_outq.c_cc); ! 321: printf("%8.1o", tp->t_flags); ! 322: printf(" %8.1x", tp->t_addr); ! 323: printf("%3d", tp->t_delct); ! 324: printf("%4d ", tp->t_col); ! 325: putf(tp->t_state&TIMEOUT, 'T'); ! 326: putf(tp->t_state&WOPEN, 'W'); ! 327: putf(tp->t_state&ISOPEN, 'O'); ! 328: putf(tp->t_state&CARR_ON, 'C'); ! 329: putf(tp->t_state&BUSY, 'B'); ! 330: putf(tp->t_state&ASLEEP, 'A'); ! 331: putf(tp->t_state&XCLUDE, 'X'); ! 332: /* ! 333: putf(tp->t_state&HUPCLS, 'H'); ! 334: */ ! 335: printf("%6d", tp->t_pgrp); ! 336: printf("\n"); ! 337: } ! 338: ! 339: dousr() ! 340: { ! 341: struct user U; ! 342: register i, j, *ip; ! 343: ! 344: /* This wins only if PAGSIZ > sizeof (struct user) */ ! 345: lseek(fc, ubase * NBPG, 0); ! 346: read(fc, &U, sizeof(U)); ! 347: /* ! 348: printf("rsav %.1o %.1o\n", U.u_rsav[0], U.u_rsav[1]); ! 349: */ ! 350: printf("segflg, error %d, %d\n", U.u_segflg, U.u_error); ! 351: printf("uids %d,%d,%d,%d\n", U.u_uid,U.u_gid,U.u_ruid,U.u_rgid); ! 352: printf("procp %.1x\n", U.u_procp); ! 353: printf("base, count, offset %.1x %.1x %ld\n", U.u_base, ! 354: U.u_count, U.u_offset); ! 355: printf("cdir %.1x\n", U.u_cdir); ! 356: printf("dbuf %.14s\n", U.u_dbuf); ! 357: printf("dirp %.1x\n", U.u_dirp); ! 358: printf("dent %d %.14s\n", U.u_dent.d_ino, U.u_dent.d_name); ! 359: printf("pdir %.1o\n", U.u_pdir); ! 360: /* ! 361: printf("dseg"); ! 362: for (i=0; i<8; i++) ! 363: printf("%8.1o", U.u_uisa[i]); ! 364: printf("\n "); ! 365: for (i=0; i<8; i++) ! 366: printf("%8.1o", U.u_uisd[i]); ! 367: if (U.u_sep) { ! 368: printf("\ntseg"); ! 369: for (i=8; i<16; i++) ! 370: printf("%8.1o", U.u_uisa[i]); ! 371: printf("\n "); ! 372: for (i=8; i<16; i++) ! 373: printf("%8.1o", U.u_uisd[i]); ! 374: } ! 375: */ ! 376: printf("\nfile"); ! 377: for (i=0; i<10; i++) ! 378: printf("%9.1x", U.u_ofile[i]); ! 379: printf("\n "); ! 380: for (i=10; i<NOFILE; i++) ! 381: printf("%9.1x", U.u_ofile[i]); ! 382: printf("\nargs"); ! 383: for (i=0; i<5; i++) ! 384: printf(" %.1x", U.u_arg[i]); ! 385: printf("\nsizes %.1x %.1x %.1x\n", U.u_tsize, U.u_dsize, U.u_ssize); ! 386: printf("sep %d\n", U.u_sep); ! 387: printf("qsav %.1x %.1x\n", U.u_qsav[0], U.u_qsav[1]); ! 388: printf("ssav %.1x %.1x\n", U.u_ssav[0], U.u_ssav[1]); ! 389: printf("sigs"); ! 390: for (i=0; i<NSIG; i++) ! 391: printf(" %.1x", U.u_signal[i]); ! 392: printf("\ntimes %ld %ld\n", U.u_utime/60, U.u_stime/60); ! 393: printf("ctimes %ld %ld\n", U.u_cutime/60, U.u_cstime/60); ! 394: printf("ar0 %.1x\n", U.u_ar0); ! 395: /* ! 396: printf("prof"); ! 397: for (i=0; i<4; i++) ! 398: printf(" %.1o", U.u_prof[i]); ! 399: */ ! 400: printf("\nintflg %d\n", U.u_intflg); ! 401: printf("ttyp %.1x\n", U.u_ttyp); ! 402: printf("ttydev %d,%d\n", major(U.u_ttyd), minor(U.u_ttyd)); ! 403: printf("comm %.14s\n", U.u_comm); ! 404: /* ! 405: i = U.u_stack - &U; ! 406: while (U[++i] == 0); ! 407: i &= ~07; ! 408: while (i < 512) { ! 409: printf("%x ", 0140000+2*i); ! 410: for (j=0; j<8; j++) ! 411: printf("%9x", U[i++]); ! 412: printf("\n"); ! 413: } ! 414: */ ! 415: } ! 416: ! 417: oatoi(s) ! 418: char *s; ! 419: { ! 420: register v; ! 421: ! 422: v = 0; ! 423: while (*s) ! 424: v = (v<<3) + *s++ - '0'; ! 425: return(v); ! 426: } ! 427: ! 428: dofil() ! 429: { ! 430: struct file xfile[NFILE]; ! 431: register struct file *fp; ! 432: register nf; ! 433: int loc; ! 434: ! 435: nf = 0; ! 436: lseek(fc, (long)setup[SFIL].value, 0); ! 437: read(fc, xfile, sizeof(xfile)); ! 438: for (fp=xfile; fp < &xfile[NFILE]; fp++) ! 439: if (fp->f_count) ! 440: nf++; ! 441: printf("%d open files\n", nf); ! 442: printf(" LOC FLG CNT INO OFFS\n"); ! 443: for (fp=xfile,loc=setup[SFIL].value; fp < &xfile[NFILE]; fp++,loc+=sizeof(xfile[0])) { ! 444: if (fp->f_count==0) ! 445: continue; ! 446: printf("%8x ", loc); ! 447: putf(fp->f_flag&FREAD, 'R'); ! 448: putf(fp->f_flag&FWRITE, 'W'); ! 449: putf(fp->f_flag&FPIPE, 'P'); ! 450: printf("%4d", mask(fp->f_count)); ! 451: printf("%9.1x", fp->f_inode); ! 452: printf(" %ld\n", fp->f_un.f_offset); ! 453: } ! 454: } ! 455: ! 456: /********* ! 457: #include <sys/mpx.h> ! 458: dompx() ! 459: { ! 460: struct chan chan[C]; ! 461: struct mach mach[M]; ! 462: struct line line[M-1]; ! 463: int mptbc; ! 464: char mptbuf[TBSIZ]; ! 465: register struct chan *cp; ! 466: register struct mach *mp; ! 467: register struct line *lp; ! 468: int loc, nc; ! 469: ! 470: lseek(fc, (long)setup[SMPXC].value, 0); ! 471: read(fc, chan, sizeof(chan)); ! 472: lseek(fc, (long)setup[SMPXM].value, 0); ! 473: read(fc, mach, sizeof(mach)); ! 474: lseek(fc, (long)setup[SMPXB1].value, 0); ! 475: read(fc, &mptbc, sizeof(mptbc)); ! 476: lseek(fc, (long)setup[SMPXB2].value, 0); ! 477: read(fc, mptbuf, sizeof(mptbuf)); ! 478: lseek(fc, (long)setup[SMPSM].value, 0); ! 479: read(fc, line, sizeof(line)); ! 480: nc = 0; ! 481: for(cp=chan; cp < &chan[C]; cp++) ! 482: if(cp->cflag&ALLOC) ! 483: nc++; ! 484: printf("%d mpx channels\n", nc); ! 485: printf(" LOC FLG M C DEST\n"); ! 486: for(cp=chan,loc=setup[SMPXC].value; cp < &chan[C]; cp++,loc=+sizeof(chan[0])) { ! 487: if((cp->cflag&ALLOC) == 0) ! 488: continue; ! 489: printf("%7.1o ", loc); ! 490: putf(cp->cflag&BLOCK, 'B'); ! 491: putf(cp->cflag&WWAIT, 'B'); ! 492: putf(cp->cflag&CRUN, 'R'); ! 493: putf(cp->cflag&RWAIT, 'W'); ! 494: putf(cp->cflag&ALLOC, 'A'); ! 495: putf(cp->cflag&DIS, 'D'); ! 496: putf(cp->cflag&DLY, 'D'); ! 497: printf(" %1d %3d ", mask(cp->m), mask(cp->c)); ! 498: printf("%7.1o ", cp->dest); ! 499: printf("\n"); ! 500: } ! 501: ! 502: printf("%d mpx machines\n", M); ! 503: printf(" LOC FLG RCH RCN XCH XCN\n"); ! 504: for(mp=mach,loc=setup[SMPXM].value; mp < &mach[M]; mp++,loc=+sizeof(mach[0])) { ! 505: printf("%7.1o ", loc); ! 506: putf(mp->mflag&RNEXT, 'N'); ! 507: putf(mp->mflag&MRUN, 'R'); ! 508: putf(mp->mflag&XNEXT, 'N'); ! 509: printf(" %3d", mask(mp->rchan)); ! 510: printf(" %3d", mask(mp->rcount)); ! 511: printf(" %3d", mask(mp->xchan)); ! 512: printf(" %3d", mask(mp->xcount)); ! 513: for(nc=0; nc<128; nc++) { ! 514: cp = mp->chanp[nc]; ! 515: if(cp == 0) ! 516: continue; ! 517: printf(" %d-%o", nc, cp); ! 518: } ! 519: printf("\n"); ! 520: } ! 521: printf("%d mpx lines\n", M-1); ! 522: printf(" LOC RSQ XSQ AKF XMF STE TIM SUM\n"); ! 523: for(lp=line,loc=setup[SMPSM].value; lp < &line[M-1]; lp++, loc =+ sizeof(line[0])) { ! 524: printf("%7.1o ", loc); ! 525: printf("%3o ", lp->rseq); ! 526: printf("%3o ", lp->xseq); ! 527: printf("%3o ", lp->ackf); ! 528: printf("%3o ", lp->xflag); ! 529: printf("%3d ", lp->state); ! 530: printf("%3d ", lp->time); ! 531: printf("%7o\n", lp->sum); ! 532: } ! 533: printf("last characters recieved\n"); ! 534: nc = -1; ! 535: loc = mptbc; ! 536: for(;;) { ! 537: if(nc != mptbuf[loc]) { ! 538: if(nc >= 0) ! 539: printf(")\n"); ! 540: nc = mptbuf[loc]; ! 541: printf("%d(", nc); ! 542: } else ! 543: printf(","); ! 544: loc++; ! 545: if(loc >= TBSIZ) ! 546: loc = 0; ! 547: if(loc == mptbc) ! 548: break; ! 549: printf("%o", mask(mptbuf[loc])); ! 550: loc++; ! 551: if(loc >= TBSIZ) ! 552: loc = 0; ! 553: if(loc == mptbc) ! 554: break; ! 555: } ! 556: printf(")\n"); ! 557: } ! 558: *********/
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.