xref: /OK3568_Linux_fs/kernel/Documentation/filesystems/devpts.rst (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1*4882a593Smuzhiyun.. SPDX-License-Identifier: GPL-2.0
2*4882a593Smuzhiyun
3*4882a593Smuzhiyun=====================
4*4882a593SmuzhiyunThe Devpts Filesystem
5*4882a593Smuzhiyun=====================
6*4882a593Smuzhiyun
7*4882a593SmuzhiyunEach mount of the devpts filesystem is now distinct such that ptys
8*4882a593Smuzhiyunand their indicies allocated in one mount are independent from ptys
9*4882a593Smuzhiyunand their indicies in all other mounts.
10*4882a593Smuzhiyun
11*4882a593SmuzhiyunAll mounts of the devpts filesystem now create a ``/dev/pts/ptmx`` node
12*4882a593Smuzhiyunwith permissions ``0000``.
13*4882a593Smuzhiyun
14*4882a593SmuzhiyunTo retain backwards compatibility the a ptmx device node (aka any node
15*4882a593Smuzhiyuncreated with ``mknod name c 5 2``) when opened will look for an instance
16*4882a593Smuzhiyunof devpts under the name ``pts`` in the same directory as the ptmx device
17*4882a593Smuzhiyunnode.
18*4882a593Smuzhiyun
19*4882a593SmuzhiyunAs an option instead of placing a ``/dev/ptmx`` device node at ``/dev/ptmx``
20*4882a593Smuzhiyunit is possible to place a symlink to ``/dev/pts/ptmx`` at ``/dev/ptmx`` or
21*4882a593Smuzhiyunto bind mount ``/dev/ptx/ptmx`` to ``/dev/ptmx``.  If you opt for using
22*4882a593Smuzhiyunthe devpts filesystem in this manner devpts should be mounted with
23*4882a593Smuzhiyunthe ``ptmxmode=0666``, or ``chmod 0666 /dev/pts/ptmx`` should be called.
24*4882a593Smuzhiyun
25*4882a593SmuzhiyunTotal count of pty pairs in all instances is limited by sysctls::
26*4882a593Smuzhiyun
27*4882a593Smuzhiyun    kernel.pty.max = 4096	- global limit
28*4882a593Smuzhiyun    kernel.pty.reserve = 1024	- reserved for filesystems mounted from the initial mount namespace
29*4882a593Smuzhiyun    kernel.pty.nr		- current count of ptys
30*4882a593Smuzhiyun
31*4882a593SmuzhiyunPer-instance limit could be set by adding mount option ``max=<count>``.
32*4882a593Smuzhiyun
33*4882a593SmuzhiyunThis feature was added in kernel 3.4 together with
34*4882a593Smuzhiyun``sysctl kernel.pty.reserve``.
35*4882a593Smuzhiyun
36*4882a593SmuzhiyunIn kernels older than 3.4 sysctl ``kernel.pty.max`` works as per-instance limit.
37