More than 2048 pty devcies

Jeff jeff at intersystems.com
Fri Mar 25 13:07:56 UTC 2005


> On Wed, 2005-03-02 at 17:47 +0530, Reddy V, Ravinder (Ravinder) wrote:
>> Hi,
>> 
>>  Can anyone please let me know the system variable which holds the pseudo
>> terminal limit in fedora linux.
>> Also please let me know the filename where this variable is present, and how
>> to change this variable value?
> 
> If you look in Documentation/devices.txt in the kernel sources, you will
> see that device major numbers 136-143 reserved for Unix98 pseudo-TTY
> devices. That makes 8 x 256 total available under the current device
> allocation scheme.
> 
> However, if you look in include/linux/tty.h you see this:
> 
> #define NR_UNIX98_PTY_DEFAULT   4096      /* Default maximum for Unix98 ptys */
> #define NR_UNIX98_PTY_MAX       (1 << MINORBITS) /* Absolute limit */
> 
> and in include/linux/kdev_t.h
> 
> #define MINORBITS      20
> 
> Which gives a maximum of 1048576. So then looking in drivers/char/pty.c
> 
> /* Unix98 devices */
> #ifdef CONFIG_UNIX98_PTYS
> /*
>  * sysctl support for setting limits on the number of Unix98 ptys allocated.
>  * Otherwise one can eat up all kernel memory by opening /dev/ptmx repeatedly.
>  */
> int pty_limit = NR_UNIX98_PTY_DEFAULT;
> static int pty_limit_min = 0;
> static int pty_limit_max = NR_UNIX98_PTY_MAX;
> 
> And from sysctl:
> 
> kernel.pty.max = 4096
> 
> So you can set it either by echoing a value into:
> 
> /proc/sys/kernel/pty/max
> 
> Or by using
> 
> sysctl -w kernel.pty.max=<value>
> 
> If you want to set it permanently, add a line to /etc/sysctl.conf and it
> will get loaded at boot time.
> 
> -- 
> C. Linus Hicks <lhicks at nc dot rr dot com>

The above was posted earlier this month.

What I don't understand is how to reconcile the maximum of
8 x 256 (2048) total devices available based on major/minor
device numbers with the default of 4096 or the theoretical max
of 1048576. Is there something else at work here?







More information about the fedora-list mailing list