summaryrefslogtreecommitdiff
path: root/include/linux
diff options
context:
space:
mode:
authorAndrew Morton <akpm@osdl.org>2004-02-22 07:01:12 -0800
committerLinus Torvalds <torvalds@ppc970.osdl.org>2004-02-22 07:01:12 -0800
commit562123b5e1c5e73e141748e687b45321484804d1 (patch)
tree2a6e9c2cfee75dbe5c1336d6aa08ac85437a2b58 /include/linux
parentd6ca389041ddde6d1d3a7d17c2d79a0713081fd7 (diff)
[PATCH] dynamic pty allocation
From: "H. Peter Anvin" <hpa@transmeta.com> Remove the limit of 2048 pty's - allocate them on demand up to the 12:20 dev_t limit: a million.
Diffstat (limited to 'include/linux')
-rw-r--r--include/linux/devpts_fs.h23
-rw-r--r--include/linux/sysctl.h8
-rw-r--r--include/linux/tty.h24
-rw-r--r--include/linux/tty_driver.h11
4 files changed, 32 insertions, 34 deletions
diff --git a/include/linux/devpts_fs.h b/include/linux/devpts_fs.h
index 4def3512b355..734f7ea9e835 100644
--- a/include/linux/devpts_fs.h
+++ b/include/linux/devpts_fs.h
@@ -2,7 +2,7 @@
*
* linux/include/linux/devpts_fs.h
*
- * Copyright 1998 H. Peter Anvin -- All Rights Reserved
+ * Copyright 1998-2004 H. Peter Anvin -- All Rights Reserved
*
* This file is part of the Linux kernel and is made available under
* the terms of the GNU General Public License, version 2, or at your
@@ -13,21 +13,22 @@
#ifndef _LINUX_DEVPTS_FS_H
#define _LINUX_DEVPTS_FS_H 1
-#ifdef CONFIG_DEVPTS_FS
+#include <linux/errno.h>
-void devpts_pty_new(int, dev_t); /* mknod in devpts */
-void devpts_pty_kill(int); /* unlink */
+#if CONFIG_UNIX98_PTYS
-#else
+int devpts_pty_new(struct tty_struct *); /* mknod in devpts */
+struct tty_struct *devpts_get_tty(int); /* get tty structure */
+void devpts_pty_kill(int); /* unlink */
-static inline void devpts_pty_new(int line, dev_t device)
-{
-}
+#else
-static inline void devpts_pty_kill(int line)
-{
-}
+/* Dummy stubs in the no-pty case */
+static inline int devpts_pty_new(struct tty_struct *) { return -EINVAL; }
+static inline struct tty_struct *devpts_get_tty(int) { return NULL; }
+static inline void devpts_pty_kill(int) { }
#endif
+
#endif /* _LINUX_DEVPTS_FS_H */
diff --git a/include/linux/sysctl.h b/include/linux/sysctl.h
index f800e292d8a1..6819132d40d4 100644
--- a/include/linux/sysctl.h
+++ b/include/linux/sysctl.h
@@ -129,6 +129,7 @@ enum
KERN_HPPA_UNALIGNED=59, /* int: hppa unaligned-trap enable */
KERN_PRINTK_RATELIMIT=60, /* int: tune printk ratelimiting */
KERN_PRINTK_RATELIMIT_BURST=61, /* int: tune printk ratelimiting */
+ KERN_PTY=62, /* dir: pty driver */
};
@@ -192,6 +193,13 @@ enum
RANDOM_UUID=6
};
+/* /proc/sys/kernel/pty */
+enum
+{
+ PTY_MAX=1,
+ PTY_NR=2
+};
+
/* /proc/sys/bus/isa */
enum
{
diff --git a/include/linux/tty.h b/include/linux/tty.h
index 0626d1b321aa..ca1f1ccf6c49 100644
--- a/include/linux/tty.h
+++ b/include/linux/tty.h
@@ -28,29 +28,13 @@
/*
- * Note: don't mess with NR_PTYS until you understand the tty minor
- * number allocation game...
* (Note: the *_driver.minor_start values 1, 64, 128, 192 are
* hardcoded at present.)
*/
-#define NR_PTYS 256 /* ptys/major */
-#define NR_LDISCS 16
-
-/*
- * Unix98 PTY's can be defined as any multiple of NR_PTYS up to
- * UNIX98_PTY_MAJOR_COUNT; this section defines what we need from the
- * config options
- */
-#ifdef CONFIG_UNIX98_PTYS
-# define UNIX98_NR_MAJORS ((CONFIG_UNIX98_PTY_COUNT+NR_PTYS-1)/NR_PTYS)
-# if UNIX98_NR_MAJORS <= 0
-# undef CONFIG_UNIX98_PTYS
-# elif UNIX98_NR_MAJORS > UNIX98_PTY_MAJOR_COUNT
-# error Too many Unix98 ptys defined
-# undef UNIX98_NR_MAJORS
-# define UNIX98_NR_MAJORS UNIX98_PTY_MAJOR_COUNT
-# endif
-#endif
+#define NR_PTYS CONFIG_LEGACY_PTY_COUNT /* Number of legacy ptys */
+#define NR_UNIX98_PTY_DEFAULT 4096 /* Default maximum for Unix98 ptys */
+#define NR_UNIX98_PTY_MAX (1 << MINORBITS) /* Absolute limit */
+#define NR_LDISCS 16
/*
* These are set up by the setup-routine at boot-time:
diff --git a/include/linux/tty_driver.h b/include/linux/tty_driver.h
index 63051af4d8ac..f0b98e5a5473 100644
--- a/include/linux/tty_driver.h
+++ b/include/linux/tty_driver.h
@@ -160,9 +160,10 @@ struct tty_driver {
const char *devfs_name;
const char *name;
int name_base; /* offset of printed name */
- short major; /* major device number */
- short minor_start; /* start of minor device number*/
- short num; /* number of devices */
+ int major; /* major device number */
+ int minor_start; /* start of minor device number */
+ int minor_num; /* number of *possible* devices */
+ int num; /* number of devices allocated */
short type; /* type of tty driver */
short subtype; /* subtype of tty driver */
struct termios init_termios; /* Initial termios */
@@ -244,11 +245,15 @@ void tty_set_operations(struct tty_driver *driver, struct tty_operations *op);
* TTY_DRIVER_NO_DEVFS --- if set, do not create devfs entries. This
* is only used by tty_register_driver().
*
+ * TTY_DRIVER_DEVPTS_MEM -- don't use the standard arrays, instead
+ * use dynamic memory keyed through the devpts filesystem. This
+ * is only applicable to the pty driver.
*/
#define TTY_DRIVER_INSTALLED 0x0001
#define TTY_DRIVER_RESET_TERMIOS 0x0002
#define TTY_DRIVER_REAL_RAW 0x0004
#define TTY_DRIVER_NO_DEVFS 0x0008
+#define TTY_DRIVER_DEVPTS_MEM 0x0010
/* tty driver types */
#define TTY_DRIVER_TYPE_SYSTEM 0x0001