Introduce struct xtty, used when exporting tty information to userland.
Make kern.ttys export a struct xtty rather than struct tty. Since struct tty is no longer exposed to userland, remove the dev_t / udev_t hack. Sponsored by: DARPA, NAI Labs
This commit is contained in:
parent
776c387ac1
commit
1a149fcd67
@ -2573,13 +2573,38 @@ ttyregister(struct tty *tp)
|
||||
static int
|
||||
sysctl_kern_ttys(SYSCTL_HANDLER_ARGS)
|
||||
{
|
||||
struct tty *tp;
|
||||
struct xtty xt;
|
||||
int error;
|
||||
struct tty *tp, t;
|
||||
|
||||
SLIST_FOREACH(tp, &tty_list, t_list) {
|
||||
t = *tp;
|
||||
if (t.t_dev)
|
||||
t.ttyu.t_udev = dev2udev(t.t_dev);
|
||||
error = SYSCTL_OUT(req, (caddr_t)&t, sizeof(t));
|
||||
bzero(&xt, sizeof xt);
|
||||
xt.xt_size = sizeof xt;
|
||||
#define XT_COPY(field) xt.xt_##field = tp->t_##field
|
||||
xt.xt_rawcc = tp->t_rawq.c_cc;
|
||||
xt.xt_cancc = tp->t_canq.c_cc;
|
||||
xt.xt_outcc = tp->t_outq.c_cc;
|
||||
XT_COPY(line);
|
||||
xt.xt_dev = dev2udev(tp->t_dev);
|
||||
XT_COPY(state);
|
||||
XT_COPY(flags);
|
||||
XT_COPY(timeout);
|
||||
xt.xt_pgid = tp->t_pgrp->pg_id;
|
||||
xt.xt_sid = tp->t_session->s_sid;
|
||||
XT_COPY(termios);
|
||||
XT_COPY(winsize);
|
||||
XT_COPY(column);
|
||||
XT_COPY(rocount);
|
||||
XT_COPY(rocol);
|
||||
XT_COPY(ififosize);
|
||||
XT_COPY(ihiwat);
|
||||
XT_COPY(ilowat);
|
||||
XT_COPY(ispeedwat);
|
||||
XT_COPY(ohiwat);
|
||||
XT_COPY(olowat);
|
||||
XT_COPY(ospeedwat);
|
||||
#undef XT_COPY
|
||||
error = SYSCTL_OUT(req, &xt, sizeof xt);
|
||||
if (error)
|
||||
return (error);
|
||||
}
|
||||
|
@ -74,11 +74,7 @@ struct tty {
|
||||
struct clist t_outq; /* Device output queue. */
|
||||
long t_outcc; /* Output queue statistics. */
|
||||
int t_line; /* Interface to device drivers. */
|
||||
union {
|
||||
dev_t t_kdev; /* Device. */
|
||||
udev_t t_udev; /* Userland (sysctl) instance. */
|
||||
void *t_devp; /* Keep user/kernel size in sync. */
|
||||
} ttyu;
|
||||
dev_t t_dev; /* Device. */
|
||||
int t_state; /* Device and driver (TS*) state. */
|
||||
int t_flags; /* Tty flags. */
|
||||
int t_timeout; /* Timeout for ttywait() */
|
||||
@ -111,7 +107,6 @@ struct tty {
|
||||
|
||||
#define t_cc t_termios.c_cc
|
||||
#define t_cflag t_termios.c_cflag
|
||||
#define t_dev ttyu.t_kdev
|
||||
#define t_iflag t_termios.c_iflag
|
||||
#define t_ispeed t_termios.c_ispeed
|
||||
#define t_lflag t_termios.c_lflag
|
||||
@ -123,6 +118,34 @@ struct tty {
|
||||
#define TTIPRI (PSOCK + 1) /* Sleep priority for tty reads. */
|
||||
#define TTOPRI (PSOCK + 2) /* Sleep priority for tty writes. */
|
||||
|
||||
/*
|
||||
* Userland version of struct tty, for sysctl
|
||||
*/
|
||||
struct xtty {
|
||||
size_t xt_size; /* Structure size */
|
||||
long xt_rawcc; /* Raw input queue statistics. */
|
||||
long xt_cancc; /* Canonical queue statistics. */
|
||||
long xt_outcc; /* Output queue statistics. */
|
||||
int xt_line; /* Interface to device drivers. */
|
||||
udev_t xt_dev; /* Userland (sysctl) instance. */
|
||||
int xt_state; /* Device and driver (TS*) state. */
|
||||
int xt_flags; /* Tty flags. */
|
||||
int xt_timeout; /* Timeout for ttywait() */
|
||||
pid_t xt_pgid; /* Process group ID */
|
||||
pid_t xt_sid; /* Session ID */
|
||||
struct termios xt_termios; /* Termios state. */
|
||||
struct winsize xt_winsize; /* Window size. */
|
||||
int xt_column; /* Tty output column. */
|
||||
int xt_rocount, xt_rocol; /* Tty. */
|
||||
int xt_ififosize; /* Total size of upstream fifos. */
|
||||
int xt_ihiwat; /* High water mark for input. */
|
||||
int xt_ilowat; /* Low water mark for input. */
|
||||
speed_t xt_ispeedwat; /* t_ispeed override for watermarks. */
|
||||
int xt_ohiwat; /* High water mark for output. */
|
||||
int xt_olowat; /* Low water mark for output. */
|
||||
speed_t xt_ospeedwat; /* t_ospeed override for watermarks. */
|
||||
};
|
||||
|
||||
/*
|
||||
* User data unfortunately has to be copied through buffers on the way to
|
||||
* and from clists. The buffers are on the stack so their sizes must be
|
||||
|
Loading…
Reference in New Issue
Block a user