summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordes <des@FreeBSD.org>2002-05-28 05:40:53 +0000
committerdes <des@FreeBSD.org>2002-05-28 05:40:53 +0000
commite332aae78578e2b6358a0d898ab9e63c9e2205e6 (patch)
tree342ff2aa63e11e3bd875304e163f9a80fe63699e
parentc749049ff87b6c015ef289830c6eb0cab143b2a4 (diff)
downloadFreeBSD-src-e332aae78578e2b6358a0d898ab9e63c9e2205e6.zip
FreeBSD-src-e332aae78578e2b6358a0d898ab9e63c9e2205e6.tar.gz
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
-rw-r--r--sys/kern/tty.c35
-rw-r--r--sys/sys/tty.h35
2 files changed, 59 insertions, 11 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 8d8d375..713766a 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -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);
}
diff --git a/sys/sys/tty.h b/sys/sys/tty.h
index 7840538..ad467a0 100644
--- a/sys/sys/tty.h
+++ b/sys/sys/tty.h
@@ -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
@@ -124,6 +119,34 @@ struct tty {
#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
* fairly small.
OpenPOWER on IntegriCloud