summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sys/kern/tty.c34
-rw-r--r--sys/kern/tty_pty.c3
-rw-r--r--sys/sys/tty.h4
3 files changed, 38 insertions, 3 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index e9de97b..46c15c6 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.c 8.8 (Berkeley) 1/21/94
- * $Id: tty.c,v 1.118 1999/05/08 06:39:42 phk Exp $
+ * $Id: tty.c,v 1.119 1999/05/22 20:10:31 dt Exp $
*/
/*-
@@ -94,6 +94,7 @@
#if NSNP > 0
#include <sys/snoop.h>
#endif
+#include <sys/sysctl.h>
#include <vm/vm.h>
#include <sys/lock.h>
@@ -195,6 +196,11 @@ static u_char const char_type[] = {
#define MAX_INPUT TTYHOG /* XXX limit is usually larger for !ICANON */
/*
+ * list of struct tty where pstat(8) can pick it up with sysctl
+ */
+static SLIST_HEAD(, tty) tty_list;
+
+/*
* Initial open of tty, or (re)entry to standard tty line discipline.
*/
int
@@ -2433,3 +2439,29 @@ ttyfree(tp)
free(tp, M_TTYS);
}
#endif /* 0 */
+
+void
+ttyregister(tp)
+ struct tty *tp;
+{
+ SLIST_INSERT_HEAD(&tty_list, tp, t_list);
+}
+
+static int
+sysctl_kern_ttys SYSCTL_HANDLER_ARGS
+{
+ int error;
+ struct tty *tp, t;
+ SLIST_FOREACH(tp, &tty_list, t_list) {
+ t = *tp;
+ if (t.t_dev)
+ t.t_dev = (dev_t)dev2udev(t.t_dev);
+ error = SYSCTL_OUT(req, (caddr_t)&t, sizeof(t));
+ if (error)
+ return (error);
+ }
+ return (0);
+}
+
+SYSCTL_PROC(_kern, OID_AUTO, ttys, CTLTYPE_OPAQUE|CTLFLAG_RD,
+ 0, 0, sysctl_kern_ttys, "S,tty", "All struct ttys");
diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c
index ae0e9fe..160693f 100644
--- a/sys/kern/tty_pty.c
+++ b/sys/kern/tty_pty.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_pty.c 8.4 (Berkeley) 2/20/95
- * $Id: tty_pty.c,v 1.61 1999/05/31 11:27:38 phk Exp $
+ * $Id: tty_pty.c,v 1.62 1999/08/08 19:28:50 phk Exp $
*/
/*
@@ -167,6 +167,7 @@ ptyinit(n)
bzero(pt, sizeof(*pt));
devs->si_drv1 = devc->si_drv1 = pt;
devs->si_tty_tty = devc->si_tty_tty = &pt->pt_tty;
+ ttyregister(&pt->pt_tty);
}
/*ARGSUSED*/
diff --git a/sys/sys/tty.h b/sys/sys/tty.h
index 1e1a094..cedfa63 100644
--- a/sys/sys/tty.h
+++ b/sys/sys/tty.h
@@ -36,7 +36,7 @@
* SUCH DAMAGE.
*
* @(#)tty.h 8.6 (Berkeley) 1/21/94
- * $Id: tty.h,v 1.43 1998/11/11 10:04:13 truckman Exp $
+ * $Id: tty.h,v 1.44 1998/11/11 10:56:07 truckman Exp $
*/
#ifndef _SYS_TTY_H_
@@ -101,6 +101,7 @@ struct tty {
int t_olowat; /* Low water mark for output. */
speed_t t_ospeedwat; /* t_ospeed override for watermarks. */
int t_gen; /* Generation number. */
+ SLIST_ENTRY(tty) t_list; /* Global chain of ttys for pstat(8) */
};
#define t_cc t_termios.c_cc
@@ -263,6 +264,7 @@ int ttyinput __P((int c, struct tty *tp));
int ttylclose __P((struct tty *tp, int flag));
int ttymodem __P((struct tty *tp, int flag));
int ttyopen __P((dev_t device, struct tty *tp));
+void ttyregister __P((struct tty *tp));
int ttysleep __P((struct tty *tp,
void *chan, int pri, char *wmesg, int timeout));
int ttywait __P((struct tty *tp));
OpenPOWER on IntegriCloud