Deleted Added
full compact
pty.c (53483) pty.c (57070)
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
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 53483 1999-11-21 02:54:54Z jkh $
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;
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;
121};
122
123#define PF_PKT 0x08 /* packet mode */
124#define PF_STOPPED 0x10 /* user told stopped */
125#define PF_REMOTE 0x20 /* remote and flow controlled input */
126#define PF_NOSTOP 0x40
127#define PF_UCNTL 0x80 /* user control mode */
128

--- 36 unchanged lines hidden (view full) ---

165 dev_t dev;
166 int flag, devtype;
167 struct proc *p;
168{
169 register struct tty *tp;
170 int error;
171 int minr;
172 dev_t nextdev;
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;
173
174 /*
175 * XXX: Gross hack for DEVFS:
176 * If we openned this device, ensure we have the
177 * next one too, so people can open it.
178 */
179 minr = lminor(dev);
180 if (minr < 255) {
181 nextdev = makedev(major(dev), minr + 1);
182 if (!nextdev->si_drv1) {
183 ptyinit(minr + 1);
184 }
185 }
186 if (!dev->si_drv1)
187 ptyinit(minor(dev));
188 if (!dev->si_drv1)
189 return(ENXIO);
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;
190 tp = dev->si_tty;
191 if ((tp->t_state & TS_ISOPEN) == 0) {
192 ttychars(tp); /* Set up default chars */
193 tp->t_iflag = TTYDEF_IFLAG;
194 tp->t_oflag = TTYDEF_OFLAG;
195 tp->t_lflag = TTYDEF_LFLAG;
196 tp->t_cflag = TTYDEF_CFLAG;
197 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
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;
198 } else if (tp->t_state & TS_XCLUDE && suser(p))
201 } else if (tp->t_state & TS_XCLUDE && suser(p)) {
199 return (EBUSY);
202 return (EBUSY);
203 } else if (pti->pt_prison != p->p_prison) {
204 return (EBUSY);
205 }
200 if (tp->t_oproc) /* Ctrlr still around. */
201 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
202 while ((tp->t_state & TS_CARR_ON) == 0) {
203 if (flag&FNONBLOCK)
204 break;
205 error = ttysleep(tp, TSA_CARR_ON(tp), TTIPRI | PCATCH,
206 "ptsopn", 0);
207 if (error)

--- 141 unchanged lines hidden (view full) ---

349 tp = dev->si_tty;
350 if (tp->t_oproc)
351 return (EIO);
352 tp->t_oproc = ptsstart;
353 tp->t_stop = ptsstop;
354 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
355 tp->t_lflag &= ~EXTPROC;
356 pti = dev->si_drv1;
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;
357 pti->pt_flags = 0;
358 pti->pt_send = 0;
359 pti->pt_ucntl = 0;
360 return (0);
361}
362
363static int
364ptcclose(dev, flags, fmt, p)

--- 458 unchanged lines hidden ---
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 ---