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 = (int)szmin(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,
508 (int)szmin(ap->a_uio->uio_resid, BUFSIZ));
511 error = uiomove(buf, (size_t)cc, ap->a_uio);
518 ptsstop(struct tty *tp, int flush)
520 struct pt_ioctl *pti = tp->t_dev->si_drv1;
523 /* note: FLUSHREAD and FLUSHWRITE already ok */
525 flush = TIOCPKT_STOP;
526 pti->pt_flags |= PF_STOPPED;
528 pti->pt_flags &= ~PF_STOPPED;
529 pti->pt_send |= flush;
530 /* change of perspective */
540 ptcpoll(struct dev_poll_args *ap)
542 cdev_t dev = ap->a_head.a_dev;
543 struct tty *tp = dev->si_tty;
544 struct pt_ioctl *pti = dev->si_drv1;
547 if ((tp->t_state & TS_CONNECTED) == 0) {
548 ap->a_events = seltrue(dev, ap->a_events) | POLLHUP;
553 * Need to block timeouts (ttrstart).
557 if (ap->a_events & (POLLIN | POLLRDNORM))
558 if ((tp->t_state & TS_ISOPEN) &&
559 ((tp->t_outq.c_cc && (tp->t_state & TS_TTSTOP) == 0) ||
560 ((pti->pt_flags & PF_PKT) && pti->pt_send) ||
561 ((pti->pt_flags & PF_UCNTL) && pti->pt_ucntl)))
562 revents |= ap->a_events & (POLLIN | POLLRDNORM);
564 if (ap->a_events & (POLLOUT | POLLWRNORM))
565 if (tp->t_state & TS_ISOPEN &&
566 ((pti->pt_flags & PF_REMOTE) ?
567 (tp->t_canq.c_cc == 0) :
568 ((tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG - 2) ||
569 (tp->t_canq.c_cc == 0 && (tp->t_lflag & ICANON)))))
570 revents |= ap->a_events & (POLLOUT | POLLWRNORM);
572 if (ap->a_events & POLLHUP)
573 if ((tp->t_state & TS_CARR_ON) == 0)
577 if (ap->a_events & (POLLIN | POLLRDNORM))
578 selrecord(curthread, &pti->pt_selr);
580 if (ap->a_events & (POLLOUT | POLLWRNORM))
581 selrecord(curthread, &pti->pt_selw);
585 ap->a_events = revents;
590 ptcwrite(struct dev_write_args *ap)
592 cdev_t dev = ap->a_head.a_dev;
593 struct tty *tp = dev->si_tty;
596 u_char locbuf[BUFSIZ];
598 struct pt_ioctl *pti = dev->si_drv1;
602 if ((tp->t_state&TS_ISOPEN) == 0)
604 if (pti->pt_flags & PF_REMOTE) {
607 while ((ap->a_uio->uio_resid > 0 || cc > 0) &&
608 tp->t_canq.c_cc < TTYHOG - 1) {
610 cc = (int)szmin(ap->a_uio->uio_resid, BUFSIZ);
611 cc = imin(cc, TTYHOG - 1 - tp->t_canq.c_cc);
613 error = uiomove(cp, (size_t)cc, ap->a_uio);
616 /* check again for safety */
617 if ((tp->t_state & TS_ISOPEN) == 0) {
618 /* adjust as usual */
619 ap->a_uio->uio_resid += cc;
624 cc = b_to_q((char *)cp, cc, &tp->t_canq);
626 * XXX we don't guarantee that the canq size
627 * is >= TTYHOG, so the above b_to_q() may
628 * leave some bytes uncopied. However, space
629 * is guaranteed for the null terminator if
630 * we don't fail here since (TTYHOG - 1) is
631 * not a multiple of CBSIZE.
637 /* adjust for data copied in but not written */
638 ap->a_uio->uio_resid += cc;
639 clist_putc(0, &tp->t_canq);
641 wakeup(TSA_PTS_READ(tp));
644 while (ap->a_uio->uio_resid > 0 || cc > 0) {
646 cc = (int)szmin(ap->a_uio->uio_resid, BUFSIZ);
648 error = uiomove(cp, (size_t)cc, ap->a_uio);
651 /* check again for safety */
652 if ((tp->t_state & TS_ISOPEN) == 0) {
653 /* adjust for data copied in but not written */
654 ap->a_uio->uio_resid += cc;
659 if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 &&
660 (tp->t_canq.c_cc > 0 || !(tp->t_lflag&ICANON))) {
661 wakeup(TSA_HUP_OR_INPUT(tp));
664 (*linesw[tp->t_line].l_rint)(*cp++, tp);
673 * Come here to wait for slave to open, for space
674 * in outq, or space in rawq, or an empty canq.
676 if ((tp->t_state & TS_CONNECTED) == 0) {
677 /* adjust for data copied in but not written */
678 ap->a_uio->uio_resid += cc;
681 if (ap->a_ioflag & IO_NDELAY) {
682 /* adjust for data copied in but not written */
683 ap->a_uio->uio_resid += cc;
685 return (EWOULDBLOCK);
688 error = tsleep(TSA_PTC_WRITE(tp), PCATCH, "ptcout", 0);
690 /* adjust for data copied in but not written */
691 ap->a_uio->uio_resid += cc;
699 ptyioctl(struct dev_ioctl_args *ap)
701 cdev_t dev = ap->a_head.a_dev;
702 struct tty *tp = dev->si_tty;
703 struct pt_ioctl *pti = dev->si_drv1;
704 u_char *cc = tp->t_cc;
707 if (dev_dflags(dev) & D_MASTER) {
712 * We avoid calling ttioctl on the controller since,
713 * in that case, tp must be the controlling terminal.
715 *(int *)ap->a_data = tp->t_pgrp ? tp->t_pgrp->pg_id : 0;
719 if (*(int *)ap->a_data) {
720 if (pti->pt_flags & PF_UCNTL)
722 pti->pt_flags |= PF_PKT;
724 pti->pt_flags &= ~PF_PKT;
728 if (*(int *)ap->a_data) {
729 if (pti->pt_flags & PF_PKT)
731 pti->pt_flags |= PF_UCNTL;
733 pti->pt_flags &= ~PF_UCNTL;
737 if (*(int *)ap->a_data)
738 pti->pt_flags |= PF_REMOTE;
740 pti->pt_flags &= ~PF_REMOTE;
741 ttyflush(tp, FREAD|FWRITE);
746 * The rest of the ioctls shouldn't be called until
749 if ((tp->t_state & TS_ISOPEN) == 0)
762 * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
763 * ttywflush(tp) will hang if there are characters in
766 ndflush(&tp->t_outq, tp->t_outq.c_cc);
770 if (*(unsigned int *)ap->a_data >= NSIG ||
771 *(unsigned int *)ap->a_data == 0)
773 if ((tp->t_lflag&NOFLSH) == 0)
774 ttyflush(tp, FREAD|FWRITE);
775 pgsignal(tp->t_pgrp, *(unsigned int *)ap->a_data, 1);
776 if ((*(unsigned int *)ap->a_data == SIGINFO) &&
777 ((tp->t_lflag&NOKERNINFO) == 0))
782 if (ap->a_cmd == TIOCEXT) {
784 * When the EXTPROC bit is being toggled, we need
785 * to send an TIOCPKT_IOCTL if the packet driver
788 if (*(int *)ap->a_data) {
789 if (pti->pt_flags & PF_PKT) {
790 pti->pt_send |= TIOCPKT_IOCTL;
791 ptcwakeup(tp, FREAD);
793 tp->t_lflag |= EXTPROC;
795 if ((tp->t_lflag & EXTPROC) &&
796 (pti->pt_flags & PF_PKT)) {
797 pti->pt_send |= TIOCPKT_IOCTL;
798 ptcwakeup(tp, FREAD);
800 tp->t_lflag &= ~EXTPROC;
804 error = (*linesw[tp->t_line].l_ioctl)(tp, ap->a_cmd, ap->a_data,
805 ap->a_fflag, ap->a_cred);
806 if (error == ENOIOCTL)
807 error = ttioctl(tp, ap->a_cmd, ap->a_data, ap->a_fflag);
808 if (error == ENOIOCTL) {
809 if (pti->pt_flags & PF_UCNTL &&
810 (ap->a_cmd & ~0xff) == UIOCCMD(0)) {
811 if (ap->a_cmd & 0xff) {
812 pti->pt_ucntl = (u_char)ap->a_cmd;
813 ptcwakeup(tp, FREAD);
820 * If external processing and packet mode send ioctl packet.
822 if ((tp->t_lflag&EXTPROC) && (pti->pt_flags & PF_PKT)) {
831 #if defined(COMPAT_43) || defined(COMPAT_SUNOS)
838 pti->pt_send |= TIOCPKT_IOCTL;
839 ptcwakeup(tp, FREAD);
844 stop = (tp->t_iflag & IXON) && CCEQ(cc[VSTOP], CTRL('s'))
845 && CCEQ(cc[VSTART], CTRL('q'));
846 if (pti->pt_flags & PF_NOSTOP) {
848 pti->pt_send &= ~TIOCPKT_NOSTOP;
849 pti->pt_send |= TIOCPKT_DOSTOP;
850 pti->pt_flags &= ~PF_NOSTOP;
851 ptcwakeup(tp, FREAD);
855 pti->pt_send &= ~TIOCPKT_DOSTOP;
856 pti->pt_send |= TIOCPKT_NOSTOP;
857 pti->pt_flags |= PF_NOSTOP;
858 ptcwakeup(tp, FREAD);
865 static void ptc_drvinit (void *unused);
868 ptc_drvinit(void *unused)
872 devfs_clone_bitmap_init(&DEVFS_CLONE_BITMAP(pty));
873 devfs_clone_bitmap_init(&DEVFS_CLONE_BITMAP(pts));
876 /* Unix98 pty stuff, leave out for now */
877 make_dev(&ptc_ops, 0, 0, 0, 0666, "ptmx");
878 devfs_clone_handler_add("ptmx", ptyclone);
880 for (i = 0; i < 256; i++) {
885 SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR_C,ptc_drvinit,NULL)