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;
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 pt->pt_tty.t_dev = devs;
162 ttyregister(&pt->pt_tty);
167 ptyclone(struct dev_clone_args *ap)
172 unit = devfs_clone_bitmap_get(&DEVFS_CLONE_BITMAP(pty), 256);
177 pt = kmalloc(sizeof(*pt), M_PTY, M_WAITOK | M_ZERO);
179 pt->devc = ap->a_dev = make_only_dev(&ptc_ops, unit, ap->a_cred->cr_ruid, 0, 0600, "ptm/%d", unit);
180 pt->devs = make_dev(&pts_ops, unit, ap->a_cred->cr_ruid, 0, 0600, "pts/%d", unit);
182 //reference_dev(pt->devc);
183 //reference_dev(pt->devs);
185 pt->devs->si_drv1 = pt->devc->si_drv1 = pt;
186 pt->devs->si_tty = pt->devc->si_tty = &pt->pt_tty;
187 pt->pt_tty.t_dev = pt->devs;
188 ttyregister(&pt->pt_tty);
196 ptsopen(struct dev_open_args *ap)
198 cdev_t dev = ap->a_head.a_dev;
201 struct pt_ioctl *pti;
209 if ((tp->t_state & TS_ISOPEN) == 0) {
210 ttychars(tp); /* Set up default chars */
211 tp->t_iflag = TTYDEF_IFLAG;
212 tp->t_oflag = TTYDEF_OFLAG;
213 tp->t_lflag = TTYDEF_LFLAG;
214 tp->t_cflag = TTYDEF_CFLAG;
215 tp->t_ispeed = tp->t_ospeed = TTYDEF_SPEED;
216 } else if ((tp->t_state & TS_XCLUDE) && priv_check_cred(ap->a_cred, PRIV_ROOT, 0)) {
218 } else if (pti->pt_prison != ap->a_cred->cr_prison) {
221 if (tp->t_oproc) /* Ctrlr still around. */
222 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
223 while ((tp->t_state & TS_CARR_ON) == 0) {
224 if (ap->a_oflags & FNONBLOCK)
226 error = ttysleep(tp, TSA_CARR_ON(tp), PCATCH, "ptsopn", 0);
230 error = (*linesw[tp->t_line].l_open)(dev, tp);
232 ptcwakeup(tp, FREAD|FWRITE);
235 /* unix98 pty stuff */
236 if ((!error) && (!memcmp(dev->si_name, "pts/", 4))) {
237 ((struct pt_ioctl *)dev->si_drv1)->ref_count++;
238 //reference_dev(dev);
239 //reference_dev(((struct pt_ioctl *)dev->si_drv1)->devc);
240 //devfs_clone_bitmap_set(&DEVFS_CLONE_BITMAP(pts), dev->si_uminor-300);
248 ptsclose(struct dev_close_args *ap)
250 cdev_t dev = ap->a_head.a_dev;
254 /* unix98 pty stuff */
255 if (!memcmp(dev->si_name, "pts/", 4)) {
256 if (--((struct pt_ioctl *)dev->si_drv1)->ref_count == 0) {
257 kfree(dev->si_drv1, M_PTY);
258 devfs_clone_bitmap_put(&DEVFS_CLONE_BITMAP(pty), dev->si_uminor);
264 err = (*linesw[tp->t_line].l_close)(tp, ap->a_fflag);
265 ptsstop(tp, FREAD|FWRITE);
271 ptsread(struct dev_read_args *ap)
273 cdev_t dev = ap->a_head.a_dev;
274 struct proc *p = curproc;
275 struct tty *tp = dev->si_tty;
276 struct pt_ioctl *pti = dev->si_drv1;
281 lp = curthread->td_lwp;
284 if (pti->pt_flags & PF_REMOTE) {
285 while (isbackground(p, tp)) {
286 if (SIGISMEMBER(p->p_sigignore, SIGTTIN) ||
287 SIGISMEMBER(lp->lwp_sigmask, SIGTTIN) ||
288 p->p_pgrp->pg_jobc == 0 || p->p_flag & P_PPWAIT)
290 pgsignal(p->p_pgrp, SIGTTIN, 1);
291 error = ttysleep(tp, &lbolt, PCATCH, "ptsbg", 0);
295 if (tp->t_canq.c_cc == 0) {
296 if (ap->a_ioflag & IO_NDELAY)
297 return (EWOULDBLOCK);
298 error = ttysleep(tp, TSA_PTS_READ(tp), PCATCH,
304 while (tp->t_canq.c_cc > 1 && ap->a_uio->uio_resid > 0)
305 if (ureadc(clist_getc(&tp->t_canq), ap->a_uio) < 0) {
309 if (tp->t_canq.c_cc == 1)
310 clist_getc(&tp->t_canq);
315 error = (*linesw[tp->t_line].l_read)(tp, ap->a_uio, ap->a_ioflag);
316 ptcwakeup(tp, FWRITE);
321 * Write to pseudo-tty.
322 * Wakeups of controlling tty will happen
323 * indirectly, when tty driver calls ptsstart.
326 ptswrite(struct dev_write_args *ap)
328 cdev_t dev = ap->a_head.a_dev;
332 if (tp->t_oproc == 0)
334 return ((*linesw[tp->t_line].l_write)(tp, ap->a_uio, ap->a_ioflag));
338 * Start output on pseudo-tty.
339 * Wake up process selecting or sleeping for input from controlling tty.
342 ptsstart(struct tty *tp)
344 struct pt_ioctl *pti = tp->t_dev->si_drv1;
346 if (tp->t_state & TS_TTSTOP)
348 if (pti->pt_flags & PF_STOPPED) {
349 pti->pt_flags &= ~PF_STOPPED;
350 pti->pt_send = TIOCPKT_START;
352 ptcwakeup(tp, FREAD);
356 ptcwakeup(struct tty *tp, int flag)
358 struct pt_ioctl *pti = tp->t_dev->si_drv1;
361 selwakeup(&pti->pt_selr);
362 wakeup(TSA_PTC_READ(tp));
365 selwakeup(&pti->pt_selw);
366 wakeup(TSA_PTC_WRITE(tp));
371 ptcopen(struct dev_open_args *ap)
373 cdev_t dev = ap->a_head.a_dev;
375 struct pt_ioctl *pti;
384 tp->t_oproc = ptsstart;
385 tp->t_stop = ptsstop;
386 (void)(*linesw[tp->t_line].l_modem)(tp, 1);
387 tp->t_lflag &= ~EXTPROC;
389 pti->pt_prison = ap->a_cred->cr_prison;
393 pti->devs->si_uid = ap->a_cred->cr_uid;
398 ptcclose(struct dev_close_args *ap)
400 cdev_t dev = ap->a_head.a_dev;
404 (void)(*linesw[tp->t_line].l_modem)(tp, 0);
407 * XXX MDMBUF makes no sense for ptys but would inhibit the above
408 * l_modem(). CLOCAL makes sense but isn't supported. Special
409 * l_modem()s that ignore carrier drop make no sense for ptys but
410 * may be in use because other parts of the line discipline make
411 * sense for ptys. Recover by doing everything that a normal
412 * ttymodem() would have done except for sending a SIGHUP.
414 if (tp->t_state & TS_ISOPEN) {
415 tp->t_state &= ~(TS_CARR_ON | TS_CONNECTED);
416 tp->t_state |= TS_ZOMBIE;
417 ttyflush(tp, FREAD | FWRITE);
418 tp->t_dev->si_uid = 0;
421 tp->t_oproc = 0; /* mark closed */
423 if (!memcmp(dev->si_name, "ptm/", 4)) {
424 ((struct pt_ioctl *)dev->si_drv1)->devc = NULL;
425 if (--((struct pt_ioctl *)dev->si_drv1)->ref_count == 0) {
426 kfree(dev->si_drv1, M_PTY);
427 devfs_clone_bitmap_put(&DEVFS_CLONE_BITMAP(pty), dev->si_uminor);
430 //release_dev(((struct pt_ioctl *)dev->si_drv1)->devs);
437 ptcread(struct dev_read_args *ap)
439 cdev_t dev = ap->a_head.a_dev;
440 struct tty *tp = dev->si_tty;
441 struct pt_ioctl *pti = dev->si_drv1;
446 * We want to block until the slave
447 * is open, and there's something to read;
448 * but if we lost the slave or we're NBIO,
449 * then return the appropriate error instead.
452 if (tp->t_state&TS_ISOPEN) {
453 if (pti->pt_flags&PF_PKT && pti->pt_send) {
454 error = ureadc((int)pti->pt_send, ap->a_uio);
457 if (pti->pt_send & TIOCPKT_IOCTL) {
458 cc = min(ap->a_uio->uio_resid,
459 sizeof(tp->t_termios));
460 uiomove((caddr_t)&tp->t_termios, cc,
466 if (pti->pt_flags&PF_UCNTL && pti->pt_ucntl) {
467 error = ureadc((int)pti->pt_ucntl, ap->a_uio);
473 if (tp->t_outq.c_cc && (tp->t_state&TS_TTSTOP) == 0)
476 if ((tp->t_state & TS_CONNECTED) == 0)
477 return (0); /* EOF */
478 if (ap->a_ioflag & IO_NDELAY)
479 return (EWOULDBLOCK);
480 error = tsleep(TSA_PTC_READ(tp), PCATCH, "ptcin", 0);
484 if (pti->pt_flags & (PF_PKT|PF_UCNTL))
485 error = ureadc(0, ap->a_uio);
486 while (ap->a_uio->uio_resid > 0 && error == 0) {
487 cc = q_to_b(&tp->t_outq, buf, min(ap->a_uio->uio_resid, BUFSIZ));
490 error = uiomove(buf, cc, ap->a_uio);
497 ptsstop(struct tty *tp, int flush)
499 struct pt_ioctl *pti = tp->t_dev->si_drv1;
502 /* note: FLUSHREAD and FLUSHWRITE already ok */
504 flush = TIOCPKT_STOP;
505 pti->pt_flags |= PF_STOPPED;
507 pti->pt_flags &= ~PF_STOPPED;
508 pti->pt_send |= flush;
509 /* change of perspective */
519 ptcpoll(struct dev_poll_args *ap)
521 cdev_t dev = ap->a_head.a_dev;
522 struct tty *tp = dev->si_tty;
523 struct pt_ioctl *pti = dev->si_drv1;
526 if ((tp->t_state & TS_CONNECTED) == 0) {
527 ap->a_events = seltrue(dev, ap->a_events) | POLLHUP;
532 * Need to block timeouts (ttrstart).
536 if (ap->a_events & (POLLIN | POLLRDNORM))
537 if ((tp->t_state & TS_ISOPEN) &&
538 ((tp->t_outq.c_cc && (tp->t_state & TS_TTSTOP) == 0) ||
539 ((pti->pt_flags & PF_PKT) && pti->pt_send) ||
540 ((pti->pt_flags & PF_UCNTL) && pti->pt_ucntl)))
541 revents |= ap->a_events & (POLLIN | POLLRDNORM);
543 if (ap->a_events & (POLLOUT | POLLWRNORM))
544 if (tp->t_state & TS_ISOPEN &&
545 ((pti->pt_flags & PF_REMOTE) ?
546 (tp->t_canq.c_cc == 0) :
547 ((tp->t_rawq.c_cc + tp->t_canq.c_cc < TTYHOG - 2) ||
548 (tp->t_canq.c_cc == 0 && (tp->t_lflag & ICANON)))))
549 revents |= ap->a_events & (POLLOUT | POLLWRNORM);
551 if (ap->a_events & POLLHUP)
552 if ((tp->t_state & TS_CARR_ON) == 0)
556 if (ap->a_events & (POLLIN | POLLRDNORM))
557 selrecord(curthread, &pti->pt_selr);
559 if (ap->a_events & (POLLOUT | POLLWRNORM))
560 selrecord(curthread, &pti->pt_selw);
564 ap->a_events = revents;
569 ptcwrite(struct dev_write_args *ap)
571 cdev_t dev = ap->a_head.a_dev;
572 struct tty *tp = dev->si_tty;
575 u_char locbuf[BUFSIZ];
577 struct pt_ioctl *pti = dev->si_drv1;
581 if ((tp->t_state&TS_ISOPEN) == 0)
583 if (pti->pt_flags & PF_REMOTE) {
586 while ((ap->a_uio->uio_resid > 0 || cc > 0) &&
587 tp->t_canq.c_cc < TTYHOG - 1) {
589 cc = min(ap->a_uio->uio_resid, BUFSIZ);
590 cc = min(cc, TTYHOG - 1 - tp->t_canq.c_cc);
592 error = uiomove((caddr_t)cp, cc, ap->a_uio);
595 /* check again for safety */
596 if ((tp->t_state & TS_ISOPEN) == 0) {
597 /* adjust as usual */
598 ap->a_uio->uio_resid += cc;
603 cc = b_to_q((char *)cp, cc, &tp->t_canq);
605 * XXX we don't guarantee that the canq size
606 * is >= TTYHOG, so the above b_to_q() may
607 * leave some bytes uncopied. However, space
608 * is guaranteed for the null terminator if
609 * we don't fail here since (TTYHOG - 1) is
610 * not a multiple of CBSIZE.
616 /* adjust for data copied in but not written */
617 ap->a_uio->uio_resid += cc;
618 clist_putc(0, &tp->t_canq);
620 wakeup(TSA_PTS_READ(tp));
623 while (ap->a_uio->uio_resid > 0 || cc > 0) {
625 cc = min(ap->a_uio->uio_resid, BUFSIZ);
627 error = uiomove((caddr_t)cp, cc, ap->a_uio);
630 /* check again for safety */
631 if ((tp->t_state & TS_ISOPEN) == 0) {
632 /* adjust for data copied in but not written */
633 ap->a_uio->uio_resid += cc;
638 if ((tp->t_rawq.c_cc + tp->t_canq.c_cc) >= TTYHOG - 2 &&
639 (tp->t_canq.c_cc > 0 || !(tp->t_lflag&ICANON))) {
640 wakeup(TSA_HUP_OR_INPUT(tp));
643 (*linesw[tp->t_line].l_rint)(*cp++, tp);
652 * Come here to wait for slave to open, for space
653 * in outq, or space in rawq, or an empty canq.
655 if ((tp->t_state & TS_CONNECTED) == 0) {
656 /* adjust for data copied in but not written */
657 ap->a_uio->uio_resid += cc;
660 if (ap->a_ioflag & IO_NDELAY) {
661 /* adjust for data copied in but not written */
662 ap->a_uio->uio_resid += cc;
664 return (EWOULDBLOCK);
667 error = tsleep(TSA_PTC_WRITE(tp), PCATCH, "ptcout", 0);
669 /* adjust for data copied in but not written */
670 ap->a_uio->uio_resid += cc;
678 ptyioctl(struct dev_ioctl_args *ap)
680 cdev_t dev = ap->a_head.a_dev;
681 struct tty *tp = dev->si_tty;
682 struct pt_ioctl *pti = dev->si_drv1;
683 u_char *cc = tp->t_cc;
686 if (dev_dflags(dev) & D_MASTER) {
691 * We avoid calling ttioctl on the controller since,
692 * in that case, tp must be the controlling terminal.
694 *(int *)ap->a_data = tp->t_pgrp ? tp->t_pgrp->pg_id : 0;
698 if (*(int *)ap->a_data) {
699 if (pti->pt_flags & PF_UCNTL)
701 pti->pt_flags |= PF_PKT;
703 pti->pt_flags &= ~PF_PKT;
707 if (*(int *)ap->a_data) {
708 if (pti->pt_flags & PF_PKT)
710 pti->pt_flags |= PF_UCNTL;
712 pti->pt_flags &= ~PF_UCNTL;
716 if (*(int *)ap->a_data)
717 pti->pt_flags |= PF_REMOTE;
719 pti->pt_flags &= ~PF_REMOTE;
720 ttyflush(tp, FREAD|FWRITE);
725 * The rest of the ioctls shouldn't be called until
728 if ((tp->t_state & TS_ISOPEN) == 0)
741 * IF CONTROLLER STTY THEN MUST FLUSH TO PREVENT A HANG.
742 * ttywflush(tp) will hang if there are characters in
745 ndflush(&tp->t_outq, tp->t_outq.c_cc);
749 if (*(unsigned int *)ap->a_data >= NSIG ||
750 *(unsigned int *)ap->a_data == 0)
752 if ((tp->t_lflag&NOFLSH) == 0)
753 ttyflush(tp, FREAD|FWRITE);
754 pgsignal(tp->t_pgrp, *(unsigned int *)ap->a_data, 1);
755 if ((*(unsigned int *)ap->a_data == SIGINFO) &&
756 ((tp->t_lflag&NOKERNINFO) == 0))
761 if (ap->a_cmd == TIOCEXT) {
763 * When the EXTPROC bit is being toggled, we need
764 * to send an TIOCPKT_IOCTL if the packet driver
767 if (*(int *)ap->a_data) {
768 if (pti->pt_flags & PF_PKT) {
769 pti->pt_send |= TIOCPKT_IOCTL;
770 ptcwakeup(tp, FREAD);
772 tp->t_lflag |= EXTPROC;
774 if ((tp->t_lflag & EXTPROC) &&
775 (pti->pt_flags & PF_PKT)) {
776 pti->pt_send |= TIOCPKT_IOCTL;
777 ptcwakeup(tp, FREAD);
779 tp->t_lflag &= ~EXTPROC;
783 error = (*linesw[tp->t_line].l_ioctl)(tp, ap->a_cmd, ap->a_data,
784 ap->a_fflag, ap->a_cred);
785 if (error == ENOIOCTL)
786 error = ttioctl(tp, ap->a_cmd, ap->a_data, ap->a_fflag);
787 if (error == ENOIOCTL) {
788 if (pti->pt_flags & PF_UCNTL &&
789 (ap->a_cmd & ~0xff) == UIOCCMD(0)) {
790 if (ap->a_cmd & 0xff) {
791 pti->pt_ucntl = (u_char)ap->a_cmd;
792 ptcwakeup(tp, FREAD);
799 * If external processing and packet mode send ioctl packet.
801 if ((tp->t_lflag&EXTPROC) && (pti->pt_flags & PF_PKT)) {
810 #if defined(COMPAT_43) || defined(COMPAT_SUNOS)
817 pti->pt_send |= TIOCPKT_IOCTL;
818 ptcwakeup(tp, FREAD);
823 stop = (tp->t_iflag & IXON) && CCEQ(cc[VSTOP], CTRL('s'))
824 && CCEQ(cc[VSTART], CTRL('q'));
825 if (pti->pt_flags & PF_NOSTOP) {
827 pti->pt_send &= ~TIOCPKT_NOSTOP;
828 pti->pt_send |= TIOCPKT_DOSTOP;
829 pti->pt_flags &= ~PF_NOSTOP;
830 ptcwakeup(tp, FREAD);
834 pti->pt_send &= ~TIOCPKT_DOSTOP;
835 pti->pt_send |= TIOCPKT_NOSTOP;
836 pti->pt_flags |= PF_NOSTOP;
837 ptcwakeup(tp, FREAD);
844 static void ptc_drvinit (void *unused);
847 ptc_drvinit(void *unused)
851 devfs_clone_bitmap_init(&DEVFS_CLONE_BITMAP(pty));
852 devfs_clone_bitmap_init(&DEVFS_CLONE_BITMAP(pts));
855 /* Unix98 pty stuff, leave out for now */
856 make_dev(&ptc_ops, 0, 0, 0, 0666, "ptmx");
857 devfs_clone_handler_add("ptmx", ptyclone);
859 for (i = 0; i < 256; i++) {
864 SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR_C,ptc_drvinit,NULL)