141486Smckusick /* 241486Smckusick * Copyright (c) 1988 University of Utah. 341486Smckusick * Copyright (c) 1990 The Regents of the University of California. 441486Smckusick * All rights reserved. 541486Smckusick * 641486Smckusick * This code is derived from software contributed to Berkeley by 741486Smckusick * the Systems Programming Group of the University of Utah Computer 841486Smckusick * Science Department. 941486Smckusick * 1041486Smckusick * %sccs.include.redist.c% 1141486Smckusick * 1245423Smckusick * from: Utah $Hdr: hpux_tty.c 1.1 90/07/09$ 1341486Smckusick * 14*56314Shibler * @(#)hpux_tty.c 7.12 (Berkeley) 09/21/92 1541486Smckusick */ 1641486Smckusick 1741486Smckusick /* 1841486Smckusick * stty/gtty/termio emulation stuff 1941486Smckusick */ 2041486Smckusick #ifdef HPUXCOMPAT 2141486Smckusick 2248477Skarels #include "param.h" 2348477Skarels #include "systm.h" 2448477Skarels #include "filedesc.h" 2548477Skarels #include "ioctl.h" 2652519Smckusick #include "proc.h" 2748477Skarels #include "tty.h" 2848477Skarels #include "file.h" 2948477Skarels #include "conf.h" 3048477Skarels #include "buf.h" 3148477Skarels #include "kernel.h" 3241486Smckusick 3341486Smckusick #include "hpux.h" 3441486Smckusick #include "hpux_termio.h" 3541486Smckusick 3641486Smckusick /* 3744341Shibler * Map BSD/POSIX style termios info to and from SYS5 style termio stuff. 3841486Smckusick */ 3948477Skarels hpuxtermio(fp, com, data, p) 4041486Smckusick struct file *fp; 4141486Smckusick caddr_t data; 4248477Skarels struct proc *p; 4341486Smckusick { 4444341Shibler struct termios tios; 4555830Shibler struct hpuxtermios htios; 4644341Shibler int line, error, (*ioctlrout)(); 4755830Shibler int newi = 0; 4841486Smckusick 4941486Smckusick ioctlrout = fp->f_ops->fo_ioctl; 5041486Smckusick switch (com) { 5155830Shibler case HPUXTCGETATTR: 5255830Shibler newi = 1; 5355830Shibler /* fall into ... */ 5441486Smckusick case HPUXTCGETA: 5544341Shibler /* 5644341Shibler * Get BSD terminal state 5744341Shibler */ 5848477Skarels if (error = (*ioctlrout)(fp, TIOCGETA, (caddr_t)&tios, p)) 5941486Smckusick break; 6055830Shibler bzero((char *)&htios, sizeof htios); 6144341Shibler /* 6244341Shibler * Set iflag. 6344341Shibler * Same through ICRNL, no BSD equivs for IUCLC, IENQAK 6444341Shibler */ 6555830Shibler htios.c_iflag = tios.c_iflag & 0x1ff; 6644341Shibler if (tios.c_iflag & IXON) 6755830Shibler htios.c_iflag |= TIO_IXON; 6844341Shibler if (tios.c_iflag & IXOFF) 6955830Shibler htios.c_iflag |= TIO_IXOFF; 7044341Shibler if (tios.c_iflag & IXANY) 7155830Shibler htios.c_iflag |= TIO_IXANY; 7244341Shibler /* 7344341Shibler * Set oflag. 7444341Shibler * No BSD equivs for OLCUC/OCRNL/ONOCR/ONLRET/OFILL/OFDEL 7544341Shibler * or any of the delays. 7644341Shibler */ 7744341Shibler if (tios.c_oflag & OPOST) 7855830Shibler htios.c_oflag |= TIO_OPOST; 7944341Shibler if (tios.c_oflag & ONLCR) 8055830Shibler htios.c_oflag |= TIO_ONLCR; 8144341Shibler if (tios.c_oflag & OXTABS) 8255830Shibler htios.c_oflag |= TIO_TAB3; 8344341Shibler /* 8444341Shibler * Set cflag. 8544341Shibler * Baud from ospeed, rest from cflag. 8644341Shibler */ 8755830Shibler htios.c_cflag = bsdtohpuxbaud(tios.c_ospeed); 8844341Shibler switch (tios.c_cflag & CSIZE) { 8944341Shibler case CS5: 9055830Shibler htios.c_cflag |= TIO_CS5; break; 9144341Shibler case CS6: 9255830Shibler htios.c_cflag |= TIO_CS6; break; 9344341Shibler case CS7: 9455830Shibler htios.c_cflag |= TIO_CS7; break; 9544341Shibler case CS8: 9655830Shibler htios.c_cflag |= TIO_CS8; break; 9741486Smckusick } 9844341Shibler if (tios.c_cflag & CSTOPB) 9955830Shibler htios.c_cflag |= TIO_CSTOPB; 10044341Shibler if (tios.c_cflag & CREAD) 10155830Shibler htios.c_cflag |= TIO_CREAD; 10244341Shibler if (tios.c_cflag & PARENB) 10355830Shibler htios.c_cflag |= TIO_PARENB; 10444341Shibler if (tios.c_cflag & PARODD) 10555830Shibler htios.c_cflag |= TIO_PARODD; 10644341Shibler if (tios.c_cflag & HUPCL) 10755830Shibler htios.c_cflag |= TIO_HUPCL; 10844341Shibler if (tios.c_cflag & CLOCAL) 10955830Shibler htios.c_cflag |= TIO_CLOCAL; 11044341Shibler /* 11144341Shibler * Set lflag. 11244341Shibler * No BSD equiv for XCASE. 11344341Shibler */ 11444341Shibler if (tios.c_lflag & ECHOE) 11555830Shibler htios.c_lflag |= TIO_ECHOE; 11644341Shibler if (tios.c_lflag & ECHOK) 11755830Shibler htios.c_lflag |= TIO_ECHOK; 11844341Shibler if (tios.c_lflag & ECHO) 11955830Shibler htios.c_lflag |= TIO_ECHO; 12044341Shibler if (tios.c_lflag & ECHONL) 12155830Shibler htios.c_lflag |= TIO_ECHONL; 12244341Shibler if (tios.c_lflag & ISIG) 12355830Shibler htios.c_lflag |= TIO_ISIG; 12444341Shibler if (tios.c_lflag & ICANON) 12555830Shibler htios.c_lflag |= TIO_ICANON; 12644341Shibler if (tios.c_lflag & NOFLSH) 12755830Shibler htios.c_lflag |= TIO_NOFLSH; 12844341Shibler /* 12944341Shibler * Line discipline 13044341Shibler */ 13155830Shibler if (!newi) { 13255830Shibler line = 0; 13355830Shibler (void) (*ioctlrout)(fp, TIOCGETD, (caddr_t)&line, p); 13455830Shibler htios.c_reserved = line; 13555830Shibler } 13644341Shibler /* 13755830Shibler * Set editing chars. 13855830Shibler * No BSD equiv for VSWTCH. 13944341Shibler */ 14055830Shibler htios.c_cc[HPUXVINTR] = tios.c_cc[VINTR]; 14155830Shibler htios.c_cc[HPUXVQUIT] = tios.c_cc[VQUIT]; 14255830Shibler htios.c_cc[HPUXVERASE] = tios.c_cc[VERASE]; 14355830Shibler htios.c_cc[HPUXVKILL] = tios.c_cc[VKILL]; 14455830Shibler htios.c_cc[HPUXVEOF] = tios.c_cc[VEOF]; 14555830Shibler htios.c_cc[HPUXVEOL] = tios.c_cc[VEOL]; 14655830Shibler htios.c_cc[HPUXVEOL2] = tios.c_cc[VEOL2]; 14755830Shibler htios.c_cc[HPUXVSWTCH] = 0; 14855830Shibler htios.c_cc[HPUXVMINS] = tios.c_cc[VMIN]; 14955830Shibler htios.c_cc[HPUXVTIMES] = tios.c_cc[VTIME]; 15055830Shibler htios.c_cc[HPUXVSUSP] = tios.c_cc[VSUSP]; 15155830Shibler htios.c_cc[HPUXVSTART] = tios.c_cc[VSTART]; 15255830Shibler htios.c_cc[HPUXVSTOP] = tios.c_cc[VSTOP]; 15355830Shibler if (newi) 15455830Shibler bcopy((char *)&htios, data, sizeof htios); 15555830Shibler else 15655830Shibler termiostotermio(&htios, (struct hpuxtermio *)data); 15741486Smckusick break; 15841486Smckusick 15955830Shibler case HPUXTCSETATTR: 16055830Shibler case HPUXTCSETATTRD: 16155830Shibler case HPUXTCSETATTRF: 16255830Shibler newi = 1; 16355830Shibler /* fall into ... */ 16441486Smckusick case HPUXTCSETA: 16541486Smckusick case HPUXTCSETAW: 16641486Smckusick case HPUXTCSETAF: 16744341Shibler /* 16844341Shibler * Get old characteristics and determine if we are a tty. 16944341Shibler */ 17048477Skarels if (error = (*ioctlrout)(fp, TIOCGETA, (caddr_t)&tios, p)) 17141486Smckusick break; 172*56314Shibler if (newi) 173*56314Shibler bcopy(data, (char *)&htios, sizeof htios); 174*56314Shibler else 175*56314Shibler termiototermios((struct termio *)data, &htios, &tios); 17644341Shibler /* 17744341Shibler * Set iflag. 17844341Shibler * Same through ICRNL, no HP-UX equiv for IMAXBEL 17944341Shibler */ 18044341Shibler tios.c_iflag &= ~(IXON|IXOFF|IXANY|0x1ff); 18155830Shibler tios.c_iflag |= htios.c_iflag & 0x1ff; 18255830Shibler if (htios.c_iflag & TIO_IXON) 18344341Shibler tios.c_iflag |= IXON; 18455830Shibler if (htios.c_iflag & TIO_IXOFF) 18544341Shibler tios.c_iflag |= IXOFF; 18655830Shibler if (htios.c_iflag & TIO_IXANY) 18744341Shibler tios.c_iflag |= IXANY; 18844341Shibler /* 18944341Shibler * Set oflag. 19044341Shibler * No HP-UX equiv for ONOEOT 19144341Shibler */ 19244341Shibler tios.c_oflag &= ~(OPOST|ONLCR|OXTABS); 19355830Shibler if (htios.c_oflag & TIO_OPOST) 19444341Shibler tios.c_oflag |= OPOST; 19555830Shibler if (htios.c_oflag & TIO_ONLCR) 19644341Shibler tios.c_oflag |= ONLCR; 19755830Shibler if (htios.c_oflag & TIO_TAB3) 19844341Shibler tios.c_oflag |= OXTABS; 19944341Shibler /* 20044341Shibler * Set cflag. 20144341Shibler * No HP-UX equiv for CCTS_OFLOW/CCTS_IFLOW/MDMBUF 20244341Shibler */ 20344341Shibler tios.c_cflag &= 20444341Shibler ~(CSIZE|CSTOPB|CREAD|PARENB|PARODD|HUPCL|CLOCAL); 20555830Shibler switch (htios.c_cflag & TIO_CSIZE) { 20644341Shibler case TIO_CS5: 20744341Shibler tios.c_cflag |= CS5; break; 20844341Shibler case TIO_CS6: 20944341Shibler tios.c_cflag |= CS6; break; 21044341Shibler case TIO_CS7: 21144341Shibler tios.c_cflag |= CS7; break; 21244341Shibler case TIO_CS8: 21344341Shibler tios.c_cflag |= CS8; break; 21441486Smckusick } 21555830Shibler if (htios.c_cflag & TIO_CSTOPB) 21644341Shibler tios.c_cflag |= CSTOPB; 21755830Shibler if (htios.c_cflag & TIO_CREAD) 21844341Shibler tios.c_cflag |= CREAD; 21955830Shibler if (htios.c_cflag & TIO_PARENB) 22044341Shibler tios.c_cflag |= PARENB; 22155830Shibler if (htios.c_cflag & TIO_PARODD) 22244341Shibler tios.c_cflag |= PARODD; 22355830Shibler if (htios.c_cflag & TIO_HUPCL) 22444341Shibler tios.c_cflag |= HUPCL; 22555830Shibler if (htios.c_cflag & TIO_CLOCAL) 22644341Shibler tios.c_cflag |= CLOCAL; 22744341Shibler /* 22844341Shibler * Set lflag. 22944341Shibler * No HP-UX equiv for ECHOKE/ECHOPRT/ECHOCTL 23044341Shibler * IEXTEN treated as part of ICANON 23144341Shibler */ 23244341Shibler tios.c_lflag &= ~(ECHOE|ECHOK|ECHO|ISIG|ICANON|IEXTEN|NOFLSH); 23355830Shibler if (htios.c_lflag & TIO_ECHOE) 23444341Shibler tios.c_lflag |= ECHOE; 23555830Shibler if (htios.c_lflag & TIO_ECHOK) 23644341Shibler tios.c_lflag |= ECHOK; 23755830Shibler if (htios.c_lflag & TIO_ECHO) 23844341Shibler tios.c_lflag |= ECHO; 23955830Shibler if (htios.c_lflag & TIO_ECHONL) 24044341Shibler tios.c_lflag |= ECHONL; 24155830Shibler if (htios.c_lflag & TIO_ISIG) 24244341Shibler tios.c_lflag |= ISIG; 24355830Shibler if (htios.c_lflag & TIO_ICANON) 24444341Shibler tios.c_lflag |= (ICANON|IEXTEN); 24555830Shibler if (htios.c_lflag & TIO_NOFLSH) 24644341Shibler tios.c_lflag |= NOFLSH; 24744341Shibler /* 24844341Shibler * Set editing chars. 24955830Shibler * No HP-UX equivs of VWERASE/VREPRINT/VDSUSP/VLNEXT 25055830Shibler * /VDISCARD/VSTATUS/VERASE2 25144341Shibler */ 25255830Shibler tios.c_cc[VINTR] = htios.c_cc[HPUXVINTR]; 25355830Shibler tios.c_cc[VQUIT] = htios.c_cc[HPUXVQUIT]; 25455830Shibler tios.c_cc[VERASE] = htios.c_cc[HPUXVERASE]; 25555830Shibler tios.c_cc[VKILL] = htios.c_cc[HPUXVKILL]; 25655830Shibler tios.c_cc[VEOF] = htios.c_cc[HPUXVEOF]; 25755830Shibler tios.c_cc[VEOL] = htios.c_cc[HPUXVEOL]; 25855830Shibler tios.c_cc[VEOL2] = htios.c_cc[HPUXVEOL2]; 25955830Shibler tios.c_cc[VMIN] = htios.c_cc[HPUXVMINS]; 26055830Shibler tios.c_cc[VTIME] = htios.c_cc[HPUXVTIMES]; 26155830Shibler tios.c_cc[VSUSP] = htios.c_cc[HPUXVSUSP]; 26255830Shibler tios.c_cc[VSTART] = htios.c_cc[HPUXVSTART]; 26355830Shibler tios.c_cc[VSTOP] = htios.c_cc[HPUXVSTOP]; 26455830Shibler 26544341Shibler /* 26644341Shibler * Set the new stuff 26744341Shibler */ 26855830Shibler if (com == HPUXTCSETA || com == HPUXTCSETATTR) 26944341Shibler com = TIOCSETA; 27055830Shibler else if (com == HPUXTCSETAW || com == HPUXTCSETATTRD) 27144341Shibler com = TIOCSETAW; 27241486Smckusick else 27344341Shibler com = TIOCSETAF; 27448477Skarels error = (*ioctlrout)(fp, com, (caddr_t)&tios, p); 27544341Shibler if (error == 0) { 27644341Shibler /* 27744341Shibler * Set line discipline 27844341Shibler */ 27955830Shibler if (!newi) { 28055830Shibler line = htios.c_reserved; 28155830Shibler (void) (*ioctlrout)(fp, TIOCSETD, 28255830Shibler (caddr_t)&line, p); 28355830Shibler } 28444341Shibler /* 28544341Shibler * Set non-blocking IO if VMIN == VTIME == 0. 28644341Shibler * Should handle the other cases as well. It also 28744341Shibler * isn't correct to just turn it off as it could be 28844341Shibler * on as the result of a fcntl operation. 28944341Shibler * XXX - wouldn't need to do this at all if VMIN/VTIME 29044341Shibler * were implemented. 29144341Shibler */ 29255830Shibler line = (htios.c_cc[HPUXVMIN] == 0 && 29355830Shibler htios.c_cc[HPUXVTIME] == 0); 29448477Skarels if (line) 29549942Smckusick fp->f_flag |= FNONBLOCK; 29648477Skarels else 29749942Smckusick fp->f_flag &= ~FNONBLOCK; 29848477Skarels (void) (*ioctlrout)(fp, FIONBIO, (caddr_t)&line, p); 29944341Shibler } 30041486Smckusick break; 30141486Smckusick 30241486Smckusick default: 30343453Shibler error = EINVAL; 30441486Smckusick break; 30541486Smckusick } 30643453Shibler return(error); 30741486Smckusick } 30841486Smckusick 309*56314Shibler termiototermios(tio, tios, bsdtios) 31055830Shibler struct hpuxtermio *tio; 31155830Shibler struct hpuxtermios *tios; 312*56314Shibler struct termios *bsdtios; 31355830Shibler { 31455830Shibler int i; 31555830Shibler 31655830Shibler bzero((char *)tios, sizeof *tios); 31755830Shibler tios->c_iflag = tio->c_iflag; 31855830Shibler tios->c_oflag = tio->c_oflag; 31955830Shibler tios->c_cflag = tio->c_cflag; 32055830Shibler tios->c_lflag = tio->c_lflag; 32155830Shibler tios->c_reserved = tio->c_line; 32255830Shibler for (i = 0; i <= HPUXVSWTCH; i++) 32355830Shibler tios->c_cc[i] = tio->c_cc[i]; 32455830Shibler if (tios->c_lflag & TIO_ICANON) { 32555830Shibler tios->c_cc[HPUXVEOF] = tio->c_cc[HPUXVEOF]; 32655830Shibler tios->c_cc[HPUXVEOL] = tio->c_cc[HPUXVEOL]; 32755830Shibler tios->c_cc[HPUXVMINS] = tios->c_cc[HPUXVTIMES] = 0; 32855830Shibler } else { 32955830Shibler tios->c_cc[HPUXVEOF] = tios->c_cc[HPUXVEOL] = 0; 33055830Shibler tios->c_cc[HPUXVMINS] = tio->c_cc[HPUXVMIN]; 33155830Shibler tios->c_cc[HPUXVTIMES] = tio->c_cc[HPUXVTIME]; 33255830Shibler } 333*56314Shibler tios->c_cc[HPUXVMINS] = bsdtios->c_cc[VMIN]; 334*56314Shibler tios->c_cc[HPUXVTIMES] = bsdtios->c_cc[VTIME]; 335*56314Shibler tios->c_cc[HPUXVSUSP] = bsdtios->c_cc[VSUSP]; 336*56314Shibler tios->c_cc[HPUXVSTART] = bsdtios->c_cc[VSTART]; 337*56314Shibler tios->c_cc[HPUXVSTOP] = bsdtios->c_cc[VSTOP]; 33855830Shibler } 33955830Shibler 34055830Shibler termiostotermio(tios, tio) 34155830Shibler struct hpuxtermios *tios; 34255830Shibler struct hpuxtermio *tio; 34355830Shibler { 34455830Shibler int i; 34555830Shibler 34655830Shibler tio->c_iflag = tios->c_iflag; 34755830Shibler tio->c_oflag = tios->c_oflag; 34855830Shibler tio->c_cflag = tios->c_cflag; 34955830Shibler tio->c_lflag = tios->c_lflag; 35055830Shibler tio->c_line = tios->c_reserved; 35155830Shibler for (i = 0; i <= HPUXVSWTCH; i++) 35255830Shibler tio->c_cc[i] = tios->c_cc[i]; 353*56314Shibler if (tios->c_lflag & TIO_ICANON) { 35455830Shibler tio->c_cc[HPUXVEOF] = tios->c_cc[HPUXVEOF]; 35555830Shibler tio->c_cc[HPUXVEOL] = tios->c_cc[HPUXVEOL]; 35655830Shibler } else { 35755830Shibler tio->c_cc[HPUXVMIN] = tios->c_cc[HPUXVMINS]; 35855830Shibler tio->c_cc[HPUXVTIME] = tios->c_cc[HPUXVTIMES]; 35955830Shibler } 36055830Shibler } 36155830Shibler 36244341Shibler bsdtohpuxbaud(bsdspeed) 36344341Shibler long bsdspeed; 36444341Shibler { 36544341Shibler switch (bsdspeed) { 36644341Shibler case B0: return(TIO_B0); 36744341Shibler case B50: return(TIO_B50); 36844341Shibler case B75: return(TIO_B75); 36944341Shibler case B110: return(TIO_B110); 37044341Shibler case B134: return(TIO_B134); 37144341Shibler case B150: return(TIO_B150); 37244341Shibler case B200: return(TIO_B200); 37344341Shibler case B300: return(TIO_B300); 37444341Shibler case B600: return(TIO_B600); 37544341Shibler case B1200: return(TIO_B1200); 37644341Shibler case B1800: return(TIO_B1800); 37744341Shibler case B2400: return(TIO_B2400); 37844341Shibler case B4800: return(TIO_B4800); 37944341Shibler case B9600: return(TIO_B9600); 38044341Shibler case B19200: return(TIO_B19200); 38144341Shibler case B38400: return(TIO_B38400); 38244341Shibler default: return(TIO_B0); 38344341Shibler } 38444341Shibler } 38544341Shibler 38644341Shibler hpuxtobsdbaud(hpuxspeed) 38744341Shibler int hpuxspeed; 38844341Shibler { 38944341Shibler static char hpuxtobsdbaudtab[32] = { 39044341Shibler B0, B50, B75, B110, B134, B150, B200, B300, 39144341Shibler B600, B0, B1200, B1800, B2400, B0, B4800, B0, 39244341Shibler B9600, B19200, B38400, B0, B0, B0, B0, B0, 39344341Shibler B0, B0, B0, B0, B0, B0, EXTA, EXTB 39444341Shibler }; 39544341Shibler 39644341Shibler return(hpuxtobsdbaudtab[hpuxspeed & TIO_CBAUD]); 39744341Shibler } 39844341Shibler 39955830Shibler #ifdef COMPAT_OHPUX 40043453Shibler ohpuxgtty(p, uap, retval) 40143453Shibler struct proc *p; 40243453Shibler struct args { 40341486Smckusick int fdes; 40441486Smckusick caddr_t cmarg; 40543453Shibler } *uap; 40643453Shibler int *retval; 40743453Shibler { 40841486Smckusick 40945923Smckusick return (getsettty(p, uap->fdes, HPUXTIOCGETP, uap->cmarg)); 41041486Smckusick } 41141486Smckusick 41243453Shibler ohpuxstty(p, uap, retval) 41343453Shibler struct proc *p; 41443453Shibler struct args { 41541486Smckusick int fdes; 41641486Smckusick caddr_t cmarg; 41743453Shibler } *uap; 41843453Shibler int *retval; 41943453Shibler { 42041486Smckusick 42145923Smckusick return (getsettty(p, uap->fdes, HPUXTIOCSETP, uap->cmarg)); 42241486Smckusick } 42341486Smckusick 42441486Smckusick /* 42541486Smckusick * Simplified version of ioctl() for use by 42641486Smckusick * gtty/stty and TIOCGETP/TIOCSETP. 42741486Smckusick */ 42845923Smckusick getsettty(p, fdes, com, cmarg) 42945923Smckusick struct proc *p; 43041486Smckusick int fdes, com; 43141486Smckusick caddr_t cmarg; 43241486Smckusick { 43345923Smckusick register struct filedesc *fdp = p->p_fd; 43441486Smckusick register struct file *fp; 43541486Smckusick struct hpuxsgttyb hsb; 43641486Smckusick struct sgttyb sb; 43743453Shibler int error; 43841486Smckusick 43948477Skarels if (((unsigned)fdes) >= fdp->fd_nfiles || 44048477Skarels (fp = fdp->fd_ofiles[fdes]) == NULL) 44143453Shibler return (EBADF); 44243453Shibler if ((fp->f_flag & (FREAD|FWRITE)) == 0) 44343453Shibler return (EBADF); 44441486Smckusick if (com == HPUXTIOCSETP) { 44543453Shibler if (error = copyin(cmarg, (caddr_t)&hsb, sizeof hsb)) 44643453Shibler return (error); 44741486Smckusick sb.sg_ispeed = hsb.sg_ispeed; 44841486Smckusick sb.sg_ospeed = hsb.sg_ospeed; 44941486Smckusick sb.sg_erase = hsb.sg_erase; 45041486Smckusick sb.sg_kill = hsb.sg_kill; 45143453Shibler sb.sg_flags = hsb.sg_flags & ~(V7_HUPCL|V7_XTABS|V7_NOAL); 45243453Shibler if (hsb.sg_flags & V7_XTABS) 45343453Shibler sb.sg_flags |= XTABS; 45443453Shibler if (hsb.sg_flags & V7_HUPCL) 45548477Skarels (void)(*fp->f_ops->fo_ioctl) 45648477Skarels (fp, TIOCHPCL, (caddr_t)0, p); 45741486Smckusick com = TIOCSETP; 45841486Smckusick } else { 45941486Smckusick bzero((caddr_t)&hsb, sizeof hsb); 46041486Smckusick com = TIOCGETP; 46141486Smckusick } 46248477Skarels error = (*fp->f_ops->fo_ioctl)(fp, com, (caddr_t)&sb, p); 46343453Shibler if (error == 0 && com == TIOCGETP) { 46441486Smckusick hsb.sg_ispeed = sb.sg_ispeed; 46541486Smckusick hsb.sg_ospeed = sb.sg_ospeed; 46641486Smckusick hsb.sg_erase = sb.sg_erase; 46741486Smckusick hsb.sg_kill = sb.sg_kill; 46843453Shibler hsb.sg_flags = sb.sg_flags & ~(V7_HUPCL|V7_XTABS|V7_NOAL); 46943453Shibler if (sb.sg_flags & XTABS) 47043453Shibler hsb.sg_flags |= V7_XTABS; 47143453Shibler error = copyout((caddr_t)&hsb, cmarg, sizeof hsb); 47241486Smckusick } 47343453Shibler return (error); 47441486Smckusick } 47541486Smckusick #endif 47655830Shibler #endif 477