1/* 2 * Copyright (c) 1982, 1986, 1989, 1993 3 * The Regents of the University of California. All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 1. Redistributions of source code must retain the above copyright --- 17 unchanged lines hidden (view full) --- 26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 31 * SUCH DAMAGE. 32 * 33 * @(#)tty_pty.c 8.4 (Berkeley) 2/20/95 |
34 * $FreeBSD: head/sys/kern/tty_pty.c 57070 2000-02-09 03:32:11Z rwatson $ |
35 */ 36 37/* 38 * Pseudo-teletype Driver 39 * (Actually two drivers, requiring two entries in 'cdevsw') 40 */ 41#include "pty.h" /* XXX */ 42#include "opt_compat.h" --- 70 unchanged lines hidden (view full) --- 113 114struct pt_ioctl { 115 int pt_flags; 116 struct selinfo pt_selr, pt_selw; 117 u_char pt_send; 118 u_char pt_ucntl; 119 struct tty pt_tty; 120 dev_t devs, devc; |
121 struct prison *pt_prison; |
122}; 123 124#define PF_PKT 0x08 /* packet mode */ 125#define PF_STOPPED 0x10 /* user told stopped */ 126#define PF_REMOTE 0x20 /* remote and flow controlled input */ 127#define PF_NOSTOP 0x40 128#define PF_UCNTL 0x80 /* user control mode */ 129 --- 36 unchanged lines hidden (view full) --- 166 dev_t dev; 167 int flag, devtype; 168 struct proc *p; 169{ 170 register struct tty *tp; 171 int error; 172 int minr; 173 dev_t nextdev; |
174 struct pt_ioctl *pti; |
175 176 /* 177 * XXX: Gross hack for DEVFS: 178 * If we openned this device, ensure we have the 179 * next one too, so people can open it. 180 */ 181 minr = lminor(dev); 182 if (minr < 255) { 183 nextdev = makedev(major(dev), minr + 1); 184 if (!nextdev->si_drv1) { 185 ptyinit(minr + 1); 186 } 187 } 188 if (!dev->si_drv1) 189 ptyinit(minor(dev)); 190 if (!dev->si_drv1) 191 return(ENXIO); |
192 pti = dev->si_drv1; |
193 tp = dev->si_tty; 194 if ((tp->t_state & TS_ISOPEN) == 0) { 195 ttychars(tp); /* Set up default chars */ 196 tp->t_iflag = TTYDEF_IFLAG; 197 tp->t_oflag = TTYDEF_OFLAG; 198 tp->t_lflag = TTYDEF_LFLAG; 199 tp->t_cflag = TTYDEF_CFLAG; 200 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED; |
201 } else if (tp->t_state & TS_XCLUDE && suser(p)) { |
202 return (EBUSY); |
203 } else if (pti->pt_prison != p->p_prison) { 204 return (EBUSY); 205 } |
206 if (tp->t_oproc) /* Ctrlr still around. */ 207 (void)(*linesw[tp->t_line].l_modem)(tp, 1); 208 while ((tp->t_state & TS_CARR_ON) == 0) { 209 if (flag&FNONBLOCK) 210 break; 211 error = ttysleep(tp, TSA_CARR_ON(tp), TTIPRI | PCATCH, 212 "ptsopn", 0); 213 if (error) --- 141 unchanged lines hidden (view full) --- 355 tp = dev->si_tty; 356 if (tp->t_oproc) 357 return (EIO); 358 tp->t_oproc = ptsstart; 359 tp->t_stop = ptsstop; 360 (void)(*linesw[tp->t_line].l_modem)(tp, 1); 361 tp->t_lflag &= ~EXTPROC; 362 pti = dev->si_drv1; |
363 pti->pt_prison = p->p_prison; |
364 pti->pt_flags = 0; 365 pti->pt_send = 0; 366 pti->pt_ucntl = 0; 367 return (0); 368} 369 370static int 371ptcclose(dev, flags, fmt, p) --- 458 unchanged lines hidden --- |