1 diff -ur linux-2.6.5-virgin/drivers/char/tty_io.c linux-2.6.5-eviltron/drivers/char/tty_io.c
2 --- linux-2.6.5-virgin/drivers/char/tty_io.c 2004-05-07 03:39:25.085624064 -0600
3 +++ linux-2.6.5-eviltron/drivers/char/tty_io.c 2004-05-07 03:37:51.697821168 -0600
4 @@ -1362,14 +1362,25 @@
5 #ifdef CONFIG_UNIX98_PTYS
6 if (device == MKDEV(TTYAUX_MAJOR,2)) {
7 /* find a device that is not in use. */
8 - static int next_ptmx_dev = 0;
9 + static int next_ptmx_dev = MAX_PREFERRED_PTY;
12 - while (driver->refcount < pty_limit) {
13 - index = next_ptmx_dev;
14 - next_ptmx_dev = (next_ptmx_dev+1) % driver->num;
15 - if (!init_dev(driver, index, &tty))
16 - goto ptmx_found; /* ok! */
17 + /* first, try and allocate a pty < 256 for old glibc */
18 + for (index = 0; index < MAX_PREFERRED_PTY && driver->refcount < pty_limit && index < driver->num; index++) {
19 + if (!init_dev(driver, index, &tty))
22 + /* nothing below MAX_PREFERRED_PTY, try something higher, unless
23 + * we've already run out of options */
24 + if (index != driver->num) {
25 + while (driver->refcount < pty_limit) {
26 + index = next_ptmx_dev;
27 + next_ptmx_dev = (next_ptmx_dev+1) % driver->num;
29 + next_ptmx_dev = MAX_PREFERRED_PTY;
30 + if (!init_dev(driver, index, &tty))
31 + goto ptmx_found; /* ok! */
34 return -EIO; /* no free ptys */
36 diff -ur linux-2.6.5-virgin/include/linux/tty.h linux-2.6.5-eviltron/include/linux/tty.h
37 --- linux-2.6.5-virgin/include/linux/tty.h 2004-05-07 03:39:26.953340128 -0600
38 +++ linux-2.6.5-eviltron/include/linux/tty.h 2004-05-07 01:43:55.000000000 -0600
40 #define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */
41 #define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */
43 +#define MAX_PREFERRED_PTY 256 /* we prefer to allocate ptys beneath this number */
46 * These are set up by the setup-routine at boot-time: