There are several bugs in 2.1.115 relating to > 256 pty's; here is the
current patch I've sent to Linus.
If there are other bugs I would appreciate in devpts I would
appreciate if someone would notify me (I'm not on BUGTRAQ.)
-hpa
diff -ur stock/linux-2.1.115/drivers/char/pty.c linux-2.1.115-smp/drivers/char/pty.c
--- stock/linux-2.1.115/drivers/char/pty.c Thu Aug 6 02:29:45 1998
+++ linux-2.1.115-smp/drivers/char/pty.c Sat Aug 8 23:14:04 1998
@@ -85,7 +85,15 @@
if (tty->driver.subtype == PTY_TYPE_MASTER) {
tty_hangup(tty->link);
set_bit(TTY_OTHER_CLOSED, &tty->flags);
- devpts_pty_kill(MINOR(tty->device) - tty->driver.minor_start);
+#ifdef CONFIG_UNIX98_PTYS
+ {
+ unsigned int major = MAJOR(tty->device) - UNIX98_PTY_MASTER_MAJOR;
+ if ( major < UNIX98_NR_MAJORS ) {
+ devpts_pty_kill( MINOR(tty->device)
+ - tty->driver.minor_start + tty->driver.name_base );
+ }
+ }
+#endif
}
}
@@ -214,16 +222,20 @@
return ((count < N_TTY_BUF_SIZE/2) ? 0 : count);
}
-/*
- * Return the minor device number of a given pty. This lets us
- * open a master pty with the multi-headed ptmx device, then
- * find out which one we got after it is open, with an ioctl.
+/*
+ * Return the device number of a Unix98 PTY (only!). This lets us open a
+ * master pty with the multi-headed ptmx device, then find out which
+ * one we got after it is open, with an ioctl.
*/
-static int pty_get_device_minor(struct tty_struct *tty, unsigned int *value)
+#ifdef CONFIG_UNIX98_PTYS
+static int pty_get_device_number(struct tty_struct *tty, unsigned int *value)
{
- unsigned int result = MINOR(tty->device);
+ unsigned int result = MINOR(tty->device)
+ - tty->driver.minor_start + tty->driver.name_base;
return put_user(result, value);
}
+#endif
+
/* Set the lock flag on a pty */
static int pty_set_lock(struct tty_struct *tty, int * arg)
{
@@ -237,22 +249,37 @@
return 0;
}
-static int pty_ioctl(struct tty_struct *tty, struct file *file,
- unsigned int cmd, unsigned long arg)
+static int pty_bsd_ioctl(struct tty_struct *tty, struct file *file,
+ unsigned int cmd, unsigned long arg)
{
if (!tty) {
printk("pty_ioctl called with NULL tty!\n");
return -EIO;
}
switch(cmd) {
- case TIOCGPTN: /* Get PT Number */
- return pty_get_device_minor(tty, (unsigned int *)arg);
case TIOCSPTLCK: /* Set PT Lock (disallow slave open) */
return pty_set_lock(tty, (int *) arg);
}
return -ENOIOCTLCMD;
}
+#ifdef CONFIG_UNIX98_PTYS
+static int pty_unix98_ioctl(struct tty_struct *tty, struct file *file,
+ unsigned int cmd, unsigned long arg)
+{
+ if (!tty) {
+ printk("pty_unix98_ioctl called with NULL tty!\n");
+ return -EIO;
+ }
+ switch(cmd) {
+ case TIOCGPTN: /* Get PT Number */
+ return pty_get_device_number(tty, (unsigned int *)arg);
+ }
+
+ return pty_bsd_ioctl(tty,file,cmd,arg);
+}
+#endif
+
static void pty_flush_buffer(struct tty_struct *tty)
{
struct tty_struct *to = tty->link;
@@ -369,7 +396,7 @@
* assign it here, instead of up with the rest of the
* pty_driver initialization. <cananian@alumni.princeton.edu>
*/
- pty_driver.ioctl = pty_ioctl;
+ pty_driver.ioctl = pty_bsd_ioctl;
/* Unix98 devices */
#ifdef CONFIG_UNIX98_PTYS
@@ -380,6 +407,7 @@
ptm_driver[i].proc_entry = 0;
ptm_driver[i].major = UNIX98_PTY_MASTER_MAJOR+i;
ptm_driver[i].minor_start = 0;
+ ptm_driver[i].name_base = i*NR_PTYS;
ptm_driver[i].num = NR_PTYS;
ptm_driver[i].other = &pts_driver[i];
ptm_driver[i].table = ptm_table[i];
@@ -392,6 +420,7 @@
pts_driver[i].proc_entry = 0;
pts_driver[i].major = UNIX98_PTY_SLAVE_MAJOR+i;
pts_driver[i].minor_start = 0;
+ pts_driver[i].name_base = i*NR_PTYS;
pts_driver[i].num = ptm_driver[i].num;
pts_driver[i].other = &ptm_driver[i];
pts_driver[i].table = pts_table[i];
@@ -399,7 +428,7 @@
pts_driver[i].termios_locked = pts_termios_locked[i];
pts_driver[i].driver_state = ptm_state[i];
- ptm_driver[i].ioctl = pty_ioctl;
+ ptm_driver[i].ioctl = pty_unix98_ioctl;
if (tty_register_driver(&ptm_driver[i]))
panic("Couldn't register Unix98 ptm driver major %d",
diff -ur stock/linux-2.1.115/drivers/char/tty_io.c linux-2.1.115-smp/drivers/char/tty_io.c
--- stock/linux-2.1.115/drivers/char/tty_io.c Thu Aug 6 02:29:45 1998
+++ linux-2.1.115-smp/drivers/char/tty_io.c Sat Aug 8 16:33:12 1998
@@ -1238,7 +1238,7 @@
#ifdef CONFIG_UNIX98_PTYS
if (device == PTMX_DEV) {
/* find a free pty. */
- int major, minor, line;
+ int major, minor;
struct tty_driver *driver;
/* find a device that is not in use. */
@@ -1255,9 +1255,8 @@
return -EIO; /* no free ptys */
ptmx_found:
set_bit(TTY_PTY_LOCK, &tty->flags); /* LOCK THE SLAVE */
- line = minor - driver->minor_start;
- devpts_pty_new(line + major*NR_PTYS, MKDEV(driver->other->major,
- line+driver->other->minor_start));
+ minor -= driver->minor_start;
+ devpts_pty_new(driver->other->name_base + minor, MKDEV(driver->other->major, minor + driver->other->minor_start));
noctty = 1;
goto init_dev_done;
}
-- PGP: 2047/2A960705 BA 03 D3 2C 14 A8 A8 BD 1E DF FE 69 EE 35 BD 74 See http://www.zytor.com/~hpa/ for web page and full PGP public key I am Bahá'í -- ask me about it or see http://www.bahai.org/ "To love another person is to see the face of God." -- Les Misérables- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.rutgers.edu Please read the FAQ at http://www.altern.org/andrebalsa/doc/lkml-faq.html