tty_compat.c revision 330897
1130167Sgad/*- 2130167Sgad * SPDX-License-Identifier: BSD-3-Clause 3130167Sgad * 4130167Sgad * Copyright (c) 1982, 1986, 1991, 1993 5130167Sgad * The Regents of the University of California. All rights reserved. 6130167Sgad * 7130167Sgad * Redistribution and use in source and binary forms, with or without 8130167Sgad * modification, are permitted provided that the following conditions 9130167Sgad * are met: 10130167Sgad * 1. Redistributions of source code must retain the above copyright 11130167Sgad * notice, this list of conditions and the following disclaimer. 12130167Sgad * 2. Redistributions in binary form must reproduce the above copyright 13130167Sgad * notice, this list of conditions and the following disclaimer in the 14130167Sgad * documentation and/or other materials provided with the distribution. 15130167Sgad * 4. Neither the name of the University nor the names of its contributors 16130167Sgad * may be used to endorse or promote products derived from this software 17130167Sgad * without specific prior written permission. 18130167Sgad * 19130167Sgad * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 20130167Sgad * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 21130167Sgad * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 22130167Sgad * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 23130167Sgad * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 24130167Sgad * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 25130167Sgad * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 26130167Sgad * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 27130167Sgad * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 28130167Sgad * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 29130167Sgad * SUCH DAMAGE. 30130167Sgad * 3113244Sgraichen * @(#)tty_compat.c 8.1 (Berkeley) 6/10/93 3213244Sgraichen */ 3313244Sgraichen 3413244Sgraichen#include <sys/cdefs.h> 3513244Sgraichen__FBSDID("$FreeBSD: stable/11/sys/kern/tty_compat.c 330897 2018-03-14 03:19:51Z eadler $"); 3659004Shm 3759004Shm#include "opt_compat.h" 3859004Shm 3959004Shm/* 4059004Shm * mapping routines for old line discipline (yuck) 4159004Shm */ 4259004Shm 4359004Shm#include <sys/param.h> 4459004Shm#include <sys/systm.h> 4559004Shm#include <sys/ioctl_compat.h> 4659004Shm#include <sys/tty.h> 4759004Shm#include <sys/kernel.h> 4859004Shm#include <sys/sysctl.h> 4959004Shm 5013244Sgraichenstruct speedtab { 5113244Sgraichen int sp_speed; /* Speed. */ 5259004Shm int sp_code; /* Code. */ 5359004Shm}; 5413244Sgraichen 5513244Sgraichenstatic int ttcompatgetflags(struct tty *tp); 56114601Sobrienstatic void ttcompatsetflags(struct tty *tp, struct termios *t); 57114601Sobrienstatic void ttcompatsetlflags(struct tty *tp, struct termios *t); 5813244Sgraichenstatic int ttcompatspeedtab(int speed, struct speedtab *table); 59130045Sgad 6013244Sgraichenstatic int ttydebug = 0; 61130045SgadSYSCTL_INT(_debug, OID_AUTO, ttydebug, CTLFLAG_RW, &ttydebug, 0, ""); 6213244Sgraichen 6380638Sobrienstatic struct speedtab compatspeeds[] = { 6480638Sobrien#define MAX_SPEED 17 6580638Sobrien { 115200, 17 }, 6613244Sgraichen { 57600, 16 }, 6796001Smaxim { 38400, 15 }, 68130167Sgad { 19200, 14 }, 6996001Smaxim { 9600, 13 }, 7096001Smaxim { 4800, 12 }, 7196001Smaxim { 2400, 11 }, 7230160Scharnier { 1800, 10 }, 7330160Scharnier { 1200, 9 }, 7495999Smaxim { 600, 8 }, 7530160Scharnier { 300, 7 }, 76111773Sgad { 200, 6 }, 77106905Ssobomax { 150, 5 }, 7830160Scharnier { 134, 4 }, 7943071Swollman { 110, 3 }, 8030160Scharnier { 75, 2 }, 8130160Scharnier { 50, 1 }, 8213244Sgraichen { 0, 0 }, 8313244Sgraichen { -1, -1 }, 8413244Sgraichen}; 8543071Swollmanstatic int compatspcodes[] = { 8616240Salex 0, 50, 75, 110, 134, 150, 200, 300, 600, 1200, 8713244Sgraichen 1800, 2400, 4800, 9600, 19200, 38400, 57600, 115200, 8843071Swollman}; 89119998Sgad 9043071Swollmanstatic int 91111768Sgadttcompatspeedtab(int speed, struct speedtab *table) 92111768Sgad{ 93111768Sgad if (speed == 0) 94130045Sgad return (0); /* hangup */ 95130045Sgad for ( ; table->sp_speed > 0; table++) 96130045Sgad if (table->sp_speed <= speed) /* nearest one, rounded down */ 97111768Sgad return (table->sp_code); 98130045Sgad return (1); /* 50, min and not hangup */ 99111768Sgad} 100130045Sgad 101130045Sgadstatic int 102130045Sgadttsetcompat(struct tty *tp, u_long *com, caddr_t data, struct termios *term) 103112003Sgad{ 104130045Sgad switch (*com) { 105130043Sgad case TIOCSETP: 10643071Swollman case TIOCSETN: { 107130045Sgad struct sgttyb *sg = (struct sgttyb *)data; 108130045Sgad int speed; 109111781Sgad 110130045Sgad if ((speed = sg->sg_ispeed) > MAX_SPEED || speed < 0) 111111781Sgad return(EINVAL); 112130165Sgad else if (speed != ttcompatspeedtab(tp->t_termios.c_ispeed, 113130165Sgad compatspeeds)) 114130165Sgad term->c_ispeed = compatspcodes[speed]; 11513244Sgraichen else 11659003Shm term->c_ispeed = tp->t_termios.c_ispeed; 11759003Shm if ((speed = sg->sg_ospeed) > MAX_SPEED || speed < 0) 118111772Sgad return(EINVAL); 119114137Sgad else if (speed != ttcompatspeedtab(tp->t_termios.c_ospeed, 120111772Sgad compatspeeds)) 121130165Sgad term->c_ospeed = compatspcodes[speed]; 122111779Sgad else 123111779Sgad term->c_ospeed = tp->t_termios.c_ospeed; 12459003Shm term->c_cc[VERASE] = sg->sg_erase; 125130165Sgad term->c_cc[VKILL] = sg->sg_kill; 12659003Shm tp->t_compatflags = (tp->t_compatflags&0xffff0000) | 127120361Sgad (sg->sg_flags&0xffff); 128139655Sdelphij ttcompatsetflags(tp, term); 12980646Sobrien *com = (*com == TIOCSETP) ? TIOCSETAF : TIOCSETA; 13059003Shm break; 131111388Sgad } 13259003Shm case TIOCSETC: { 13313244Sgraichen struct tchars *tc = (struct tchars *)data; 13413244Sgraichen cc_t *cc; 135130167Sgad 136130167Sgad cc = term->c_cc; 137130167Sgad cc[VINTR] = tc->t_intrc; 138130167Sgad cc[VQUIT] = tc->t_quitc; 139130167Sgad cc[VSTART] = tc->t_startc; 140130167Sgad cc[VSTOP] = tc->t_stopc; 141130167Sgad cc[VEOF] = tc->t_eofc; 142130167Sgad cc[VEOL] = tc->t_brkc; 143130167Sgad if (tc->t_brkc == (char)_POSIX_VDISABLE) 144130167Sgad cc[VEOL2] = _POSIX_VDISABLE; 145130167Sgad *com = TIOCSETA; 146130167Sgad break; 147130167Sgad } 148130167Sgad case TIOCSLTC: { 149130167Sgad struct ltchars *ltc = (struct ltchars *)data; 150130167Sgad cc_t *cc; 151130167Sgad 152130165Sgad cc = term->c_cc; 153130165Sgad cc[VSUSP] = ltc->t_suspc; 154130165Sgad cc[VDSUSP] = ltc->t_dsuspc; 155111388Sgad cc[VREPRINT] = ltc->t_rprntc; 156130167Sgad cc[VDISCARD] = ltc->t_flushc; 157130167Sgad cc[VWERASE] = ltc->t_werasc; 158130167Sgad cc[VLNEXT] = ltc->t_lnextc; 159120361Sgad *com = TIOCSETA; 160120361Sgad break; 16159004Shm } 162114137Sgad case TIOCLBIS: 163114137Sgad case TIOCLBIC: 164114137Sgad case TIOCLSET: 16559003Shm if (*com == TIOCLSET) 16659003Shm tp->t_compatflags = (tp->t_compatflags&0xffff) | 16759003Shm *(int *)data<<16; 168143106Sbrooks else { 169111768Sgad tp->t_compatflags = (ttcompatgetflags(tp)&0xffff0000) | 17059003Shm (tp->t_compatflags&0xffff); 171111772Sgad if (*com == TIOCLBIS) 172111772Sgad tp->t_compatflags |= *(int *)data<<16; 173111772Sgad else 174111772Sgad tp->t_compatflags &= ~(*(int *)data<<16); 175111772Sgad } 17659004Shm ttcompatsetlflags(tp, term); 177136127Sbrooks *com = TIOCSETA; 178111773Sgad break; 17959003Shm } 180120361Sgad return 0; 181120361Sgad} 182120361Sgad 183159998Sgad/*ARGSUSED*/ 184159998Sgadint 185159998Sgadtty_ioctl_compat(struct tty *tp, u_long com, caddr_t data, int fflag, 18671299Sjedgar struct thread *td) 18713244Sgraichen{ 188111773Sgad switch (com) { 189111773Sgad case TIOCSETP: 190112020Sgad case TIOCSETN: 19116240Salex case TIOCSETC: 19216240Salex case TIOCSLTC: 193119102Sgad case TIOCLBIS: 19459003Shm case TIOCLBIC: 195130165Sgad case TIOCLSET: { 196130165Sgad struct termios term; 197130165Sgad int error; 198130167Sgad 199130167Sgad term = tp->t_termios; 200130167Sgad if ((error = ttsetcompat(tp, &com, data, &term)) != 0) 201130167Sgad return error; 202130167Sgad return tty_ioctl(tp, com, &term, fflag, td); 203130167Sgad } 204130167Sgad case TIOCGETP: { 205130167Sgad struct sgttyb *sg = (struct sgttyb *)data; 206130165Sgad cc_t *cc = tp->t_termios.c_cc; 207112020Sgad 208112020Sgad sg->sg_ospeed = ttcompatspeedtab(tp->t_termios.c_ospeed, 209112020Sgad compatspeeds); 210111388Sgad if (tp->t_termios.c_ispeed == 0) 211111388Sgad sg->sg_ispeed = sg->sg_ospeed; 212111388Sgad else 213111781Sgad sg->sg_ispeed = ttcompatspeedtab(tp->t_termios.c_ispeed, 214119904Sgad compatspeeds); 21580640Sobrien sg->sg_erase = cc[VERASE]; 216119926Sgad sg->sg_kill = cc[VKILL]; 21716240Salex sg->sg_flags = tp->t_compatflags = ttcompatgetflags(tp); 218130038Sgad break; 219114137Sgad } 220114137Sgad case TIOCGETC: { 22113244Sgraichen struct tchars *tc = (struct tchars *)data; 222111768Sgad cc_t *cc = tp->t_termios.c_cc; 223129975Sgad 224129975Sgad tc->t_intrc = cc[VINTR]; 225129975Sgad tc->t_quitc = cc[VQUIT]; 226111768Sgad tc->t_startc = cc[VSTART]; 227129975Sgad tc->t_stopc = cc[VSTOP]; 228129975Sgad tc->t_eofc = cc[VEOF]; 229129975Sgad tc->t_brkc = cc[VEOL]; 230129975Sgad break; 231111768Sgad } 23259004Shm case TIOCGLTC: { 23359004Shm struct ltchars *ltc = (struct ltchars *)data; 23413244Sgraichen cc_t *cc = tp->t_termios.c_cc; 235130165Sgad 23659003Shm ltc->t_suspc = cc[VSUSP]; 237130167Sgad ltc->t_dsuspc = cc[VDSUSP]; 238130167Sgad ltc->t_rprntc = cc[VREPRINT]; 23925443Sache ltc->t_flushc = cc[VDISCARD]; 240130167Sgad ltc->t_werasc = cc[VWERASE]; 241130167Sgad ltc->t_lnextc = cc[VLNEXT]; 242130167Sgad break; 243111781Sgad } 244111773Sgad case TIOCLGET: 245111773Sgad tp->t_compatflags = 246111773Sgad (ttcompatgetflags(tp) & 0xffff0000UL) 24759003Shm | (tp->t_compatflags & 0xffff); 24859003Shm *(int *)data = tp->t_compatflags>>16; 249111773Sgad if (ttydebug) 25059003Shm printf("CLGET: returning %x\n", *(int *)data); 251130165Sgad break; 252130165Sgad 253130165Sgad case OTIOCGETD: 254130165Sgad *(int *)data = 2; 25559003Shm break; 256130165Sgad 25759003Shm case OTIOCSETD: { 258130165Sgad int ldisczero = 0; 259130165Sgad 26059003Shm return (tty_ioctl(tp, TIOCSETD, 26159003Shm *(int *)data == 2 ? (caddr_t)&ldisczero : data, 262130165Sgad fflag, td)); 263130167Sgad } 264130167Sgad 265130167Sgad case OTIOCCONS: 266130167Sgad *(int *)data = 1; 267130167Sgad return (tty_ioctl(tp, TIOCCONS, data, fflag, td)); 268130167Sgad 269130167Sgad default: 270130204Sgad return (ENOIOCTL); 271130167Sgad } 272130167Sgad return (0); 273130167Sgad} 274130204Sgad 275130204Sgadstatic int 276130204Sgadttcompatgetflags(struct tty *tp) 277130204Sgad{ 278130204Sgad tcflag_t iflag = tp->t_termios.c_iflag; 279130204Sgad tcflag_t lflag = tp->t_termios.c_lflag; 280130204Sgad tcflag_t oflag = tp->t_termios.c_oflag; 281130204Sgad tcflag_t cflag = tp->t_termios.c_cflag; 282130167Sgad int flags = 0; 283130167Sgad 284130167Sgad if (iflag&IXOFF) 285130167Sgad flags |= TANDEM; 286130167Sgad if (iflag&ICRNL || oflag&ONLCR) 287130167Sgad flags |= CRMOD; 288130167Sgad if ((cflag&CSIZE) == CS8) { 289130204Sgad flags |= PASS8; 290130167Sgad if (iflag&ISTRIP) 291130167Sgad flags |= ANYP; 292130167Sgad } 293130167Sgad else if (cflag&PARENB) { 294130167Sgad if (iflag&INPCK) { 295130167Sgad if (cflag&PARODD) 296130167Sgad flags |= ODDP; 297130167Sgad else 298130167Sgad flags |= EVENP; 299130167Sgad } else 300130167Sgad flags |= EVENP | ODDP; 301130167Sgad } 302130167Sgad 303130167Sgad if ((lflag&ICANON) == 0) { 304130167Sgad /* fudge */ 30595999Smaxim if (iflag&(INPCK|ISTRIP|IXON) || lflag&(IEXTEN|ISIG) 30695999Smaxim || (cflag&(CSIZE|PARENB)) != CS8) 30759003Shm flags |= CBREAK; 30813244Sgraichen else 30913244Sgraichen flags |= RAW; 310111388Sgad } 311111388Sgad if (!(flags&RAW) && !(oflag&OPOST) && (cflag&(CSIZE|PARENB)) == CS8) 312111388Sgad flags |= LITOUT; 313111388Sgad if (cflag&MDMBUF) 314111388Sgad flags |= MDMBUF; 315111388Sgad if ((cflag&HUPCL) == 0) 316111388Sgad flags |= NOHANG; 317111388Sgad if (oflag&TAB3) 318111388Sgad flags |= XTABS; 319111388Sgad if (lflag&ECHOE) 320111388Sgad flags |= CRTERA|CRTBS; 321111388Sgad if (lflag&ECHOKE) 322136174Sbrooks flags |= CRTKIL|CRTBS; 323136127Sbrooks if (lflag&ECHOPRT) 324136127Sbrooks flags |= PRTERA; 325136127Sbrooks if (lflag&ECHOCTL) 326111388Sgad flags |= CTLECH; 327111388Sgad if ((iflag&IXANY) == 0) 328111388Sgad flags |= DECCTQ; 329111388Sgad flags |= lflag&(ECHO|TOSTOP|FLUSHO|PENDIN|NOFLSH); 330111388Sgad if (ttydebug) 331111388Sgad printf("getflags: %x\n", flags); 332111388Sgad return (flags); 333111772Sgad} 334114137Sgad 335111772Sgadstatic void 336130165Sgadttcompatsetflags(struct tty *tp, struct termios *t) 337111388Sgad{ 338111388Sgad int flags = tp->t_compatflags; 339111388Sgad tcflag_t iflag = t->c_iflag; 340130165Sgad tcflag_t oflag = t->c_oflag; 341111388Sgad tcflag_t lflag = t->c_lflag; 342120361Sgad tcflag_t cflag = t->c_cflag; 343120361Sgad 344120361Sgad if (flags & RAW) { 345111388Sgad iflag = IGNBRK; 346111388Sgad lflag &= ~(ECHOCTL|ISIG|ICANON|IEXTEN); 347111388Sgad } else { 348111388Sgad iflag &= ~(PARMRK|IGNPAR|IGNCR|INLCR); 349111388Sgad iflag |= BRKINT|IXON|IMAXBEL; 350111388Sgad lflag |= ISIG|IEXTEN|ECHOCTL; /* XXX was echoctl on ? */ 351111388Sgad if (flags & XTABS) 352111772Sgad oflag |= TAB3; 353114137Sgad else 354111772Sgad oflag &= ~TAB3; 355130165Sgad if (flags & CBREAK) 356111779Sgad lflag &= ~ICANON; 357111779Sgad else 358111388Sgad lflag |= ICANON; 359130165Sgad if (flags&CRMOD) { 360111388Sgad iflag |= ICRNL; 361120361Sgad oflag |= ONLCR; 362111388Sgad } else { 363111388Sgad iflag &= ~ICRNL; 364111388Sgad oflag &= ~ONLCR; 365111388Sgad } 366111388Sgad } 367111388Sgad if (flags&ECHO) 368111388Sgad lflag |= ECHO; 369111388Sgad else 370111388Sgad lflag &= ~ECHO; 371111388Sgad 37259004Shm cflag &= ~(CSIZE|PARENB); 373111388Sgad if (flags&(RAW|LITOUT|PASS8)) { 374111388Sgad cflag |= CS8; 375111388Sgad if (!(flags&(RAW|PASS8)) 376111388Sgad || (flags&(RAW|PASS8|ANYP)) == (PASS8|ANYP)) 377111388Sgad iflag |= ISTRIP; 378111388Sgad else 379111388Sgad iflag &= ~ISTRIP; 380111388Sgad if (flags&(RAW|LITOUT)) 381111388Sgad oflag &= ~OPOST; 382111388Sgad else 383111388Sgad oflag |= OPOST; 384111388Sgad } else { 385111388Sgad cflag |= CS7|PARENB; 386111388Sgad iflag |= ISTRIP; 387111388Sgad oflag |= OPOST; 388111388Sgad } 389111388Sgad /* XXX don't set INPCK if RAW or PASS8? */ 390111388Sgad if ((flags&(EVENP|ODDP)) == EVENP) { 391111772Sgad iflag |= INPCK; 392111772Sgad cflag &= ~PARODD; 393111772Sgad } else if ((flags&(EVENP|ODDP)) == ODDP) { 394111772Sgad iflag |= INPCK; 395111772Sgad cflag |= PARODD; 396120361Sgad } else 397120361Sgad iflag &= ~INPCK; 398120361Sgad if (flags&TANDEM) 399120361Sgad iflag |= IXOFF; 400120361Sgad else 401111388Sgad iflag &= ~IXOFF; 402111388Sgad if ((flags&DECCTQ) == 0) 403111388Sgad iflag |= IXANY; 404111388Sgad else 405112020Sgad iflag &= ~IXANY; 406112020Sgad t->c_iflag = iflag; 407112020Sgad t->c_oflag = oflag; 408112020Sgad t->c_lflag = lflag; 409112020Sgad t->c_cflag = cflag; 410112020Sgad} 411112020Sgad 412112020Sgadstatic void 413112020Sgadttcompatsetlflags(struct tty *tp, struct termios *t) 414112020Sgad{ 415112020Sgad int flags = tp->t_compatflags; 416112020Sgad tcflag_t iflag = t->c_iflag; 417112020Sgad tcflag_t oflag = t->c_oflag; 418112020Sgad tcflag_t lflag = t->c_lflag; 419112020Sgad tcflag_t cflag = t->c_cflag; 420112020Sgad 421112020Sgad iflag &= ~(PARMRK|IGNPAR|IGNCR|INLCR); 422130165Sgad if (flags&CRTERA) 42359004Shm lflag |= ECHOE; 42413244Sgraichen else 425130045Sgad lflag &= ~ECHOE; 426130165Sgad if (flags&CRTKIL) 427130165Sgad lflag |= ECHOKE; 428120361Sgad else 429111772Sgad lflag &= ~ECHOKE; 43059003Shm if (flags&PRTERA) 431130165Sgad lflag |= ECHOPRT; 43259003Shm else 43359003Shm lflag &= ~ECHOPRT; 43459003Shm if (flags&CTLECH) 43580638Sobrien lflag |= ECHOCTL; 43680638Sobrien else 43759003Shm lflag &= ~ECHOCTL; 43859003Shm if (flags&TANDEM) 43959003Shm iflag |= IXOFF; 440130165Sgad else 44159003Shm iflag &= ~IXOFF; 442111772Sgad if ((flags&DECCTQ) == 0) 443114137Sgad iflag |= IXANY; 444130165Sgad else 445114137Sgad iflag &= ~IXANY; 446114137Sgad if (flags & MDMBUF) 447114137Sgad cflag |= MDMBUF; 448114137Sgad else 449114137Sgad cflag &= ~MDMBUF; 450114137Sgad if (flags&NOHANG) 451114137Sgad cflag &= ~HUPCL; 452114137Sgad else 453114137Sgad cflag |= HUPCL; 454114137Sgad lflag &= ~(TOSTOP|FLUSHO|PENDIN|NOFLSH); 455114137Sgad lflag |= flags&(TOSTOP|FLUSHO|PENDIN|NOFLSH); 456114137Sgad 457159998Sgad /* 458114137Sgad * The next if-else statement is copied from above so don't bother 459159998Sgad * checking it separately. We could avoid fiddlling with the 460114137Sgad * character size if the mode is already RAW or if neither the 461114137Sgad * LITOUT bit or the PASS8 bit is being changed, but the delta of 462114137Sgad * the change is not available here and skipping the RAW case would 463114137Sgad * make the code different from above. 464114137Sgad */ 465114137Sgad cflag &= ~(CSIZE|PARENB); 466114137Sgad if (flags&(RAW|LITOUT|PASS8)) { 467114137Sgad cflag |= CS8; 46859003Shm if (!(flags&(RAW|PASS8)) 469111772Sgad || (flags&(RAW|PASS8|ANYP)) == (PASS8|ANYP)) 470120361Sgad iflag |= ISTRIP; 471120361Sgad else 472120361Sgad iflag &= ~ISTRIP; 473120361Sgad if (flags&(RAW|LITOUT)) 474120361Sgad oflag &= ~OPOST; 475120361Sgad else 47643071Swollman oflag |= OPOST; 477120361Sgad } else { 478120361Sgad cflag |= CS7|PARENB; 479130165Sgad iflag |= ISTRIP; 480120361Sgad oflag |= OPOST; 481120361Sgad } 482120361Sgad t->c_iflag = iflag; 483120361Sgad t->c_oflag = oflag; 484120361Sgad t->c_lflag = lflag; 485120361Sgad t->c_cflag = cflag; 486120361Sgad} 487120361Sgad