summaryrefslogtreecommitdiffstats
path: root/sys
diff options
context:
space:
mode:
authorache <ache@FreeBSD.org>1995-08-02 12:03:12 +0000
committerache <ache@FreeBSD.org>1995-08-02 12:03:12 +0000
commita3dede93544fd29675cef5ae3a9de45206dd6082 (patch)
tree4500647c1e4b5cf38a3e3ebda2f88bb446957040 /sys
parent4b4411611caeeafff898c141215294745b3bd998 (diff)
downloadFreeBSD-src-a3dede93544fd29675cef5ae3a9de45206dd6082.zip
FreeBSD-src-a3dede93544fd29675cef5ae3a9de45206dd6082.tar.gz
Better approximation for TIOCGETP (gtty) for non-standard speeds.
Old variant returns 38400 for them, now it returns nearest matched rounded down, expect speeds in range 0 > speed < 50 rounded up to not produce hangup.
Diffstat (limited to 'sys')
-rw-r--r--sys/kern/tty_compat.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/sys/kern/tty_compat.c b/sys/kern/tty_compat.c
index 26ed1ec..b266b56 100644
--- a/sys/kern/tty_compat.c
+++ b/sys/kern/tty_compat.c
@@ -31,7 +31,7 @@
* SUCH DAMAGE.
*
* @(#)tty_compat.c 8.1 (Berkeley) 6/10/93
- * $Id: tty_compat.c,v 1.14 1995/08/01 23:27:36 ache Exp $
+ * $Id: tty_compat.c,v 1.15 1995/08/02 06:55:35 ache Exp $
*/
/*
@@ -80,9 +80,22 @@ static struct speedtab compatspeeds[] = {
};
static int compatspcodes[] = {
0, 50, 75, 110, 134, 150, 200, 300, 600, 1200,
- 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200,
+ 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200
};
+static
+int ttcompatspeedtab(speed, table)
+ int speed;
+ register struct speedtab *table;
+{
+ if (speed == 0)
+ return (0); /* hangup */
+ for ( ; table->sp_speed > 0; table++)
+ if (table->sp_speed <= speed) /* nearest one, rounded down */
+ return (table->sp_code);
+ return (1); /* 50, min and not hangup */
+}
+
int ttsetcompat(tp, com, data, term)
register struct tty *tp;
int *com;
@@ -187,16 +200,12 @@ ttcompat(tp, com, data, flag)
case TIOCGETP: {
register struct sgttyb *sg = (struct sgttyb *)data;
register cc_t *cc = tp->t_cc;
- register speed;
- speed = ttspeedtab(tp->t_ospeed, compatspeeds);
- sg->sg_ospeed = (speed == -1) ? MAX_SPEED : speed;
+ sg->sg_ospeed = ttcompatspeedtab(tp->t_ospeed, compatspeeds);
if (tp->t_ispeed == 0)
sg->sg_ispeed = sg->sg_ospeed;
- else {
- speed = ttspeedtab(tp->t_ispeed, compatspeeds);
- sg->sg_ispeed = (speed == -1) ? MAX_SPEED : speed;
- }
+ else
+ sg->sg_ispeed = ttcompatspeedtab(tp->t_ispeed, compatspeeds);
sg->sg_erase = cc[VERASE];
sg->sg_kill = cc[VKILL];
sg->sg_flags = tp->t_flags = ttcompatgetflags(tp);
OpenPOWER on IntegriCloud