summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjulian <julian@FreeBSD.org>1999-08-17 23:08:51 +0000
committerjulian <julian@FreeBSD.org>1999-08-17 23:08:51 +0000
commitf352b6efeda0301d20a01dd42199a9ed89583a45 (patch)
tree07a7a525897fc529acdd4b309becb11d359bf688
parent30c109da4dbc5c04e928cf748285cacf968a726e (diff)
downloadFreeBSD-src-f352b6efeda0301d20a01dd42199a9ed89583a45.zip
FreeBSD-src-f352b6efeda0301d20a01dd42199a9ed89583a45.tar.gz
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.
-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 160693f..f2b2da7 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)
OpenPOWER on IntegriCloud