aboutsummaryrefslogtreecommitdiff
path: root/sys/kern/tty_pty.c
diff options
context:
space:
mode:
authorJulian Elischer <julian@FreeBSD.org>1999-08-17 23:08:51 +0000
committerJulian Elischer <julian@FreeBSD.org>1999-08-17 23:08:51 +0000
commit944494356b6d870f37091138dc9893773560675d (patch)
tree3da8b1f478fb14bbff8f7c4fb3d8863995445fbf /sys/kern/tty_pty.c
parent38c808edb78cb3d775312fda6f73b1c9b8901c1c (diff)
downloadsrc-944494356b6d870f37091138dc9893773560675d.tar.gz
src-944494356b6d870f37091138dc9893773560675d.zip
Devfs isn't quite dead yet... Add back devfs support to ptys..
When you use pty(N) it creates pty(N+1) ready for your use in the DEVFS, so DEVFS is not cluttered up with hundreds of ptys you are never going to use.
Notes
Notes: svn path=/head/; revision=49992
Diffstat (limited to 'sys/kern/tty_pty.c')
-rw-r--r--sys/kern/tty_pty.c37
1 files changed, 36 insertions, 1 deletions
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 <sys/param.h>
#include <sys/systm.h>
@@ -56,6 +57,10 @@
#include <sys/signalvar.h>
#include <sys/malloc.h>
+#ifdef DEVFS
+#include <sys/devfsext.h>
+#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)