diff options
Diffstat (limited to 'usr.sbin/pstat')
-rw-r--r-- | usr.sbin/pstat/pstat.8 | 115 | ||||
-rw-r--r-- | usr.sbin/pstat/pstat.c | 140 |
2 files changed, 92 insertions, 163 deletions
diff --git a/usr.sbin/pstat/pstat.8 b/usr.sbin/pstat/pstat.8 index 3dd67a6..c3f7e60 100644 --- a/usr.sbin/pstat/pstat.8 +++ b/usr.sbin/pstat/pstat.8 @@ -35,7 +35,7 @@ .\" @(#)pstat.8 8.5 (Berkeley) 5/13/94 .\" $FreeBSD$ .\" -.Dd April 1, 2007 +.Dd August 20, 2008 .Dt PSTAT 8 .Os .Sh NAME @@ -153,100 +153,63 @@ with these headings: .Bl -tag -width indent .It LINE Device name. -.It RAW -Number of characters in raw input queue. +.It INQ +Number of characters that can be stored in the input queue. .It CAN -Number of characters in canonicalized input queue. -.It OUT -Number of characters in output queue. -.It IHIWT -High water mark for input. -.It ILOWT +Number of characters in the input queue which can be read. +.It LIN +Number of characters in the input queue which cannot be read yet. +.It LOW +Low water mark for input. +.It OUTQ +Number of characters that can be stored in the output queue. +.It USE +Number of bytes in the output queue. +.It LOW Low water mark for input. -.It OHWT -High water mark for output. -.It LWT -Low water mark for output. .It COL Calculated column position of terminal. +.It SESS +Kernel address of the session structure. +.It PGID +Process group for which this is the controlling terminal. .It STATE Miscellaneous state variables encoded thus: .Pp .Bl -tag -width indent -compact -.It T -delay timeout in progress -.It W -waiting for open to complete -.It O -open -.It F -outq has been flushed during DMA +.It I +init/lock-state device nodes present .It C -carrier is on -.It c -connection open +callout device nodes present +.It O +opened +.It G +gone .It B -busy doing output -.It A -process is waiting for space in output queue -.It a -process is waiting for output to complete -.It X -open for exclusive use -.It S -output stopped (ixon flow control) -.It m -output stopped (carrier flow control) -.It o -output stopped (CTS flow control) -.It d -output stopped (DSR flow control) -.It K -input stopped +busy in +.Xr open 2 .It Y send SIGIO for input events -.It D -state for lowercase -.Ql \e -work -.It E -within a -.Ql \e.../ -for PRTRUB .It L next character is literal -.It P -retyping suspended input (PENDIN) -.It N -counting tab width, ignore FLUSHO +.It H +high watermark reached +.It X +open for exclusive use +.It S +output stopped (ixon flow control) .It l block mode input routine in use -.It s -i/o being snooped .It Z connection lost .El -.It SESS -Kernel address of the session structure. -.It PGID -Process group for which this is the controlling terminal. -.It DISC -Line discipline; -.Ql term -for -TTYDISC -or -.Ql ntty -for -NTTYDISC -or -.Ql slip -for -SLIPDISC -or -.Ql ppp -for -PPPDISC. +.Pp +The +.Ql i +and +.Ql o +characters refer to the previous character, to differentiate between +input and output. .El .It Fl M Extract values associated with the name list from the specified core. diff --git a/usr.sbin/pstat/pstat.c b/usr.sbin/pstat/pstat.c index a15292b..51828cb 100644 --- a/usr.sbin/pstat/pstat.c +++ b/usr.sbin/pstat/pstat.c @@ -214,7 +214,7 @@ static const char fhdr64[] = /* c000000000000000 ------ RWAI 123 123 c000000000000000 1000000000000000 */ static const char hdr[] = -" LINE RAW CAN OUT IHIWT ILOWT OHWT LWT COL STATE SESS PGID DISC\n"; +" LINE INQ CAN LIN LOW OUTQ USE LOW COL SESS PGID STATE\n"; static void ttymode_kvm(void) @@ -232,18 +232,18 @@ ttymode_kvm(void) while (tp != NULL) { if (kvm_read(kd, (u_long)tp, &tty, sizeof tty) != sizeof tty) errx(1, "kvm_read(): %s", kvm_geterr(kd)); - xt.xt_rawcc = tty.t_rawq.c_cc; - xt.xt_cancc = tty.t_canq.c_cc; - xt.xt_outcc = tty.t_outq.c_cc; -#define XT_COPY(field) xt.xt_##field = tty.t_##field - XT_COPY(line); - XT_COPY(state); - XT_COPY(column); - XT_COPY(ihiwat); - XT_COPY(ilowat); - XT_COPY(ohiwat); - XT_COPY(olowat); -#undef XT_COPY + xt.xt_insize = tty.t_inq.ti_nblocks * TTYINQ_DATASIZE; + xt.xt_incc = tty.t_inq.ti_linestart - tty.t_inq.ti_begin; + xt.xt_inlc = tty.t_inq.ti_end - tty.t_inq.ti_linestart; + xt.xt_inlow = tty.t_inlow; + xt.xt_outsize = tty.t_outq.to_nblocks * TTYOUTQ_DATASIZE; + xt.xt_outcc = tty.t_outq.to_end - tty.t_outq.to_begin; + xt.xt_outlow = tty.t_outlow; + xt.xt_column = tty.t_column; + /* xt.xt_pgid = ... */ + /* xt.xt_sid = ... */ + xt.xt_flags = tty.t_flags; + xt.xt_dev = NODEV; ttyprt(&xt); tp = TAILQ_NEXT(&tty, t_list); } @@ -287,95 +287,61 @@ static struct { int flag; char val; } ttystates[] = { -#ifdef TS_WOPEN - { TS_WOPEN, 'W'}, -#endif - { TS_ISOPEN, 'O'}, - { TS_CARR_ON, 'C'}, -#ifdef TS_CONNECTED - { TS_CONNECTED, 'c'}, -#endif - { TS_TIMEOUT, 'T'}, - { TS_FLUSH, 'F'}, - { TS_BUSY, 'B'}, -#ifdef TS_ASLEEP - { TS_ASLEEP, 'A'}, -#endif -#ifdef TS_SO_OLOWAT - { TS_SO_OLOWAT, 'A'}, -#endif -#ifdef TS_SO_OCOMPLETE - { TS_SO_OCOMPLETE, 'a'}, -#endif - { TS_XCLUDE, 'X'}, - { TS_TTSTOP, 'S'}, -#ifdef TS_CAR_OFLOW - { TS_CAR_OFLOW, 'm'}, -#endif -#ifdef TS_CTS_OFLOW - { TS_CTS_OFLOW, 'o'}, -#endif -#ifdef TS_DSR_OFLOW - { TS_DSR_OFLOW, 'd'}, -#endif - { TS_TBLOCK, 'K'}, - { TS_ASYNC, 'Y'}, - { TS_BKSL, 'D'}, - { TS_ERASE, 'E'}, - { TS_LNCH, 'L'}, - { TS_TYPEN, 'P'}, - { TS_CNTTB, 'N'}, -#ifdef TS_CAN_BYPASS_L_RINT - { TS_CAN_BYPASS_L_RINT, 'l'}, -#endif -#ifdef TS_SNOOP - { TS_SNOOP, 's'}, -#endif -#ifdef TS_ZOMBIE - { TS_ZOMBIE, 'Z'}, +#if 0 + { TF_NOPREFIX, 'N' }, #endif - { 0, '\0'}, + { TF_INITLOCK, 'I' }, + { TF_CALLOUT, 'C' }, + + /* Keep these together -> 'Oi' and 'Oo'. */ + { TF_OPENED, 'O' }, + { TF_OPENED_IN, 'i' }, + { TF_OPENED_OUT,'o' }, + + { TF_GONE, 'G' }, + { TF_OPENCLOSE, 'B' }, + { TF_ASYNC, 'Y' }, + { TF_LITERAL, 'L' }, + + /* Keep these together -> 'Hi' and 'Ho'. */ + { TF_HIWAT, 'H' }, + { TF_HIWAT_IN, 'i' }, + { TF_HIWAT_OUT, 'o' }, + + { TF_STOPPED, 'S' }, + { TF_EXCLUDE, 'X' }, + { TF_BYPASS, 'l' }, + { TF_ZOMBIE, 'Z' }, + + { 0, '\0' }, }; static void ttyprt(struct xtty *xt) { int i, j; - char *name, state[20]; + char *name; if (xt->xt_size != sizeof *xt) errx(1, "struct xtty size mismatch"); if (usenumflag || xt->xt_dev == 0 || (name = devname(xt->xt_dev, S_IFCHR)) == NULL) - printf(" %2d,%-2d", major(xt->xt_dev), minor(xt->xt_dev)); + printf("%5d,%4d ", major(xt->xt_dev), minor(xt->xt_dev)); else - (void)printf("%7s ", name); - (void)printf("%2ld %3ld ", xt->xt_rawcc, xt->xt_cancc); - (void)printf("%3ld %5d %5d %4d %3d %7d ", xt->xt_outcc, - xt->xt_ihiwat, xt->xt_ilowat, xt->xt_ohiwat, xt->xt_olowat, - xt->xt_column); + printf("%10s ", name); + printf("%5zu %4zu %4zu %4zu %5zu %4zu %4zu %5u %5d %5d ", + xt->xt_insize, xt->xt_incc, xt->xt_inlc, + (xt->xt_insize - xt->xt_inlow), xt->xt_outsize, + xt->xt_outcc, (xt->xt_outsize - xt->xt_outlow), + xt->xt_column, xt->xt_sid, xt->xt_pgid); for (i = j = 0; ttystates[i].flag; i++) - if (xt->xt_state & ttystates[i].flag) - state[j++] = ttystates[i].val; + if (xt->xt_flags & ttystates[i].flag) { + putchar(ttystates[i].val); + j++; + } if (j == 0) - state[j++] = '-'; - state[j] = '\0'; - (void)printf("%-6s %8d", state, xt->xt_sid); - (void)printf("%6d ", xt->xt_pgid); - switch (xt->xt_line) { - case TTYDISC: - (void)printf("term\n"); - break; - case SLIPDISC: - (void)printf("slip\n"); - break; - case PPPDISC: - (void)printf("ppp\n"); - break; - default: - (void)printf("%d\n", xt->xt_line); - break; - } + putchar('-'); + putchar('\n'); } static void |