diff --git a/sys/kern/tty_pty.c b/sys/kern/tty_pty.c index 160693f7bf9a..f2b2da747d6e 100644 --- a/sys/kern/tty_pty.c +++ b/sys/kern/tty_pty.c @@ -31,7 +31,7 @@ * SUCH DAMAGE. * * @(#)tty_pty.c 8.4 (Berkeley) 2/20/95 - * $Id: tty_pty.c,v 1.62 1999/08/08 19:28:50 phk Exp $ + * $Id: tty_pty.c,v 1.63 1999/08/08 19:47:32 phk Exp $ */ /* @@ -40,6 +40,7 @@ */ #include "pty.h" /* XXX */ #include "opt_compat.h" +#include "opt_devfs.h" #include #include @@ -56,6 +57,10 @@ #include #include +#ifdef DEVFS +#include +#endif /*DEVFS*/ + MALLOC_DEFINE(M_PTY, "ptys", "pty data structures"); static void ptsstart __P((struct tty *tp)); @@ -129,6 +134,10 @@ struct pt_ioctl { u_char pt_send; u_char pt_ucntl; struct tty pt_tty; +#ifdef DEVFS + void *devfs_token_pts; + void *devfs_token_ptc; +#endif /* DEVFS */ }; #define PF_PKT 0x08 /* packet mode */ @@ -168,6 +177,14 @@ ptyinit(n) devs->si_drv1 = devc->si_drv1 = pt; devs->si_tty_tty = devc->si_tty_tty = &pt->pt_tty; ttyregister(&pt->pt_tty); +#ifdef DEVFS + pt->devfs_token_pts = devfs_add_devswf(&pts_cdevsw,n, + DV_CHR,0,0,0666, + devs->si_name); + pt->devfs_token_ptc = devfs_add_devswf(&ptc_cdevsw,n, + DV_CHR,0,0,0666, + devc->si_name); +#endif /* DEVFS */ } /*ARGSUSED*/ @@ -179,7 +196,22 @@ ptsopen(dev, flag, devtype, p) { register struct tty *tp; int error; +#ifdef DEVFS + int minr; + dev_t nextdev; + /* + * If we openned this device, ensure we have the + * next ready in the DEVFS (up to 256 of them). + */ + minr = lminor(dev); + if (minr < 255) { + nextdev = makedev(major(dev), minr + 1); + if (!nextdev->si_drv1) { + ptyinit(minr + 1); + } + } +#endif /* DEVFS */ if (!dev->si_drv1) ptyinit(minor(dev)); if (!dev->si_drv1) @@ -827,6 +859,9 @@ ptc_drvinit(unused) cdevsw_add(&ptc_cdevsw); ptc_devsw_installed = 1; } +#ifdef DEVFS + ptyinit(0); /* Add the first pty into the system.. prime the pump */ +#endif /* DEVFS */ } SYSINIT(ptcdev,SI_SUB_DRIVERS,SI_ORDER_MIDDLE+CDEV_MAJOR_C,ptc_drvinit,NULL)