2 * Copyright (c) 1982, 1986, 1989, 1993
3 * The Regents of the University of California. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by the University of
16 * California, Berkeley and its contributors.
17 * 4. Neither the name of the University nor the names of its contributors
18 * may be used to endorse or promote products derived from this software
19 * without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
22 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
23 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
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
33 * @(#)tty_pty.c 8.4 (Berkeley) 2/20/95
34 * $FreeBSD: src/sys/kern/tty_pty.c,v 1.74.2.4 2002/02/20 19:58:13 dillon Exp $
35 * $DragonFly: src/sys/kern/tty_pty.c,v 1.21 2008/08/13 10:29:38 swildner Exp $
39 * Pseudo-teletype Driver
40 * (Actually two drivers, requiring two dev_ops structures)
42 #include "use_pty.h" /* XXX */
43 #include "opt_compat.h"
45 #include <sys/param.h>
46 #include <sys/systm.h>
47 #if defined(COMPAT_43) || defined(COMPAT_SUNOS)
48 #include <sys/ioctl_compat.h>
54 #include <sys/fcntl.h>
56 #include <sys/kernel.h>
57 #include <sys/vnode.h>
58 #include <sys/signalvar.h>
59 #include <sys/malloc.h>
60 #include <sys/device.h>
61 #include <sys/thread2.h>
62 #include <sys/devfs.h>
64 DEVFS_DECLARE_CLONE_BITMAP(pty);
65 DEVFS_DECLARE_CLONE_BITMAP(pts);
67 MALLOC_DEFINE(M_PTY, "ptys", "pty data structures");
69 static void ptsstart (struct tty *tp);
70 static void ptsstop (struct tty *tp, int rw);
71 static void ptcwakeup (struct tty *tp, int flag);
72 static void ptyinit (int n);
74 static d_open_t ptsopen;
75 static d_close_t ptsclose;
76 static d_read_t ptsread;
77 static d_write_t ptswrite;
78 static d_ioctl_t ptyioctl;
79 static d_open_t ptcopen;
80 static d_close_t ptcclose;
81 static d_read_t ptcread;
82 static d_write_t ptcwrite;
83 static d_poll_t ptcpoll;
85 static d_clone_t ptyclone;
88 #define CDEV_MAJOR_S 5
89 static struct dev_ops pts_ops = {
90 { "pts", CDEV_MAJOR_S, D_TTY | D_KQFILTER },
97 .d_kqfilter = ttykqfilter,
101 #define CDEV_MAJOR_C 6
102 static struct dev_ops ptc_ops = {
103 { "ptc", CDEV_MAJOR_C, D_TTY | D_KQFILTER | D_MASTER },
110 .d_kqfilter = ttykqfilter,
111 .d_revoke = ttyrevoke
114 #define BUFSIZ 100 /* Chunk size iomoved to/from user */
118 struct selinfo pt_selr, pt_selw;
123 struct prison *pt_prison;
127 #define PF_PKT 0x08 /* packet mode */
128 #define PF_STOPPED 0x10 /* user told stopped */
129 #define PF_REMOTE 0x20 /* remote and flow controlled input */
130 #define PF_NOSTOP 0x40
131 #define PF_UCNTL 0x80 /* user control mode */
134 * This function creates and initializes a pts/ptc pair
136 * pts == /dev/tty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv]
137 * ptc == /dev/pty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv]
139 * XXX: define and add mapping of upper minor bits to allow more
146 char *names = "pqrsPQRS";
149 /* For now we only map the lower 8 bits of the minor */
153 pt = kmalloc(sizeof(*pt), M_PTY, M_WAITOK | M_ZERO);
154 pt->devs = devs = make_dev(&pts_ops, n,
155 0, 0, 0666, "tty%c%r", names[n / 32], n % 32);
156 pt->devc = devc = make_dev(&ptc_ops, n,
157 0, 0, 0666, "pty%c%r", names[n / 32], n % 32);
159 devs->si_drv1 = devc->si_drv1 = pt;
160 devs->si_tty = devc->si_tty = &pt->pt_tty;
161 devs->si_flags |= SI_OVERRIDE; /* uid, gid, perms from dev */
162 devc->si_flags |= SI_OVERRIDE; /* uid, gid, perms from dev */
163 pt->pt_tty.t_dev = devs;
164 ttyregister(&pt->pt_tty);
169 ptyclone(struct dev_clone_args *ap)
174 unit = devfs_clone_bitmap_get(&DEVFS_CLONE_BITMAP(pty), 256);
179 pt = kmalloc(sizeof(*pt), M_PTY, M_WAITOK | M_ZERO);
181 pt->devc = ap->a_dev = make_only_dev(&ptc_ops, unit, ap->a_cred->cr_ruid, 0, 0600, "ptm/%d", unit);
182 pt->devs = make_dev(&pts_ops, unit, ap->a_cred->cr_ruid, 0, 0600, "pts/%d", unit);
184 //reference_dev(pt->devc);
185 //reference_dev(pt->devs);
187 pt->devs->si_drv1 = pt->devc->si_drv1 = pt;
188 pt->devs->si_tty = pt->devc->si_tty = &pt->pt_tty;
189 pt->pt_tty.t_dev = pt->devs;
190 ttyregister(&pt->pt_tty);
198 ptsopen(struct dev_open_args *ap)
200 cdev_t dev = ap->a_head.a_dev;
203 struct pt_ioctl *pti;
211 if ((tp->t_state & TS_ISOPEN) == 0) {
212 ttychars(tp); /* Set up default chars */
213 tp->t_iflag = TTYDEF_IFLAG;
214 tp->t_oflag = TTYDEF_OFLAG;
215 tp->t_lflag = TTYDEF_LFLAG;
216 tp->t_cflag = TTYDEF_CFLAG;
217 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
218 } else if ((tp->t_state & TS_XCLUDE) && priv_check_cred(ap->a_cred, PRIV_ROOT, 0)) {
220 } else if (pti->pt_prison != ap->a_cred->cr_prison) {
223 if (tp->t_oproc) /* Ctrlr still around. */
224 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
225 while ((tp->t_state & TS_CARR_ON) == 0) {
226 if (ap->a_oflags & FNONBLOCK)
228 error = ttysleep(tp, TSA_CARR_ON(tp), PCATCH, "ptsopn", 0);
232 error = (*linesw[tp->t_line].l_open)(dev, tp);
234 ptcwakeup(tp, FREAD|FWRITE);
237 /* unix98 pty stuff */
238 if ((!error) && (!memcmp(dev->si_name, "pts/", 4))) {
239 ((struct pt_ioctl *)dev->si_drv1)->ref_count++;
240 //reference_dev(dev);
241 //reference_dev(((struct pt_ioctl *)dev->si_drv1)->devc);
242 //devfs_clone_bitmap_set(&DEVFS_CLONE_BITMAP(pts), dev->si_uminor-300);
250 ptsclose(struct dev_close_args *ap)
252 cdev_t dev = ap->a_head.a_dev;
256 /* unix98 pty stuff */
257 if (!memcmp(dev->si_name, "pts/", 4)) {
258 if (--((struct pt_ioctl *)dev->si_drv1)->ref_count == 0) {
259 kfree(dev->si_drv1, M_PTY);
260 devfs_clone_bitmap_put(&DEVFS_CLONE_BITMAP(pty), dev->si_uminor);
266 err = (*linesw[tp->t_line].l_close)(tp, ap->a_fflag);
267 ptsstop(tp, FREAD|FWRITE);
273 ptsread(struct dev_read_args *ap)
275 cdev_t dev = ap->a_head.a_dev;
276 struct proc *p = curproc;
277 struct tty *tp = dev->si_tty;
278 struct pt_ioctl *pti = dev->si_drv1;
283 lp = curthread->td_lwp;
286 if (pti->pt_flags & PF_REMOTE) {
287 while (isbackground(p, tp)) {
288 if (SIGISMEMBER(p->p_sigignore, SIGTTIN) ||
289 SIGISMEMBER(lp->lwp_sigmask, SIGTTIN) ||
290 p->p_pgrp->pg_jobc == 0 || p->p_flag & P_PPWAIT)
292 pgsignal(p->p_pgrp, SIGTTIN, 1);
293 error = ttysleep(tp, &lbolt, PCATCH, "ptsbg", 0);
297 if (tp->t_canq.c_cc == 0) {
298 if (ap->a_ioflag & IO_NDELAY)
299 return (EWOULDBLOCK);
300 error = ttysleep(tp, TSA_PTS_READ(tp), PCATCH,
306 while (tp->t_canq.c_cc > 1 && ap->a_uio->uio_resid > 0)
307 if (ureadc(clist_getc(&tp->t_canq), ap->a_uio) < 0) {
311 if (tp->t_canq.c_cc == 1)
312 clist_getc(&tp->t_canq);
317 error = (*linesw[tp->t_line].l_read)(tp, ap->a_uio, ap->a_ioflag);
318 ptcwakeup(tp, FWRITE);
323 * Write to pseudo-tty.
324 * Wakeups of controlling tty will happen
325 * indirectly, when tty driver calls ptsstart.
328 ptswrite(struct dev_write_args *ap)
330 cdev_t dev = ap->a_head.a_dev;
334 if (tp->t_oproc == 0)
336 return ((*linesw[tp->t_line].l_write)(tp, ap->a_uio, ap->a_ioflag));
340 * Start output on pseudo-tty.
341 * Wake up process selecting or sleeping for input from controlling tty.
344 ptsstart(struct tty *tp)
346 struct pt_ioctl *pti = tp->t_dev->si_drv1;
348 if (tp->t_state & TS_TTSTOP)
350 if (pti->pt_flags & PF_STOPPED) {
351 pti->pt_flags &= ~PF_STOPPED;
352 pti->pt_send = TIOCPKT_START;
354 ptcwakeup(tp, FREAD);
358 ptcwakeup(struct tty *tp, int flag)
360 struct pt_ioctl *pti = tp->t_dev->si_drv1;
363 selwakeup(&pti->pt_selr);
364 wakeup(TSA_PTC_READ(tp));
367 selwakeup(&pti->pt_selw);
368 wakeup(TSA_PTC_WRITE(tp));
373 ptcopen(struct dev_open_args *ap)
375 cdev_t dev = ap->a_head.a_dev;
377 struct pt_ioctl *pti;
384 if (pti->pt_prison && pti->pt_prison != ap->a_cred->cr_prison)
389 tp->t_oproc = ptsstart;
390 tp->t_stop = ptsstop;
391 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
392 tp->t_lflag &= ~EXTPROC;
393 pti->pt_prison = ap->a_cred->cr_prison;
398 pti->devs->si_uid = ap->a_cred->cr_uid;
399 pti->devs->si_gid = 0;
400 pti->devs->si_perms = 0600;
401 pti->devc->si_uid = ap->a_cred->cr_uid;
402 pti->devc->si_gid = 0;
403 pti->devc->si_perms = 0600;
409 ptcclose(struct dev_close_args *ap)
411 cdev_t dev = ap->a_head.a_dev;
413 struct pt_ioctl *pti;
416 (void)(*linesw[tp->t_line].l_modem)(tp, 0);
419 * XXX MDMBUF makes no sense for ptys but would inhibit the above
420 * l_modem(). CLOCAL makes sense but isn't supported. Special
421 * l_modem()s that ignore carrier drop make no sense for ptys but
422 * may be in use because other parts of the line discipline make
423 * sense for ptys. Recover by doing everything that a normal
424 * ttymodem() would have done except for sending a SIGHUP.
426 if (tp->t_state & TS_ISOPEN) {
427 tp->t_state &= ~(TS_CARR_ON | TS_CONNECTED);
428 tp->t_state |= TS_ZOMBIE;
429 ttyflush(tp, FREAD | FWRITE);
431 tp->t_oproc = 0; /* mark closed */
434 pti->pt_prison = NULL;
435 pti->devs->si_uid = 0;
436 pti->devs->si_gid = 0;
437 pti->devs->si_perms = 0666;
438 pti->devc->si_uid = 0;
439 pti->devc->si_gid = 0;
440 pti->devc->si_perms = 0666;
443 if (!memcmp(dev->si_name, "ptm/", 4)) {
444 ((struct pt_ioctl *)dev->si_drv1)->devc = NULL;
445 if (--((struct pt_ioctl *)dev->si_drv1)->ref_count == 0) {
446 kfree(dev->si_drv1, M_PTY);
447 devfs_clone_bitmap_put(&DEVFS_CLONE_BITMAP(pty), dev->si_uminor);
450 //release_dev(((struct pt_ioctl *)dev->si_drv1)->devs);
457 ptcread(struct dev_read_args *ap)
459 cdev_t dev = ap->a_head.a_dev;
460 struct tty *tp = dev->si_tty;
461 struct pt_ioctl *pti = dev->si_drv1;
466 * We want to block until the slave
467 * is open, and there's something to read;
468 * but if we lost the slave or we're NBIO,
469 * then return the appropriate error instead.
472 if (tp->t_state&TS_ISOPEN) {
473 if (pti->pt_flags&PF_PKT && pti->pt_send) {
474 error = ureadc((int)pti->pt_send, ap->a_uio);
477 if (pti->pt_send & TIOCPKT_IOCTL) {
478 cc = min(ap->a_uio->uio_resid,
479 sizeof(tp->t_termios));
480 uiomove((caddr_t)&tp->t_termios, cc,
486 if (pti->pt_flags&PF_UCNTL && pti->pt_ucntl) {
487 error = ureadc((int)pti->pt_ucntl, ap->a_uio);
493 if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
496 if ((tp->t_state & TS_CONNECTED) == 0)
497 return (0); /* EOF */
498 if (ap->a_ioflag & IO_NDELAY)
499 return (EWOULDBLOCK);
500 error = tsleep(TSA_PTC_READ(tp), PCATCH, "ptcin", 0);
504 if (pti->pt_flags & (PF_PKT|PF_UCNTL))
505 error = ureadc(0, ap->a_uio);
506 while (ap->a_uio->uio_resid > 0 && error == 0) {
507 cc = q_to_b(&tp->t_outq, buf, min(ap->a_uio->uio_resid, BUFSIZ));
510 error = uiomove(buf, cc, ap->a_uio);
517 ptsstop(struct tty *tp, int flush)
519 struct pt_ioctl *pti = tp->t_dev->si_drv1;
522 /* note: FLUSHREAD and FLUSHWRITE already ok */
524 flush = TIOCPKT_STOP;
525 pti->pt_flags |= PF_STOPPED;
527 pti->pt_flags &= ~PF_STOPPED;
528 pti->pt_send |= flush;
529 /* change of perspective */
539 ptcpoll(struct dev_poll_args *ap)
541 cdev_t dev = ap->a_head.a_dev;
542 struct tty *tp = dev->si_tty;
543 struct pt_ioctl *pti = dev->si_drv1;
546 if ((tp->t_state & TS_CONNECTED) == 0) {
547 ap->a_events = seltrue(dev, ap->a_events) | POLLHUP;
552 * Need to block timeouts (ttrstart).
556 if (ap->a_events & (POLLIN | POLLRDNORM))
557 if ((tp->t_state & TS_ISOPEN) &&
558 ((tp->t_outq.c_cc && (tp->t_state & TS_TTSTOP) == 0) ||
559 ((pti->pt_flags & PF_PKT) && pti->pt_send) ||
560 ((pti->pt_flags & PF_UCNTL) && pti->pt_ucntl)))
561 revents |= ap->a_events & (POLLIN | POLLRDNORM);
563 if (ap->a_events & (POLLOUT | POLLWRNORM))
564 if (tp->t_state & TS_ISOPEN &&
565 ((pti->pt_flags & PF_REMOTE) ?
566 (tp->t_canq.c_cc == 0) :
567 ((tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG - 2) ||
568 (tp->t_canq.c_cc == 0 && (tp->t_lflag & ICANON)))))
569 revents |= ap->a_events & (POLLOUT | POLLWRNORM);
571 if (ap->a_events & POLLHUP)
572 if ((tp->t_state & TS_CARR_ON) == 0)
576 if (ap->a_events & (POLLIN | POLLRDNORM))
577 selrecord(curthread, &pti->pt_selr);
579 if (ap->a_events & (POLLOUT | POLLWRNORM))
580 selrecord(curthread, &pti->pt_selw);
584 ap->a_events = revents;
589 ptcwrite(struct dev_write_args *ap)
591 cdev_t dev = ap->a_head.a_dev;
592 struct tty *tp = dev->si_tty;
595 u_char locbuf[BUFSIZ];
597 struct pt_ioctl *pti = dev->si_drv1;
601 if ((tp->t_state&TS_ISOPEN) == 0)
603 if (pti->pt_flags & PF_REMOTE) {
606 while ((ap->a_uio->uio_resid > 0 || cc > 0) &&
607 tp->t_canq.c_cc < TTYHOG - 1) {
609 cc = min(ap->a_uio->uio_resid, BUFSIZ);
610 cc = min(cc, TTYHOG - 1 - tp->t_canq.c_cc);
612 error = uiomove((caddr_t)cp, cc, ap->a_uio);
615 /* check again for safety */
616 if ((tp->t_state & TS_ISOPEN) == 0) {
617 /* adjust as usual */
618 ap->a_uio->uio_resid += cc;
623 cc = b_to_q((char *)cp, cc, &tp->t_canq);
625 * XXX we don't guarantee that the canq size
626 * is >= TTYHOG, so the above b_to_q() may
627 * leave some bytes uncopied. However, space
628 * is guaranteed for the null terminator if
629 * we don't fail here since (TTYHOG - 1) is
630 * not a multiple of CBSIZE.
636 /* adjust for data copied in but not written */
637 ap->a_uio->uio_resid += cc;
638 clist_putc(0, &tp->t_canq);
640 wakeup(TSA_PTS_READ(tp));
643 while (ap->a_uio->uio_resid > 0 || cc > 0) {
645 cc = min(ap->a_uio->uio_resid, BUFSIZ);
647 error = uiomove((caddr_t)cp, cc, ap->a_uio);
650 /* check again for safety */
651 if ((tp->t_state & TS_ISOPEN) == 0) {
652 /* adjust for data copied in but not written */
653 ap->a_uio->uio_resid += cc;
658 if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 &&
659 (tp->t_canq.c_cc > 0 || !(tp->t_lflag&ICANON))) {
660 wakeup(TSA_HUP_OR_INPUT(tp));
663 (*linesw[tp->t_line].l_rint)(*cp++, tp);
672 * Come here to wait for slave to open, for space
673 * in outq, or space in rawq, or an empty canq.
675 if ((tp->t_state & TS_CONNECTED) == 0) {
676 /* adjust for data copied in but not written */
677 ap->a_uio->uio_resid += cc;
680 if (ap->a_ioflag & IO_NDELAY) {
681 /* adjust for data copied in but not written */
682 ap->a_uio->uio_resid += cc;
684 return (EWOULDBLOCK);
687 error = tsleep(TSA_PTC_WRITE(tp), PCATCH, "ptcout", 0);
689 /* adjust for data copied in but not written */
690 ap->a_uio->uio_resid += cc;
698 ptyioctl(struct dev_ioctl_args *ap)
700 cdev_t dev = ap->a_head.a_dev;
701 struct tty *tp = dev->si_tty;
702 struct pt_ioctl *pti = dev->si_drv1;
703 u_char *cc = tp->t_cc;
706 if (dev_dflags(dev) & D_MASTER) {
711 * We avoid calling ttioctl on the controller since,
712 * in that case, tp must be the controlling terminal.
714 *(int *)ap->a_data = tp->t_pgrp ? tp->t_pgrp->pg_id : 0;
718 if (*(int *)ap->a_data) {
719 if (pti->pt_flags & PF_UCNTL)
721 pti->pt_flags |= PF_PKT;
723 pti->pt_flags &= ~PF_PKT;
727 if (*(int *)ap->a_data) {
728 if (pti->pt_flags & PF_PKT)
730 pti->pt_flags |= PF_UCNTL;
732 pti->pt_flags &= ~PF_UCNTL;
736 if (*(int *)ap->a_data)
737 pti->pt_flags |= PF_REMOTE;
739 pti->pt_flags &= ~PF_REMOTE;
740 ttyflush(tp, FREAD|FWRITE);
745 * The rest of the ioctls shouldn't be called until
748 if ((tp->t_state & TS_ISOPEN) == 0)
761 * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
762 * ttywflush(tp) will hang if there are characters in
765 ndflush(&tp->t_outq, tp->t_outq.c_cc);
769 if (*(unsigned int *)ap->a_data >= NSIG ||
770 *(unsigned int *)ap->a_data == 0)
772 if ((tp->t_lflag&NOFLSH) == 0)
773 ttyflush(tp, FREAD|FWRITE);
774 pgsignal(tp->t_pgrp, *(unsigned int *)ap->a_data, 1);
775 if ((*(unsigned int *)ap->a_data == SIGINFO) &&
776 ((tp->t_lflag&NOKERNINFO) == 0))
781 if (ap->a_cmd == TIOCEXT) {
783 * When the EXTPROC bit is being toggled, we need
784 * to send an TIOCPKT_IOCTL if the packet driver
787 if (*(int *)ap->a_data) {
788 if (pti->pt_flags & PF_PKT) {
789 pti->pt_send |= TIOCPKT_IOCTL;
790 ptcwakeup(tp, FREAD);
792 tp->t_lflag |= EXTPROC;
794 if ((tp->t_lflag & EXTPROC) &&
795 (pti->pt_flags & PF_PKT)) {
796 pti->pt_send |= TIOCPKT_IOCTL;
797 ptcwakeup(tp, FREAD);
799 tp->t_lflag &= ~EXTPROC;
803 error = (*linesw[tp->t_line].l_ioctl)(tp, ap->a_cmd, ap->a_data,
804 ap->a_fflag, ap->a_cred);
805 if (error == ENOIOCTL)
806 error = ttioctl(tp, ap->a_cmd, ap->a_data, ap->a_fflag);
807 if (error == ENOIOCTL) {
808 if (pti->pt_flags & PF_UCNTL &&
809 (ap->a_cmd & ~0xff) == UIOCCMD(0)) {
810 if (ap->a_cmd & 0xff) {
811 pti->pt_ucntl = (u_char)ap->a_cmd;
812 ptcwakeup(tp, FREAD);
819 * If external processing and packet mode send ioctl packet.
821 if ((tp->t_lflag&EXTPROC) && (pti->pt_flags & PF_PKT)) {
830 #if defined(COMPAT_43) || defined(COMPAT_SUNOS)
837 pti->pt_send |= TIOCPKT_IOCTL;
838 ptcwakeup(tp, FREAD);
843 stop = (tp->t_iflag & IXON) && CCEQ(cc[VSTOP], CTRL('s'))
844 && CCEQ(cc[VSTART], CTRL('q'));
845 if (pti->pt_flags & PF_NOSTOP) {
847 pti->pt_send &= ~TIOCPKT_NOSTOP;
848 pti->pt_send |= TIOCPKT_DOSTOP;
849 pti->pt_flags &= ~PF_NOSTOP;
850 ptcwakeup(tp, FREAD);
854 pti->pt_send &= ~TIOCPKT_DOSTOP;
855 pti->pt_send |= TIOCPKT_NOSTOP;
856 pti->pt_flags |= PF_NOSTOP;
857 ptcwakeup(tp, FREAD);
864 static void ptc_drvinit (void *unused);
867 ptc_drvinit(void *unused)
871 devfs_clone_bitmap_init(&DEVFS_CLONE_BITMAP(pty));
872 devfs_clone_bitmap_init(&DEVFS_CLONE_BITMAP(pts));
875 /* Unix98 pty stuff, leave out for now */
876 make_dev(&ptc_ops, 0, 0, 0, 0666, "ptmx");
877 devfs_clone_handler_add("ptmx", ptyclone);
879 for (i = 0; i < 256; i++) {
884 SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR_C,ptc_drvinit,NULL)