aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEd Schouten <ed@FreeBSD.org>2009-10-18 19:48:53 +0000
committerEd Schouten <ed@FreeBSD.org>2009-10-18 19:48:53 +0000
commit5ed8d124435dcc3851a12e6943f9e727c91233d7 (patch)
tree8688757ded2073d7415ee146442e3e4f0ccad695
parent99087885be1051d788b71bd67f1cdf5fa146a352 (diff)
downloadsrc-5ed8d124435dcc3851a12e6943f9e727c91233d7.tar.gz
src-5ed8d124435dcc3851a12e6943f9e727c91233d7.zip
Allow the buffer size to be configured for pseudo-like TTY devices.
Devices that don't implement param() (which means they don't support hardware parameters such as flow control, baud rate) hardcode the baud rate to TTYDEF_SPEED. This means the buffer size cannot be configured, which is a little inconvenient when using canonical mode with big lines of input, etc. Make it adjustable, but do clamp it between B50 and B115200 to prevent awkward buffer sizes. Remove the baud rate assignment from /etc/gettytab. Trust the kernel to fill in a proper value. Reported by: Mikolaj Golub <to my trociny gmail com> MFC after: 1 month
Notes
Notes: svn path=/head/; revision=198214
-rw-r--r--etc/gettytab2
-rw-r--r--sys/kern/tty.c15
2 files changed, 14 insertions, 3 deletions
diff --git a/etc/gettytab b/etc/gettytab
index b75da3d13816..2d3a80abc9be 100644
--- a/etc/gettytab
+++ b/etc/gettytab
@@ -162,7 +162,7 @@ X|Xwindow|X window system:\
:fd@:nd@:cd@:rw:sp#9600:
P|Pc|Pc console:\
- :ht:np:sp#115200:
+ :ht:np:
#
# Wierdo special case for fast crt's with hardcopy devices
diff --git a/sys/kern/tty.c b/sys/kern/tty.c
index 25908df8acc1..a3db944e7c44 100644
--- a/sys/kern/tty.c
+++ b/sys/kern/tty.c
@@ -870,8 +870,19 @@ static int
ttydevsw_defparam(struct tty *tp, struct termios *t)
{
- /* Use a fake baud rate, we're not a real device. */
- t->c_ispeed = t->c_ospeed = TTYDEF_SPEED;
+ /*
+ * Allow the baud rate to be adjusted for pseudo-devices, but at
+ * least restrict it to 115200 to prevent excessive buffer
+ * usage. Also disallow 0, to prevent foot shooting.
+ */
+ if (t->c_ispeed < B50)
+ t->c_ispeed = B50;
+ else if (t->c_ispeed > B115200)
+ t->c_ispeed = B115200;
+ if (t->c_ospeed < B50)
+ t->c_ospeed = B50;
+ else if (t->c_ospeed > B115200)
+ t->c_ospeed = B115200;
return (0);
}