Add new sysctl "kern.ttys" which return all the struct tty's which have
been registered with ttyregister(). register ptys with ttyregister().
This commit is contained in:
parent
1bc52887fd
commit
08add33166
@ -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>
|
||||
@ -194,6 +195,11 @@ static u_char const char_type[] = {
|
||||
#undef MAX_INPUT /* XXX wrong in <sys/syslimits.h> */
|
||||
#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.
|
||||
*/
|
||||
@ -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");
|
||||
|
@ -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*/
|
||||
|
@ -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));
|
||||
|
Loading…
x
Reference in New Issue
Block a user