	Here are the changes to create 256 ADDITIONAL TTY/PTY pairs
	in addition to the 64 in current  1.2.0 (and previous) kernels.
	(The NPTY -package does not use so much memory, as like all TTYs,
	 the necessary buffers are allocated only when the PTY-pair is
	 opened..)

	mknod /dev/ttyt0 c 3 0		(TTY256 major: 3)
	mknod /dev/ptyt0 c 2 0		(PTY256 major: 2)
	(etc.)

	Your PROBLEM will be to choose proper PTY sequence letters,
	and have your applications to support them...

	/Matti Aarnio	<mea@utu.fi> <mea@nic.funet.fi>	10-Apr-95


diff -u -r --new-file linux-1200virgin/drivers/char/Makefile linux-1200/drivers/char/Makefile
--- linux-1200virgin/drivers/char/Makefile	Wed Feb 15 10:50:55 1995
+++ linux-1200/drivers/char/Makefile	Mon Mar 13 12:32:08 1995
@@ -17,11 +17,11 @@
 	$(CC) $(CFLAGS) -c $<
 
 OBJS  = tty_io.o n_tty.o console.o keyboard.o serial.o \
-	tty_ioctl.o pty.o vt.o mem.o vc_screen.o \
+	tty_ioctl.o pty.o npty.o vt.o mem.o vc_screen.o \
 	defkeymap.o consolemap.o vesa_blank.o selection.o
 
 SRCS  = tty_io.c n_tty.c console.c keyboard.c serial.c \
-	tty_ioctl.c pty.c vt.c mem.c vc_screen.c \
+	tty_ioctl.c pty.c npty.c vt.c mem.c vc_screen.c \
 	defkeymap.c consolemap.c vesa_blank.c selection.c
 
 
diff -u -r --new-file linux-1200virgin/drivers/char/npty.c linux-1200/drivers/char/npty.c
--- linux-1200virgin/drivers/char/npty.c	Thu Jan  1 02:00:00 1970
+++ linux-1200/drivers/char/npty.c	Mon Mar 13 14:22:45 1995
@@ -0,0 +1,267 @@
+/*
+ *  linux/drivers/char/npty.c
+ *
+ *  Copyright (C) 1991, 1992  Linus Torvalds
+ *
+ *  NPTY trickery by Matti Aarnio <mea@utu.fi> who wants to have 256 ptys!
+ */
+
+/*
+ *	npty.c
+ *
+ * This module exports the following pty function:
+ * 
+ * 	int  npty_open(struct tty_struct * tty, struct file * filp);
+ */
+
+#include <linux/errno.h>
+#include <linux/sched.h>
+#include <linux/interrupt.h>
+#include <linux/tty.h>
+#include <linux/tty_flip.h>
+#include <linux/fcntl.h>
+#include <linux/string.h>
+#include <linux/major.h>
+#include <linux/mm.h>
+
+#include <asm/segment.h>
+#include <asm/system.h>
+#include <asm/bitops.h>
+
+struct pty_struct {
+	int	magic;
+	struct wait_queue * open_wait;
+};
+
+#define PTY_MAGIC 0x5001
+
+#define PTY_BUF_SIZE PAGE_SIZE/2
+
+/*
+ * tmp_buf is used as a temporary buffer by pty_write.  We need to
+ * lock it in case the memcpy_fromfs blocks while swapping in a page,
+ * and some other program tries to do a pty write at the same time.
+ * Since the lock will only come under contention when the system is
+ * swapping and available memory is low, it makes sense to share one
+ * buffer across all the PTY's, since it significantly saves memory if
+ * large numbers of PTY's are open.
+ */
+static unsigned char *tmp_buf;
+static struct semaphore tmp_buf_sem = MUTEX;
+
+struct tty_driver npty_driver, npty_slave_driver;
+static int pty_refcount = 0;
+
+static struct tty_struct *pty_table[NR_NPTYS];
+static struct termios *pty_termios[NR_NPTYS];
+static struct termios *pty_termios_locked[NR_NPTYS];
+static struct tty_struct *ttyp_table[NR_NPTYS];
+static struct termios *ttyp_termios[NR_NPTYS];
+static struct termios *ttyp_termios_locked[NR_NPTYS];
+static struct pty_struct npty_state[NR_NPTYS];
+
+#define MIN(a,b)	((a) < (b) ? (a) : (b))
+
+static void pty_close(struct tty_struct * tty, struct file * filp)
+{
+	if (!tty)
+		return;
+	if (tty->driver.subtype == PTY_TYPE_MASTER) {
+		if (tty->count > 1)
+			printk("master pty_close: count = %d!!\n", tty->count);
+	} else {
+		if (tty->count > 2)
+			return;
+	}
+	wake_up_interruptible(&tty->read_wait);
+	wake_up_interruptible(&tty->write_wait);
+	if (!tty->link)
+		return;
+	wake_up_interruptible(&tty->link->read_wait);
+	wake_up_interruptible(&tty->link->write_wait);
+	if (tty->driver.subtype == PTY_TYPE_MASTER)
+		tty_hangup(tty->link);
+	else {
+		start_tty(tty);
+		set_bit(TTY_SLAVE_CLOSED, &tty->link->flags);
+	}
+}
+
+/*
+ * The unthrottle routine is called by the line discipline to signal
+ * that it can receive more characters.  For PTY's, the TTY_THROTTLED
+ * flag is always set, to force the line discipline to always call the
+ * unthrottle routine when there are fewer than TTY_THRESHOLD_UNTHROTTLE 
+ * characters in the queue.  This is necessary since each time this
+ * happens, we need to wake up any sleeping processes that could be
+ * (1) trying to send data to the pty, or (2) waiting in wait_until_sent()
+ * for the pty buffer to be drained.
+ */
+static void pty_unthrottle(struct tty_struct * tty)
+{
+	struct tty_struct *o_tty = tty->link;
+
+	if (!o_tty)
+		return;
+
+	if ((o_tty->flags & (1 << TTY_DO_WRITE_WAKEUP)) &&
+	    o_tty->ldisc.write_wakeup)
+		(o_tty->ldisc.write_wakeup)(o_tty);
+	wake_up_interruptible(&o_tty->write_wait);
+	set_bit(TTY_THROTTLED, &tty->flags);
+}
+
+static int pty_write(struct tty_struct * tty, int from_user,
+		       unsigned char *buf, int count)
+{
+	struct tty_struct *to = tty->link;
+	int	c=0, n, r;
+	char	*temp_buffer;
+
+	if (!to || tty->stopped)
+		return 0;
+	
+	if (from_user) {
+		down(&tmp_buf_sem);
+		temp_buffer = tmp_buf +
+			((tty->driver.subtype-1) * PTY_BUF_SIZE);
+		while (count > 0) {
+			n = MIN(count, PTY_BUF_SIZE);
+			memcpy_fromfs(temp_buffer, buf, n);
+			r = to->ldisc.receive_room(to);
+			if (r <= 0)
+				break;
+			n = MIN(n, r);
+			to->ldisc.receive_buf(to, temp_buffer, 0, n);
+			buf += n;  c+= n;
+			count -= n;
+		}
+		up(&tmp_buf_sem);
+	} else {
+		c = MIN(count, to->ldisc.receive_room(to));
+		to->ldisc.receive_buf(to, buf, 0, c);
+	}
+	
+	return c;
+}
+
+static int pty_write_room(struct tty_struct *tty)
+{
+	struct tty_struct *to = tty->link;
+
+	if (!to || tty->stopped)
+		return 0;
+
+	return to->ldisc.receive_room(to);
+}
+
+static int pty_chars_in_buffer(struct tty_struct *tty)
+{
+	struct tty_struct *to = tty->link;
+
+	if (!to || !to->ldisc.chars_in_buffer)
+		return 0;
+
+	return to->ldisc.chars_in_buffer(to);
+}
+
+static void pty_flush_buffer(struct tty_struct *tty)
+{
+	struct tty_struct *to = tty->link;
+	
+	if (!to)
+		return;
+	
+	if (to->ldisc.flush_buffer)
+		to->ldisc.flush_buffer(to);
+	
+	if (to->packet) {
+		tty->ctrl_status |= TIOCPKT_FLUSHWRITE;
+		wake_up_interruptible(&to->read_wait);
+	}
+}
+
+int npty_open(struct tty_struct *tty, struct file * filp)
+{
+	int	line;
+	struct	pty_struct *pty;
+	
+	if (!tty || !tty->link)
+		return -ENODEV;
+	line = MINOR(tty->device) - tty->driver.minor_start;
+	if ((line < 0) || (line >= NR_NPTYS))
+		return -ENODEV;
+	pty = npty_state + line;
+	tty->driver_data = pty;
+
+	if (!tmp_buf) {
+		tmp_buf = (unsigned char *) get_free_page(GFP_KERNEL);
+		if (!tmp_buf)
+			return -ENOMEM;
+	}
+
+	if (tty->driver.subtype == PTY_TYPE_SLAVE)
+		clear_bit(TTY_SLAVE_CLOSED, &tty->link->flags);
+	wake_up_interruptible(&pty->open_wait);
+	set_bit(TTY_THROTTLED, &tty->flags);
+	if (filp->f_flags & O_NDELAY)
+		return 0;
+	while (!tty->link->count && !(current->signal & ~current->blocked))
+		interruptible_sleep_on(&pty->open_wait);
+	if (!tty->link->count)
+		return -ERESTARTSYS;
+	return 0;
+}
+
+long npty_init(long kmem_start)
+{
+	memset(&npty_state, 0, sizeof(npty_state));
+	memset(&npty_driver, 0, sizeof(struct tty_driver));
+	npty_driver.magic = TTY_DRIVER_MAGIC;
+	npty_driver.name  = "pty256";
+	npty_driver.major = NTTY_MAJOR;
+	npty_driver.minor_start = 0;
+	npty_driver.num   = NR_NPTYS;
+	npty_driver.type  = TTY_DRIVER_TYPE_PTY;
+	npty_driver.subtype = PTY_TYPE_MASTER;
+	npty_driver.init_termios = tty_std_termios;
+	npty_driver.init_termios.c_iflag = 0;
+	npty_driver.init_termios.c_oflag = 0;
+	npty_driver.init_termios.c_cflag = B38400 | CS8 | CREAD;
+	npty_driver.init_termios.c_lflag = 0;
+	npty_driver.flags = TTY_DRIVER_RESET_TERMIOS | TTY_DRIVER_REAL_RAW;
+	npty_driver.refcount = &pty_refcount;
+	npty_driver.table = pty_table;
+	npty_driver.termios = pty_termios;
+	npty_driver.termios_locked = pty_termios_locked;
+	npty_driver.other = &npty_slave_driver;
+
+	npty_driver.open = npty_open;
+	npty_driver.close = pty_close;
+	npty_driver.write = pty_write;
+	npty_driver.write_room = pty_write_room;
+	npty_driver.flush_buffer = pty_flush_buffer;
+	npty_driver.chars_in_buffer = pty_chars_in_buffer;
+	npty_driver.unthrottle = pty_unthrottle;
+
+	npty_slave_driver = npty_driver;
+	npty_slave_driver.name    = "tty256";
+	npty_slave_driver.major   = NPTY_MAJOR;
+	npty_slave_driver.subtype = PTY_TYPE_SLAVE;
+	npty_slave_driver.minor_start  = 0;
+	npty_slave_driver.init_termios = tty_std_termios;
+	npty_slave_driver.init_termios.c_cflag = B38400 | CS8 | CREAD;
+	npty_slave_driver.table = ttyp_table;
+	npty_slave_driver.termios = ttyp_termios;
+	npty_slave_driver.termios_locked = ttyp_termios_locked;
+	npty_slave_driver.other = &npty_driver;
+
+	tmp_buf = 0;
+
+	if (tty_register_driver(&npty_driver))
+		panic("Couldn't register pty driver");
+	if (tty_register_driver(&npty_slave_driver))
+		panic("Couldn't register pty slave driver");
+	
+	return kmem_start;
+}
diff -u -r --new-file linux-1200virgin/drivers/char/tty_io.c linux-1200/drivers/char/tty_io.c
--- linux-1200virgin/drivers/char/tty_io.c	Mon Feb 20 21:29:52 1995
+++ linux-1200/drivers/char/tty_io.c	Mon Mar 13 14:21:42 1995
@@ -1739,6 +1739,7 @@
 	kmem_start = cy_init(kmem_start);
 #endif
 	kmem_start = pty_init(kmem_start);
+	kmem_start = npty_init(kmem_start);
 	kmem_start = vcs_init(kmem_start);
 	return kmem_start;
 }
diff -u -r --new-file linux-1200virgin/include/linux/major.h linux-1200/include/linux/major.h
--- linux-1200virgin/include/linux/major.h	Thu Feb 23 13:31:40 1995
+++ linux-1200/include/linux/major.h	Mon Mar 13 12:52:13 1995
@@ -19,8 +19,8 @@
  *      --------------------   --------------------   --------------------
  *  0 - unnamed                unnamed                minor 0 = true nodev
  *  1 - /dev/mem               ramdisk
- *  2 -                        floppy
- *  3 -                        hd
+ *  2 - /dev/tty??(256)        floppy
+ *  3 - /dev/pty??(256)        hd
  *  4 - /dev/tty*
  *  5 - /dev/tty; /dev/cua*
  *  6 - lp
@@ -50,9 +50,11 @@
  */
 
 #define UNNAMED_MAJOR	0
-#define MEM_MAJOR	1
-#define FLOPPY_MAJOR	2
-#define IDE0_MAJOR	3
+#define MEM_MAJOR	1	/* char	*/
+#define NTTY_MAJOR	2	/* char */
+#define FLOPPY_MAJOR	2	/* block */
+#define NPTY_MAJOR	3	/* char */
+#define IDE0_MAJOR	3	/* block */
 #define HD_MAJOR	IDE0_MAJOR
 #define TTY_MAJOR	4
 #define TTYAUX_MAJOR	5
diff -u -r --new-file linux-1200virgin/include/linux/tty.h linux-1200/include/linux/tty.h
--- linux-1200virgin/include/linux/tty.h	Sun Feb 26 16:45:26 1995
+++ linux-1200/include/linux/tty.h	Mon Mar 13 14:05:59 1995
@@ -27,6 +27,7 @@
 		/* Note: the ioctl VT_GETSTATE does not work for
 		   consoles 16 and higher (since it returns a short) */
 #define NR_PTYS		64
+#define NR_NPTYS	256	/* Another scheme for PTYs! */
 #define NR_LDISCS	16
 
 /*
@@ -278,6 +279,7 @@
 extern long lp_init(long);
 extern long con_init(long);
 extern long pty_init(long);
+extern long npty_init(long);
 extern long tty_init(long);
 extern long vcs_init(long);
 #ifdef CONFIG_CYCLADES
