summaryrefslogtreecommitdiffstats
path: root/sys/kern/tty.c
diff options
context:
space:
mode:
authored <ed@FreeBSD.org>2009-12-01 19:14:57 +0000
committered <ed@FreeBSD.org>2009-12-01 19:14:57 +0000
commit72b5ea2c05e0379e9c44721a12a9e1ede765941c (patch)
treede36d426aab828904e4584369a2db9411f0f1c21 /sys/kern/tty.c
parent8116463c117204a8a71a275eb1ffe266fa350954 (diff)
downloadFreeBSD-src-72b5ea2c05e0379e9c44721a12a9e1ede765941c.zip
FreeBSD-src-72b5ea2c05e0379e9c44721a12a9e1ede765941c.tar.gz
Don't allocate an input buffer for a TTY when the receiver is turned off.
When the termios CREAD flag is not set, it makes little sense to allocate an input buffer. Just set the size to 0 in this case to reduce memory footprint. Disallow CREAD to be disabled for pseudo-devices to prevent foot-shooting.
Diffstat (limited to 'sys/kern/tty.c')
-rw-r--r--sys/kern/tty.c6
1 files changed, 4 insertions, 2 deletions
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 7e6cf00..9ef095c 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -102,10 +102,11 @@ static const char *dev_console_filename;
static void
tty_watermarks(struct tty *tp)
{
- size_t bs;
+ size_t bs = 0;
/* Provide an input buffer for 0.2 seconds of data. */
- bs = MIN(tp->t_termios.c_ispeed / 5, TTYBUF_MAX);
+ if (tp->t_termios.c_cflag & CREAD)
+ bs = MIN(tp->t_termios.c_ispeed / 5, TTYBUF_MAX);
ttyinq_setsize(&tp->t_inq, tp, bs);
/* Set low watermark at 10% (when 90% is available). */
@@ -890,6 +891,7 @@ ttydevsw_defparam(struct tty *tp, struct termios *t)
t->c_ospeed = B50;
else if (t->c_ospeed > B115200)
t->c_ospeed = B115200;
+ t->c_cflag |= CREAD;
return (0);
}
OpenPOWER on IntegriCloud