18c2ecf20Sopenharmony_ci.. SPDX-License-Identifier: GPL-2.0
28c2ecf20Sopenharmony_ci
38c2ecf20Sopenharmony_ci=====================
48c2ecf20Sopenharmony_ciThe Devpts Filesystem
58c2ecf20Sopenharmony_ci=====================
68c2ecf20Sopenharmony_ci
78c2ecf20Sopenharmony_ciEach mount of the devpts filesystem is now distinct such that ptys
88c2ecf20Sopenharmony_ciand their indicies allocated in one mount are independent from ptys
98c2ecf20Sopenharmony_ciand their indicies in all other mounts.
108c2ecf20Sopenharmony_ci
118c2ecf20Sopenharmony_ciAll mounts of the devpts filesystem now create a ``/dev/pts/ptmx`` node
128c2ecf20Sopenharmony_ciwith permissions ``0000``.
138c2ecf20Sopenharmony_ci
148c2ecf20Sopenharmony_ciTo retain backwards compatibility the a ptmx device node (aka any node
158c2ecf20Sopenharmony_cicreated with ``mknod name c 5 2``) when opened will look for an instance
168c2ecf20Sopenharmony_ciof devpts under the name ``pts`` in the same directory as the ptmx device
178c2ecf20Sopenharmony_cinode.
188c2ecf20Sopenharmony_ci
198c2ecf20Sopenharmony_ciAs an option instead of placing a ``/dev/ptmx`` device node at ``/dev/ptmx``
208c2ecf20Sopenharmony_ciit is possible to place a symlink to ``/dev/pts/ptmx`` at ``/dev/ptmx`` or
218c2ecf20Sopenharmony_cito bind mount ``/dev/ptx/ptmx`` to ``/dev/ptmx``.  If you opt for using
228c2ecf20Sopenharmony_cithe devpts filesystem in this manner devpts should be mounted with
238c2ecf20Sopenharmony_cithe ``ptmxmode=0666``, or ``chmod 0666 /dev/pts/ptmx`` should be called.
248c2ecf20Sopenharmony_ci
258c2ecf20Sopenharmony_ciTotal count of pty pairs in all instances is limited by sysctls::
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ci    kernel.pty.max = 4096	- global limit
288c2ecf20Sopenharmony_ci    kernel.pty.reserve = 1024	- reserved for filesystems mounted from the initial mount namespace
298c2ecf20Sopenharmony_ci    kernel.pty.nr		- current count of ptys
308c2ecf20Sopenharmony_ci
318c2ecf20Sopenharmony_ciPer-instance limit could be set by adding mount option ``max=<count>``.
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_ciThis feature was added in kernel 3.4 together with
348c2ecf20Sopenharmony_ci``sysctl kernel.pty.reserve``.
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ciIn kernels older than 3.4 sysctl ``kernel.pty.max`` works as per-instance limit.
37