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 <vfs/devfs/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;
84 static d_clone_t ptyclone;
86 #define CDEV_MAJOR_S 5
87 static struct dev_ops pts_ops = {
88 { "pts", CDEV_MAJOR_S, D_TTY | D_KQFILTER },
95 .d_kqfilter = ttykqfilter,
99 #define CDEV_MAJOR_C 6
100 static struct dev_ops ptc_ops = {
101 { "ptc", CDEV_MAJOR_C, D_TTY | D_KQFILTER | D_MASTER },
108 .d_kqfilter = ttykqfilter,
109 .d_revoke = ttyrevoke
112 #define BUFSIZ 100 /* Chunk size iomoved to/from user */
116 struct selinfo pt_selr, pt_selw;
121 struct prison *pt_prison;
125 #define PF_PKT 0x08 /* packet mode */
126 #define PF_STOPPED 0x10 /* user told stopped */
127 #define PF_REMOTE 0x20 /* remote and flow controlled input */
128 #define PF_NOSTOP 0x40
129 #define PF_UCNTL 0x80 /* user control mode */
132 * This function creates and initializes a pts/ptc pair
134 * pts == /dev/tty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv]
135 * ptc == /dev/pty[pqrsPQRS][0123456789abcdefghijklmnopqrstuv]
137 * XXX: define and add mapping of upper minor bits to allow more
144 char *names = "pqrsPQRS";
147 /* For now we only map the lower 8 bits of the minor */
151 pt = kmalloc(sizeof(*pt), M_PTY, M_WAITOK | M_ZERO);
152 pt->devs = devs = make_dev(&pts_ops, n,
153 0, 0, 0666, "tty%c%r", names[n / 32], n % 32);
154 pt->devc = devc = make_dev(&ptc_ops, n,
155 0, 0, 0666, "pty%c%r", names[n / 32], n % 32);
157 devs->si_drv1 = devc->si_drv1 = pt;
158 devs->si_tty = devc->si_tty = &pt->pt_tty;
159 pt->pt_tty.t_dev = devs;
160 ttyregister(&pt->pt_tty);
164 ptyclone(struct dev_clone_args *ap)
169 unit = devfs_clone_bitmap_get(&DEVFS_CLONE_BITMAP(pty), 256);
174 pt = kmalloc(sizeof(*pt), M_PTY, M_WAITOK | M_ZERO);
176 pt->devc = ap->a_dev = make_only_dev(&ptc_ops, unit, ap->a_cred->cr_ruid, 0, 0600, "ptm/%d", unit);
177 pt->devs = make_dev(&pts_ops, unit, ap->a_cred->cr_ruid, 0, 0600, "pts/%d", unit);
179 //reference_dev(pt->devc);
180 //reference_dev(pt->devs);
182 pt->devs->si_drv1 = pt->devc->si_drv1 = pt;
183 pt->devs->si_tty = pt->devc->si_tty = &pt->pt_tty;
184 pt->pt_tty.t_dev = pt->devs;
185 ttyregister(&pt->pt_tty);
192 ptsopen(struct dev_open_args *ap)
194 cdev_t dev = ap->a_head.a_dev;
201 struct pt_ioctl *pti;
206 * REMOVED gross hack for devfs. also note that makedev()
207 * no longer exists in this form and reference counting makes
208 * this a problem if we don't clean it out later.
211 nextdev = make_sub_dev(dev, minr + 1);
212 if (!nextdev->si_drv1) {
223 if ((tp->t_state & TS_ISOPEN) == 0) {
224 ttychars(tp); /* Set up default chars */
225 tp->t_iflag = TTYDEF_IFLAG;
226 tp->t_oflag = TTYDEF_OFLAG;
227 tp->t_lflag = TTYDEF_LFLAG;
228 tp->t_cflag = TTYDEF_CFLAG;
229 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
230 } else if ((tp->t_state & TS_XCLUDE) && priv_check_cred(ap->a_cred, PRIV_ROOT, 0)) {
232 } else if (pti->pt_prison != ap->a_cred->cr_prison) {
235 if (tp->t_oproc) /* Ctrlr still around. */
236 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
237 while ((tp->t_state & TS_CARR_ON) == 0) {
238 if (ap->a_oflags & FNONBLOCK)
240 error = ttysleep(tp, TSA_CARR_ON(tp), PCATCH, "ptsopn", 0);
244 error = (*linesw[tp->t_line].l_open)(dev, tp);
246 ptcwakeup(tp, FREAD|FWRITE);
249 /* unix98 pty stuff */
250 if ((!error) && (!memcmp(dev->si_name, "pts/", 4))) {
251 ((struct pt_ioctl *)dev->si_drv1)->ref_count++;
252 //reference_dev(dev);
253 //reference_dev(((struct pt_ioctl *)dev->si_drv1)->devc);
254 //devfs_clone_bitmap_set(&DEVFS_CLONE_BITMAP(pts), dev->si_uminor-300);
262 ptsclose(struct dev_close_args *ap)
264 cdev_t dev = ap->a_head.a_dev;
268 /* unix98 pty stuff */
269 if (!memcmp(dev->si_name, "pts/", 4)) {
270 if (--((struct pt_ioctl *)dev->si_drv1)->ref_count == 0) {
271 kfree(dev->si_drv1, M_PTY);
272 devfs_clone_bitmap_put(&DEVFS_CLONE_BITMAP(pty), dev->si_uminor);
278 err = (*linesw[tp->t_line].l_close)(tp, ap->a_fflag);
279 ptsstop(tp, FREAD|FWRITE);
285 ptsread(struct dev_read_args *ap)
287 cdev_t dev = ap->a_head.a_dev;
288 struct proc *p = curproc;
289 struct tty *tp = dev->si_tty;
290 struct pt_ioctl *pti = dev->si_drv1;
295 lp = curthread->td_lwp;
298 if (pti->pt_flags & PF_REMOTE) {
299 while (isbackground(p, tp)) {
300 if (SIGISMEMBER(p->p_sigignore, SIGTTIN) ||
301 SIGISMEMBER(lp->lwp_sigmask, SIGTTIN) ||
302 p->p_pgrp->pg_jobc == 0 || p->p_flag & P_PPWAIT)
304 pgsignal(p->p_pgrp, SIGTTIN, 1);
305 error = ttysleep(tp, &lbolt, PCATCH, "ptsbg", 0);
309 if (tp->t_canq.c_cc == 0) {
310 if (ap->a_ioflag & IO_NDELAY)
311 return (EWOULDBLOCK);
312 error = ttysleep(tp, TSA_PTS_READ(tp), PCATCH,
318 while (tp->t_canq.c_cc > 1 && ap->a_uio->uio_resid > 0)
319 if (ureadc(clist_getc(&tp->t_canq), ap->a_uio) < 0) {
323 if (tp->t_canq.c_cc == 1)
324 clist_getc(&tp->t_canq);
329 error = (*linesw[tp->t_line].l_read)(tp, ap->a_uio, ap->a_ioflag);
330 ptcwakeup(tp, FWRITE);
335 * Write to pseudo-tty.
336 * Wakeups of controlling tty will happen
337 * indirectly, when tty driver calls ptsstart.
340 ptswrite(struct dev_write_args *ap)
342 cdev_t dev = ap->a_head.a_dev;
346 if (tp->t_oproc == 0)
348 return ((*linesw[tp->t_line].l_write)(tp, ap->a_uio, ap->a_ioflag));
352 * Start output on pseudo-tty.
353 * Wake up process selecting or sleeping for input from controlling tty.
356 ptsstart(struct tty *tp)
358 struct pt_ioctl *pti = tp->t_dev->si_drv1;
360 if (tp->t_state & TS_TTSTOP)
362 if (pti->pt_flags & PF_STOPPED) {
363 pti->pt_flags &= ~PF_STOPPED;
364 pti->pt_send = TIOCPKT_START;
366 ptcwakeup(tp, FREAD);
370 ptcwakeup(struct tty *tp, int flag)
372 struct pt_ioctl *pti = tp->t_dev->si_drv1;
375 selwakeup(&pti->pt_selr);
376 wakeup(TSA_PTC_READ(tp));
379 selwakeup(&pti->pt_selw);
380 wakeup(TSA_PTC_WRITE(tp));
385 ptcopen(struct dev_open_args *ap)
387 cdev_t dev = ap->a_head.a_dev;
389 struct pt_ioctl *pti;
398 tp->t_oproc = ptsstart;
399 tp->t_stop = ptsstop;
400 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
401 tp->t_lflag &= ~EXTPROC;
403 pti->pt_prison = ap->a_cred->cr_prison;
407 pti->devs->si_uid = ap->a_cred->cr_uid;
412 ptcclose(struct dev_close_args *ap)
414 cdev_t dev = ap->a_head.a_dev;
418 (void)(*linesw[tp->t_line].l_modem)(tp, 0);
421 * XXX MDMBUF makes no sense for ptys but would inhibit the above
422 * l_modem(). CLOCAL makes sense but isn't supported. Special
423 * l_modem()s that ignore carrier drop make no sense for ptys but
424 * may be in use because other parts of the line discipline make
425 * sense for ptys. Recover by doing everything that a normal
426 * ttymodem() would have done except for sending a SIGHUP.
428 if (tp->t_state & TS_ISOPEN) {
429 tp->t_state &= ~(TS_CARR_ON | TS_CONNECTED);
430 tp->t_state |= TS_ZOMBIE;
431 ttyflush(tp, FREAD | FWRITE);
432 tp->t_dev->si_uid = 0;
435 tp->t_oproc = 0; /* mark closed */
437 if (!memcmp(dev->si_name, "ptm/", 4)) {
438 ((struct pt_ioctl *)dev->si_drv1)->devc = NULL;
439 if (--((struct pt_ioctl *)dev->si_drv1)->ref_count == 0) {
440 kfree(dev->si_drv1, M_PTY);
441 devfs_clone_bitmap_put(&DEVFS_CLONE_BITMAP(pty), dev->si_uminor);
444 //release_dev(((struct pt_ioctl *)dev->si_drv1)->devs);
451 ptcread(struct dev_read_args *ap)
453 cdev_t dev = ap->a_head.a_dev;
454 struct tty *tp = dev->si_tty;
455 struct pt_ioctl *pti = dev->si_drv1;
460 * We want to block until the slave
461 * is open, and there's something to read;
462 * but if we lost the slave or we're NBIO,
463 * then return the appropriate error instead.
466 if (tp->t_state&TS_ISOPEN) {
467 if (pti->pt_flags&PF_PKT && pti->pt_send) {
468 error = ureadc((int)pti->pt_send, ap->a_uio);
471 if (pti->pt_send & TIOCPKT_IOCTL) {
472 cc = min(ap->a_uio->uio_resid,
473 sizeof(tp->t_termios));
474 uiomove((caddr_t)&tp->t_termios, cc,
480 if (pti->pt_flags&PF_UCNTL && pti->pt_ucntl) {
481 error = ureadc((int)pti->pt_ucntl, ap->a_uio);
487 if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
490 if ((tp->t_state & TS_CONNECTED) == 0)
491 return (0); /* EOF */
492 if (ap->a_ioflag & IO_NDELAY)
493 return (EWOULDBLOCK);
494 error = tsleep(TSA_PTC_READ(tp), PCATCH, "ptcin", 0);
498 if (pti->pt_flags & (PF_PKT|PF_UCNTL))
499 error = ureadc(0, ap->a_uio);
500 while (ap->a_uio->uio_resid > 0 && error == 0) {
501 cc = q_to_b(&tp->t_outq, buf, min(ap->a_uio->uio_resid, BUFSIZ));
504 error = uiomove(buf, cc, ap->a_uio);
511 ptsstop(struct tty *tp, int flush)
513 struct pt_ioctl *pti = tp->t_dev->si_drv1;
516 /* note: FLUSHREAD and FLUSHWRITE already ok */
518 flush = TIOCPKT_STOP;
519 pti->pt_flags |= PF_STOPPED;
521 pti->pt_flags &= ~PF_STOPPED;
522 pti->pt_send |= flush;
523 /* change of perspective */
533 ptcpoll(struct dev_poll_args *ap)
535 cdev_t dev = ap->a_head.a_dev;
536 struct tty *tp = dev->si_tty;
537 struct pt_ioctl *pti = dev->si_drv1;
540 if ((tp->t_state & TS_CONNECTED) == 0) {
541 ap->a_events = seltrue(dev, ap->a_events) | POLLHUP;
546 * Need to block timeouts (ttrstart).
550 if (ap->a_events & (POLLIN | POLLRDNORM))
551 if ((tp->t_state & TS_ISOPEN) &&
552 ((tp->t_outq.c_cc && (tp->t_state & TS_TTSTOP) == 0) ||
553 ((pti->pt_flags & PF_PKT) && pti->pt_send) ||
554 ((pti->pt_flags & PF_UCNTL) && pti->pt_ucntl)))
555 revents |= ap->a_events & (POLLIN | POLLRDNORM);
557 if (ap->a_events & (POLLOUT | POLLWRNORM))
558 if (tp->t_state & TS_ISOPEN &&
559 ((pti->pt_flags & PF_REMOTE) ?
560 (tp->t_canq.c_cc == 0) :
561 ((tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG - 2) ||
562 (tp->t_canq.c_cc == 0 && (tp->t_lflag & ICANON)))))
563 revents |= ap->a_events & (POLLOUT | POLLWRNORM);
565 if (ap->a_events & POLLHUP)
566 if ((tp->t_state & TS_CARR_ON) == 0)
570 if (ap->a_events & (POLLIN | POLLRDNORM))
571 selrecord(curthread, &pti->pt_selr);
573 if (ap->a_events & (POLLOUT | POLLWRNORM))
574 selrecord(curthread, &pti->pt_selw);
578 ap->a_events = revents;
583 ptcwrite(struct dev_write_args *ap)
585 cdev_t dev = ap->a_head.a_dev;
586 struct tty *tp = dev->si_tty;
589 u_char locbuf[BUFSIZ];
591 struct pt_ioctl *pti = dev->si_drv1;
595 if ((tp->t_state&TS_ISOPEN) == 0)
597 if (pti->pt_flags & PF_REMOTE) {
600 while ((ap->a_uio->uio_resid > 0 || cc > 0) &&
601 tp->t_canq.c_cc < TTYHOG - 1) {
603 cc = min(ap->a_uio->uio_resid, BUFSIZ);
604 cc = min(cc, TTYHOG - 1 - tp->t_canq.c_cc);
606 error = uiomove((caddr_t)cp, cc, ap->a_uio);
609 /* check again for safety */
610 if ((tp->t_state & TS_ISOPEN) == 0) {
611 /* adjust as usual */
612 ap->a_uio->uio_resid += cc;
617 cc = b_to_q((char *)cp, cc, &tp->t_canq);
619 * XXX we don't guarantee that the canq size
620 * is >= TTYHOG, so the above b_to_q() may
621 * leave some bytes uncopied. However, space
622 * is guaranteed for the null terminator if
623 * we don't fail here since (TTYHOG - 1) is
624 * not a multiple of CBSIZE.
630 /* adjust for data copied in but not written */
631 ap->a_uio->uio_resid += cc;
632 clist_putc(0, &tp->t_canq);
634 wakeup(TSA_PTS_READ(tp));
637 while (ap->a_uio->uio_resid > 0 || cc > 0) {
639 cc = min(ap->a_uio->uio_resid, BUFSIZ);
641 error = uiomove((caddr_t)cp, cc, ap->a_uio);
644 /* check again for safety */
645 if ((tp->t_state & TS_ISOPEN) == 0) {
646 /* adjust for data copied in but not written */
647 ap->a_uio->uio_resid += cc;
652 if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 &&
653 (tp->t_canq.c_cc > 0 || !(tp->t_lflag&ICANON))) {
654 wakeup(TSA_HUP_OR_INPUT(tp));
657 (*linesw[tp->t_line].l_rint)(*cp++, tp);
666 * Come here to wait for slave to open, for space
667 * in outq, or space in rawq, or an empty canq.
669 if ((tp->t_state & TS_CONNECTED) == 0) {
670 /* adjust for data copied in but not written */
671 ap->a_uio->uio_resid += cc;
674 if (ap->a_ioflag & IO_NDELAY) {
675 /* adjust for data copied in but not written */
676 ap->a_uio->uio_resid += cc;
678 return (EWOULDBLOCK);
681 error = tsleep(TSA_PTC_WRITE(tp), PCATCH, "ptcout", 0);
683 /* adjust for data copied in but not written */
684 ap->a_uio->uio_resid += cc;
692 ptyioctl(struct dev_ioctl_args *ap)
694 cdev_t dev = ap->a_head.a_dev;
695 struct tty *tp = dev->si_tty;
696 struct pt_ioctl *pti = dev->si_drv1;
697 u_char *cc = tp->t_cc;
700 if (dev_dflags(dev) & D_MASTER) {
705 * We avoid calling ttioctl on the controller since,
706 * in that case, tp must be the controlling terminal.
708 *(int *)ap->a_data = tp->t_pgrp ? tp->t_pgrp->pg_id : 0;
712 if (*(int *)ap->a_data) {
713 if (pti->pt_flags & PF_UCNTL)
715 pti->pt_flags |= PF_PKT;
717 pti->pt_flags &= ~PF_PKT;
721 if (*(int *)ap->a_data) {
722 if (pti->pt_flags & PF_PKT)
724 pti->pt_flags |= PF_UCNTL;
726 pti->pt_flags &= ~PF_UCNTL;
730 if (*(int *)ap->a_data)
731 pti->pt_flags |= PF_REMOTE;
733 pti->pt_flags &= ~PF_REMOTE;
734 ttyflush(tp, FREAD|FWRITE);
739 * The rest of the ioctls shouldn't be called until
742 if ((tp->t_state & TS_ISOPEN) == 0)
755 * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
756 * ttywflush(tp) will hang if there are characters in
759 ndflush(&tp->t_outq, tp->t_outq.c_cc);
763 if (*(unsigned int *)ap->a_data >= NSIG ||
764 *(unsigned int *)ap->a_data == 0)
766 if ((tp->t_lflag&NOFLSH) == 0)
767 ttyflush(tp, FREAD|FWRITE);
768 pgsignal(tp->t_pgrp, *(unsigned int *)ap->a_data, 1);
769 if ((*(unsigned int *)ap->a_data == SIGINFO) &&
770 ((tp->t_lflag&NOKERNINFO) == 0))
775 if (ap->a_cmd == TIOCEXT) {
777 * When the EXTPROC bit is being toggled, we need
778 * to send an TIOCPKT_IOCTL if the packet driver
781 if (*(int *)ap->a_data) {
782 if (pti->pt_flags & PF_PKT) {
783 pti->pt_send |= TIOCPKT_IOCTL;
784 ptcwakeup(tp, FREAD);
786 tp->t_lflag |= EXTPROC;
788 if ((tp->t_lflag & EXTPROC) &&
789 (pti->pt_flags & PF_PKT)) {
790 pti->pt_send |= TIOCPKT_IOCTL;
791 ptcwakeup(tp, FREAD);
793 tp->t_lflag &= ~EXTPROC;
797 error = (*linesw[tp->t_line].l_ioctl)(tp, ap->a_cmd, ap->a_data,
798 ap->a_fflag, ap->a_cred);
799 if (error == ENOIOCTL)
800 error = ttioctl(tp, ap->a_cmd, ap->a_data, ap->a_fflag);
801 if (error == ENOIOCTL) {
802 if (pti->pt_flags & PF_UCNTL &&
803 (ap->a_cmd & ~0xff) == UIOCCMD(0)) {
804 if (ap->a_cmd & 0xff) {
805 pti->pt_ucntl = (u_char)ap->a_cmd;
806 ptcwakeup(tp, FREAD);
813 * If external processing and packet mode send ioctl packet.
815 if ((tp->t_lflag&EXTPROC) && (pti->pt_flags & PF_PKT)) {
824 #if defined(COMPAT_43) || defined(COMPAT_SUNOS)
831 pti->pt_send |= TIOCPKT_IOCTL;
832 ptcwakeup(tp, FREAD);
837 stop = (tp->t_iflag & IXON) && CCEQ(cc[VSTOP], CTRL('s'))
838 && CCEQ(cc[VSTART], CTRL('q'));
839 if (pti->pt_flags & PF_NOSTOP) {
841 pti->pt_send &= ~TIOCPKT_NOSTOP;
842 pti->pt_send |= TIOCPKT_DOSTOP;
843 pti->pt_flags &= ~PF_NOSTOP;
844 ptcwakeup(tp, FREAD);
848 pti->pt_send &= ~TIOCPKT_DOSTOP;
849 pti->pt_send |= TIOCPKT_NOSTOP;
850 pti->pt_flags |= PF_NOSTOP;
851 ptcwakeup(tp, FREAD);
858 static void ptc_drvinit (void *unused);
861 ptc_drvinit(void *unused)
865 devfs_clone_bitmap_init(&DEVFS_CLONE_BITMAP(pty));
866 devfs_clone_bitmap_init(&DEVFS_CLONE_BITMAP(pts));
869 /* Unix98 pty stuff, leave out for now */
870 make_dev(&ptc_ops, 0, 0, 0, 0666, "ptmx");
871 devfs_clone_handler_add("ptmx", ptyclone);
873 for (i = 0; i < 256; i++) {
878 SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR_C,ptc_drvinit,NULL)