Fix numerous bugs; flags in the wrong places, modes getting clobbered, etc.
This commit is contained in:
parent
de318bb111
commit
2566987063
@ -31,7 +31,7 @@
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* from: @(#)tty_compat.c 7.10 (Berkeley) 5/9/91
|
||||
* $Id: tty_compat.c,v 1.11 1994/03/05 22:42:55 mycroft Exp $
|
||||
* $Id: tty_compat.c,v 1.12 1994/04/12 17:18:59 mycroft Exp $
|
||||
*/
|
||||
|
||||
/*
|
||||
@ -42,12 +42,11 @@
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/tty.h>
|
||||
#include <sys/termios.h>
|
||||
#include <sys/proc.h>
|
||||
#include <sys/file.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/dkstat.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/syslog.h>
|
||||
|
||||
@ -110,7 +109,7 @@ ttcompat(tp, com, data, flag, p)
|
||||
}
|
||||
sg->sg_erase = cc[VERASE];
|
||||
sg->sg_kill = cc[VKILL];
|
||||
sg->sg_flags = tp->t_flags = ttcompatgetflags(tp);
|
||||
sg->sg_flags = ttcompatgetflags(tp);
|
||||
break;
|
||||
}
|
||||
|
||||
@ -131,7 +130,7 @@ ttcompat(tp, com, data, flag, p)
|
||||
term.c_ospeed = compatspcodes[speed];
|
||||
term.c_cc[VERASE] = sg->sg_erase;
|
||||
term.c_cc[VKILL] = sg->sg_kill;
|
||||
tp->t_flags = ttcompatgetflags(tp)&0xffff0000 | sg->sg_flags&0xffff;
|
||||
tp->t_flags = tp->t_flags&0xffff0000 | sg->sg_flags&0xffff;
|
||||
ttcompatsetflags(tp, &term);
|
||||
return (ttioctl(tp, com == TIOCSETP ? TIOCSETAF : TIOCSETA,
|
||||
(caddr_t)&term, flag, p));
|
||||
@ -194,9 +193,10 @@ ttcompat(tp, com, data, flag, p)
|
||||
|
||||
term = tp->t_termios;
|
||||
if (com == TIOCLSET)
|
||||
tp->t_flags = (ttcompatgetflags(tp)&0xffff) | *(int *)data<<16;
|
||||
tp->t_flags = (tp->t_flags&0xffff) | *(int *)data<<16;
|
||||
else {
|
||||
tp->t_flags = ttcompatgetflags(tp);
|
||||
tp->t_flags =
|
||||
(ttcompatgetflags(tp)&0xffff0000)|(tp->t_flags&0xffff);
|
||||
if (com == TIOCLBIS)
|
||||
tp->t_flags |= *(int *)data<<16;
|
||||
else
|
||||
@ -206,9 +206,7 @@ ttcompat(tp, com, data, flag, p)
|
||||
return (ttioctl(tp, TIOCSETA, (caddr_t)&term, flag, p));
|
||||
}
|
||||
case TIOCLGET:
|
||||
tp->t_flags =
|
||||
(ttcompatgetflags(tp)&0xffff0000)|(tp->t_flags&0xffff);
|
||||
*(int *)data = tp->t_flags>>16;
|
||||
*(int *)data = ttcompatgetflags(tp)>>16;
|
||||
if (ttydebug)
|
||||
printf("CLGET: returning %x\n", *(int *)data);
|
||||
break;
|
||||
@ -253,12 +251,7 @@ ttcompatgetflags(tp)
|
||||
flags |= TANDEM;
|
||||
if (iflag&ICRNL || oflag&ONLCR)
|
||||
flags |= CRMOD;
|
||||
if ((cflag&CSIZE) == CS8) {
|
||||
flags |= PASS8;
|
||||
if (iflag&ISTRIP)
|
||||
flags |= ANYP;
|
||||
}
|
||||
else if (cflag&PARENB) {
|
||||
if (cflag&PARENB) {
|
||||
if (iflag&INPCK) {
|
||||
if (cflag&PARODD)
|
||||
flags |= ODDP;
|
||||
@ -266,17 +259,24 @@ ttcompatgetflags(tp)
|
||||
flags |= EVENP;
|
||||
} else
|
||||
flags |= EVENP | ODDP;
|
||||
} else {
|
||||
if ((tp->t_flags&LITOUT) && !(oflag&OPOST))
|
||||
flags |= LITOUT;
|
||||
if (tp->t_flags&PASS8)
|
||||
flags |= PASS8;
|
||||
}
|
||||
|
||||
if ((lflag&ICANON) == 0) {
|
||||
/* fudge */
|
||||
if (oflag&OPOST || iflag&ISTRIP || iflag&IXON || lflag&ISIG || lflag&IEXTEN || cflag&PARENB || iflag&INPCK || (cflag&CSIZE) != CS8)
|
||||
if (iflag&IXON || lflag&ISIG || lflag&IEXTEN || cflag&PARENB)
|
||||
flags |= CBREAK;
|
||||
else
|
||||
flags |= RAW;
|
||||
}
|
||||
if (!(flags&RAW) && !(oflag&OPOST) && (!(cflag&PARENB) || (cflag&CSIZE) == CS8))
|
||||
flags |= LITOUT;
|
||||
if (cflag&MDMBUF)
|
||||
flags |= MDMBUF;
|
||||
if ((cflag&HUPCL) == 0)
|
||||
flags |= NOHANG;
|
||||
if (oflag&OXTABS)
|
||||
flags |= XTABS;
|
||||
if (lflag&ECHOE)
|
||||
@ -289,9 +289,9 @@ ttcompatgetflags(tp)
|
||||
flags |= CTLECH;
|
||||
if ((iflag&IXANY) == 0)
|
||||
flags |= DECCTQ;
|
||||
flags |= lflag&(ECHO|MDMBUF|TOSTOP|FLUSHO|NOHANG|PENDIN|NOFLSH);
|
||||
flags |= lflag&(ECHO|TOSTOP|FLUSHO|PENDIN|NOFLSH);
|
||||
if (ttydebug)
|
||||
printf("getflags: %x\n", flags);
|
||||
printf("getflags: %x\n", flags);
|
||||
return (flags);
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ ttcompatsetflags(tp, t)
|
||||
register long cflag = t->c_cflag;
|
||||
|
||||
if (flags & RAW) {
|
||||
iflag &= (IXOFF|IXANY);
|
||||
iflag &= IXOFF;
|
||||
oflag &= ~OPOST;
|
||||
lflag &= ~(ECHOCTL|ISIG|ICANON|IEXTEN);
|
||||
} else {
|
||||
@ -335,17 +335,16 @@ ttcompatsetflags(tp, t)
|
||||
else
|
||||
lflag &= ~ECHO;
|
||||
|
||||
cflag &= ~(CSIZE|PARENB);
|
||||
if (flags&(RAW|LITOUT|PASS8)) {
|
||||
cflag &= ~(CSIZE|PARENB);
|
||||
cflag |= CS8;
|
||||
if (!(flags&(RAW|PASS8)) || (flags&(RAW|PASS8|ANYP)) == (PASS8|ANYP))
|
||||
if ((flags&(RAW|PASS8)) == 0)
|
||||
iflag |= ISTRIP;
|
||||
else
|
||||
iflag &= ~ISTRIP;
|
||||
} else {
|
||||
cflag |= CS7;
|
||||
if ((flags&(EVENP|ODDP)))
|
||||
cflag |= PARENB;
|
||||
cflag &= ~CSIZE;
|
||||
cflag |= CS7|PARENB;
|
||||
iflag |= ISTRIP;
|
||||
}
|
||||
if ((flags&(EVENP|ODDP)) == EVENP) {
|
||||
@ -399,24 +398,28 @@ ttcompatsetlflags(tp, t)
|
||||
lflag |= IXANY;
|
||||
else
|
||||
lflag &= ~IXANY;
|
||||
lflag &= ~(MDMBUF|TOSTOP|FLUSHO|NOHANG|PENDIN|NOFLSH);
|
||||
lflag |= flags&(MDMBUF|TOSTOP|FLUSHO|NOHANG|PENDIN|NOFLSH);
|
||||
cflag &= ~(CSIZE|PARENB);
|
||||
if (flags & MDMBUF)
|
||||
cflag |= MDMBUF;
|
||||
else
|
||||
cflag &= ~MDMBUF;
|
||||
if (flags&NOHANG)
|
||||
cflag &= ~HUPCL;
|
||||
else
|
||||
cflag |= HUPCL;
|
||||
lflag &= ~(TOSTOP|FLUSHO|PENDIN|NOFLSH);
|
||||
lflag |= flags&(TOSTOP|FLUSHO|PENDIN|NOFLSH);
|
||||
if (flags&(LITOUT|PASS8)) {
|
||||
iflag &= ~ISTRIP;
|
||||
cflag &= ~(CSIZE|PARENB);
|
||||
cflag |= CS8;
|
||||
if (flags&(LITOUT|RAW))
|
||||
if (flags&LITOUT)
|
||||
oflag &= ~OPOST;
|
||||
else
|
||||
oflag |= OPOST;
|
||||
if (!(flags&(RAW|PASS8)) || (flags&(RAW|PASS8|ANYP)) == (PASS8|ANYP))
|
||||
if ((flags&(PASS8|RAW)) == 0)
|
||||
iflag |= ISTRIP;
|
||||
else
|
||||
iflag &= ~ISTRIP;
|
||||
} else if ((flags&RAW) == 0) {
|
||||
cflag |= CS7;
|
||||
if ((flags&(EVENP|ODDP)))
|
||||
cflag |= PARENB;
|
||||
oflag |= ISTRIP|OPOST;
|
||||
cflag &= ~CSIZE;
|
||||
cflag |= CS7|PARENB;
|
||||
oflag |= OPOST;
|
||||
}
|
||||
t->c_iflag = iflag;
|
||||
t->c_oflag = oflag;
|
||||
|
Loading…
Reference in New Issue
Block a user