Subject: bin/1130: pstat -t is broken
To: None <gnats-admin@sun-lamp.pc.cs.cmu.edu>
From: None <kstailey@gnu.ai.mit.edu>
List: netbsd-bugs
Date: 06/19/1995 22:50:10
>Number: 1130
>Category: bin
>Synopsis: pstat -t is broken
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: bin-bug-people (Utility Bug People)
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Mon Jun 19 22:50:09 1995
>Originator: Kenneth Stailey
>Organization:
>Release: Jun 8 1995
>Environment:
System: NetBSD duality.gnu.ai.mit.edu 1.0A NetBSD 1.0A (DUALITY) #36: Thu Jun 8 20:06:18 EDT 1995 mycroft@duality.gnu.ai.mit.edu:/build/src/sys/arch/hp300/compile/DUALITY hp300
>Description:
The "pty_tty" struct was moved inside the pt_softc struct.
Now pstat -t cannot find it.
>How-To-Repeat:
Run "pstat -t"
>Fix:
This has been tested on i386, sun3, and hp300
--- /usr/src/usr.sbin/pstat/pstat.c Wed May 17 11:13:50 1995
+++ pstat.c Sat Jun 17 14:13:56 1995
@@ -64,6 +64,51 @@
#include <sys/sysctl.h>
+#ifdef i386
+struct pc_softc { /* XXX not in any header files yet */
+ struct device sc_dev;
+ void *sc_ih;
+ struct tty *sc_tty;
+};
+
+#define COM_IBUFSIZE (2 * 256)
+
+struct com_softc { /* XXX not in any header files yet */
+ struct device sc_dev;
+ void *sc_ih;
+ struct tty *sc_tty;
+
+ int sc_overflows;
+ int sc_floods;
+ int sc_errors;
+
+ int sc_iobase;
+ u_char sc_hwflags;
+#define COM_HW_NOIEN 0x01
+#define COM_HW_FIFO 0x02
+#define COM_HW_CONSOLE 0x40
+ u_char sc_swflags;
+#define COM_SW_SOFTCAR 0x01
+#define COM_SW_CLOCAL 0x02
+#define COM_SW_CRTSCTS 0x04
+#define COM_SW_MDMBUF 0x08
+ u_char sc_msr, sc_mcr;
+ u_char sc_dtr;
+
+ u_char *sc_ibuf, *sc_ibufp, *sc_ibufhigh, *sc_ibufend;
+ u_char sc_ibufs[2][COM_IBUFSIZE];
+};
+#endif /* i386 */
+
+
+struct pt_softc { /* XXX not in any header files yet */
+ struct tty *pt_tty;
+ int pt_flags;
+ struct selinfo pt_selr, pt_selw;
+ u_char pt_send;
+ u_char pt_ucntl;
+};
+
#include <err.h>
#include <kvm.h>
#include <limits.h>
@@ -101,8 +146,8 @@
{ "_niswdev" },
#define SCONS NLMANDATORY + 3
{ "_constty" },
-#define SPTY NLMANDATORY + 4
- { "_pt_tty" },
+#define SPTYSC NLMANDATORY + 4
+ { "_pt_softc" },
#define SNPTY NLMANDATORY + 5
{ "_npty" },
@@ -149,6 +194,7 @@
#define SCCOM (SNPTY+4)
{ "_comcd" },
#endif
+
#ifdef amiga
#define SSER (SNPTY + 1)
{ "_ser_tty" },
@@ -164,6 +210,12 @@
{ "_mfcscd" },
#endif
+#ifdef sun3
+#define SKD (SNPTY + 1)
+ { "_kd_tty" },
+#define SZS (SNPTY + 2)
+ { "_zs_tty" },
+#endif
{ "" }
};
@@ -205,6 +257,7 @@
void ttytype __P((char *, int, int));
void ttytype_newcf __P((char *, int, int));
void ttytype_oldcf __P((char *, int, int));
+void ttytype_xxx __P((char *, int, int));
void ufs_header __P((void));
int ufs_print __P((struct vnode *));
void usage __P((void));
@@ -777,8 +830,39 @@
if (nl[SCMFCS].n_type != 0)
ttytype_newcf("mfcs", SMFCS, SCMFCS);
#endif
+#ifdef sun3
+ if (nl[SKD].n_type != 0)
+ ttytype("kd", SKD, 1); /* only one per host ever */
+ if (nl[SZS].n_type != 0)
+ ttytype("zs", SZS, 2); /* XXX should be dynamic */
+#endif
if (nl[SNPTY].n_type != 0)
- ttytype_oldcf("pty", SPTY, SNPTY);
+ ttytype_xxx("pty", SPTYSC, SNPTY);
+}
+
+void
+ttytype_xxx(name, type, number)
+ char *name;
+ int type, number;
+{
+ static int nttyp;
+ static struct tty tty;
+ struct pt_softc *pt_softc;
+ int ntty, i;
+
+ KGET(number, ntty);
+ (void)printf("%d %s %s\n", ntty, name, (ntty == 1) ? "line" : "lines");
+
+ if ((pt_softc = malloc(sizeof(struct pt_softc) * ntty)) == NULL)
+ return;
+
+ KGET1(type, pt_softc, sizeof(struct pt_softc) * ntty, "pty softc");
+ for (i = 0; i < ntty; i++) {
+ if (!pt_softc[i].pt_tty)
+ continue;
+ KGET2(pt_softc[i].pt_tty, &tty, sizeof(tty), "pty tty");
+ ttyprt(&tty, i);
+ }
}
void
@@ -798,6 +882,7 @@
int type, config;
{
struct cfdriver cf;
+ struct tty tty;
void **cd;
int i;
@@ -806,11 +891,47 @@
if (!cd)
return;
KGET2(cf.cd_devs, cd, cf.cd_ndevs * sizeof(void *), "cfdevicep");
+
for (i = cf.cd_ndevs - 1; i >= 0; --i)
if (cd[i])
break;
+ i++;
+ (void)printf("%d %s %s\n", i, name, i ? "line" : "lines");
+
+ (void)printf(hdr);
+
+ for (i = 0; i < cf.cd_ndevs; ++i) {
+ if (!cd[i])
+ break;
+ switch (type) {
+#ifdef SPC
+ case SPC:
+ {
+ struct pc_softc pc_softc;
+
+ KGET2(cd[i], &pc_softc, sizeof(pc_softc),
+ "pc softc");
+ KGET2(pc_softc.sc_tty, &tty,
+ sizeof(struct tty), "pc tty struct");
+ }
+ break;
+#endif /* SPC */
+#ifdef SCOM
+ case SCOM:
+ {
+ struct com_softc com_softc;
+
+ KGET2(cd[i], &com_softc, sizeof(com_softc),
+ "pc softc");
+ KGET2(com_softc.sc_tty, &tty,
+ sizeof(struct tty), "com tty struct");
+ }
+ break;
+#endif /* SCOM */
+ }
+ ttyprt(&tty, i);
+ }
free(cd);
- ttytype(name, type, i + 1);
}
void
@@ -832,8 +953,10 @@
KGET1(type, ttyp, nttyp * sizeof(*ttyp), "tty pointers");
(void)printf(hdr);
for (i = 0; i < ntty; i++) {
- if (ttyp[i] == NULL)
+ if (ttyp[i] == NULL) {
+ fprintf(stderr, "skipped %d\n", i);
continue;
+ }
KGET2(ttyp[i], &tty, sizeof(struct tty), "tty struct");
ttyprt(&tty, i);
}
>Audit-Trail:
>Unformatted: