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
--- 16 unchanged lines hidden (view full) ---
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)tty_pty.c 8.4 (Berkeley) 2/20/95
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/tty_pty.c 139205 2004-12-22 17:37:14Z phk $");
34
35/*
36 * Pseudo-teletype Driver
37 * (Actually two drivers, requiring two entries in 'cdevsw')
38 */
39#include "opt_compat.h"
40#include "opt_tty.h"
41#include <sys/param.h>
--- 7 unchanged lines hidden (view full) ---
49#endif
50#endif
51#include <sys/proc.h>
52#include <sys/tty.h>
53#include <sys/conf.h>
54#include <sys/fcntl.h>
55#include <sys/poll.h>
56#include <sys/kernel.h>
57#include <sys/uio.h>
58#include <sys/signalvar.h>
59#include <sys/malloc.h>
60
61static MALLOC_DEFINE(M_PTY, "ptys", "pty data structures");
62
63static void ptsstart(struct tty *tp);
64static void ptsstop(struct tty *tp, int rw);
65static void ptcwakeup(struct tty *tp, int flag);
--- 290 unchanged lines hidden (view full) ---
356 pt->pt_ucntl = 0;
357 return (0);
358 }
359 if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
360 break;
361 }
362 if ((tp->t_state & TS_CONNECTED) == 0)
363 return (0); /* EOF */
364 if (flag & O_NONBLOCK)
365 return (EWOULDBLOCK);
366 error = tsleep(TSA_PTC_READ(tp), TTIPRI | PCATCH, "ptcin", 0);
367 if (error)
368 return (error);
369 }
370 if (pt->pt_flags & (PF_PKT|PF_UCNTL))
371 error = ureadc(0, uio);
372 while (uio->uio_resid > 0 && error == 0) {
--- 119 unchanged lines hidden (view full) ---
492 * Come here to wait for slave to open, for space
493 * in outq, or space in rawq, or an empty canq.
494 */
495 if ((tp->t_state & TS_CONNECTED) == 0) {
496 /* adjust for data copied in but not written */
497 uio->uio_resid += cc;
498 return (EIO);
499 }
500 if (flag & O_NONBLOCK) {
501 /* adjust for data copied in but not written */
502 uio->uio_resid += cc;
503 if (cnt == 0)
504 return (EWOULDBLOCK);
505 return (0);
506 }
507 error = tsleep(TSA_PTC_WRITE(tp), TTOPRI | PCATCH, "ptcout", 0);
508 if (error) {
--- 220 unchanged lines hidden ---
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
--- 16 unchanged lines hidden (view full) ---
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
27 * SUCH DAMAGE.
28 *
29 * @(#)tty_pty.c 8.4 (Berkeley) 2/20/95
30 */
31
32#include <sys/cdefs.h>
33__FBSDID("$FreeBSD: head/sys/kern/tty_pty.c 139205 2004-12-22 17:37:14Z phk $");
34
35/*
36 * Pseudo-teletype Driver
37 * (Actually two drivers, requiring two entries in 'cdevsw')
38 */
39#include "opt_compat.h"
40#include "opt_tty.h"
41#include <sys/param.h>
--- 7 unchanged lines hidden (view full) ---
49#endif
50#endif
51#include <sys/proc.h>
52#include <sys/tty.h>
53#include <sys/conf.h>
54#include <sys/fcntl.h>
55#include <sys/poll.h>
56#include <sys/kernel.h>
57#include <sys/uio.h>
58#include <sys/signalvar.h>
59#include <sys/malloc.h>
60
61static MALLOC_DEFINE(M_PTY, "ptys", "pty data structures");
62
63static void ptsstart(struct tty *tp);
64static void ptsstop(struct tty *tp, int rw);
65static void ptcwakeup(struct tty *tp, int flag);
--- 290 unchanged lines hidden (view full) ---
356 pt->pt_ucntl = 0;
357 return (0);
358 }
359 if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
360 break;
361 }
362 if ((tp->t_state & TS_CONNECTED) == 0)
363 return (0); /* EOF */
364 if (flag & O_NONBLOCK)
365 return (EWOULDBLOCK);
366 error = tsleep(TSA_PTC_READ(tp), TTIPRI | PCATCH, "ptcin", 0);
367 if (error)
368 return (error);
369 }
370 if (pt->pt_flags & (PF_PKT|PF_UCNTL))
371 error = ureadc(0, uio);
372 while (uio->uio_resid > 0 && error == 0) {
--- 119 unchanged lines hidden (view full) ---
492 * Come here to wait for slave to open, for space
493 * in outq, or space in rawq, or an empty canq.
494 */
495 if ((tp->t_state & TS_CONNECTED) == 0) {
496 /* adjust for data copied in but not written */
497 uio->uio_resid += cc;
498 return (EIO);
499 }
500 if (flag & O_NONBLOCK) {
501 /* adjust for data copied in but not written */
502 uio->uio_resid += cc;
503 if (cnt == 0)
504 return (EWOULDBLOCK);
505 return (0);
506 }
507 error = tsleep(TSA_PTC_WRITE(tp), TTOPRI | PCATCH, "ptcout", 0);
508 if (error) {
--- 220 unchanged lines hidden ---