^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) .. _admin_devices:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) Linux allocated devices (4.x+ version)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) ======================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) This list is the Linux Device List, the official registry of allocated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7) device numbers and ``/dev`` directory nodes for the Linux operating
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) The LaTeX version of this document is no longer maintained, nor is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) the document that used to reside at lanana.org. This version in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) mainline Linux kernel is the master document. Updates shall be sent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) as patches to the kernel maintainers (see the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) :ref:`Documentation/process/submitting-patches.rst <submittingpatches>` document).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) Specifically explore the sections titled "CHAR and MISC DRIVERS", and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) "BLOCK LAYER" in the MAINTAINERS file to find the right maintainers
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) to involve for character and block devices.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) This document is included by reference into the Filesystem Hierarchy
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) Standard (FHS). The FHS is available from https://www.pathname.com/fhs/.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) Allocations marked (68k/Amiga) apply to Linux/68k on the Amiga
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) platform only. Allocations marked (68k/Atari) apply to Linux/68k on
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) the Atari platform only.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) This document is in the public domain. The authors requests, however,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) that semantically altered versions are not distributed without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) permission of the authors, assuming the authors can be contacted without
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) an unreasonable effort.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) .. attention::
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) DEVICE DRIVERS AUTHORS PLEASE READ THIS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) Linux now has extensive support for dynamic allocation of device numbering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) and can use ``sysfs`` and ``udev`` (``systemd``) to handle the naming needs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) There are still some exceptions in the serial and boot device area. Before
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) asking for a device number make sure you actually need one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) To have a major number allocated, or a minor number in situations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) where that applies (e.g. busmice), please submit a patch and send to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) the authors as indicated above.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45) Keep the description of the device *in the same format
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) as this list*. The reason for this is that it is the only way we have
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) found to ensure we have all the requisite information to publish your
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) device and avoid conflicts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) Finally, sometimes we have to play "namespace police." Please don't be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) offended. We often get submissions for ``/dev`` names that would be bound
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) to cause conflicts down the road. We are trying to avoid getting in a
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53) situation where we would have to suffer an incompatible forward
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) change. Therefore, please consult with us **before** you make your
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) device names and numbers in any way public, at least to the point
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) where it would be at all difficult to get them changed.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) Your cooperation is appreciated.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) .. include:: devices.txt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) :literal:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) Additional ``/dev/`` directory entries
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) --------------------------------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) This section details additional entries that should or may exist in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) the /dev directory. It is preferred that symbolic links use the same
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) form (absolute or relative) as is indicated here. Links are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) classified as "hard" or "symbolic" depending on the preferred type of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) link; if possible, the indicated type of link should be used.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) Compulsory links
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) ++++++++++++++++
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) These links should exist on all systems:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) =============== =============== =============== ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78) /dev/fd /proc/self/fd symbolic File descriptors
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) /dev/stdin fd/0 symbolic stdin file descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) /dev/stdout fd/1 symbolic stdout file descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81) /dev/stderr fd/2 symbolic stderr file descriptor
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) /dev/nfsd socksys symbolic Required by iBCS-2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) /dev/X0R null symbolic Required by iBCS-2
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) =============== =============== =============== ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) Note: ``/dev/X0R`` is <letter X>-<digit 0>-<letter R>.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) Recommended links
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) +++++++++++++++++
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) It is recommended that these links exist on all systems:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94) =============== =============== =============== ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) /dev/core /proc/kcore symbolic Backward compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) /dev/ramdisk ram0 symbolic Backward compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) /dev/ftape qft0 symbolic Backward compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) /dev/bttv0 video0 symbolic Backward compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) /dev/radio radio0 symbolic Backward compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) /dev/i2o* /dev/i2o/* symbolic Backward compatibility
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) /dev/scd? sr? hard Alternate SCSI CD-ROM name
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) =============== =============== =============== ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) Locally defined links
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) +++++++++++++++++++++
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) The following links may be established locally to conform to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) configuration of the system. This is merely a tabulation of existing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) practice, and does not constitute a recommendation. However, if they
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) exist, they should have the following uses.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) =============== =============== =============== ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) /dev/mouse mouse port symbolic Current mouse device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) /dev/tape tape device symbolic Current tape device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) /dev/cdrom CD-ROM device symbolic Current CD-ROM device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) /dev/cdwriter CD-writer symbolic Current CD-writer device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) /dev/scanner scanner symbolic Current scanner device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) /dev/modem modem port symbolic Current dialout device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) /dev/root root device symbolic Current root filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) /dev/swap swap device symbolic Current swap device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) =============== =============== =============== ===============================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) ``/dev/modem`` should not be used for a modem which supports dialin as
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) well as dialout, as it tends to cause lock file problems. If it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) exists, ``/dev/modem`` should point to the appropriate primary TTY device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) (the use of the alternate callout devices is deprecated).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) For SCSI devices, ``/dev/tape`` and ``/dev/cdrom`` should point to the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) *cooked* devices (``/dev/st*`` and ``/dev/sr*``, respectively), whereas
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) ``/dev/cdwriter`` and /dev/scanner should point to the appropriate generic
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) SCSI devices (/dev/sg*).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) ``/dev/mouse`` may point to a primary serial TTY device, a hardware mouse
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) device, or a socket for a mouse driver program (e.g. ``/dev/gpmdata``).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) Sockets and pipes
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) +++++++++++++++++
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) Non-transient sockets and named pipes may exist in /dev. Common entries are:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) =============== =============== ===============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) /dev/printer socket lpd local socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) /dev/log socket syslog local socket
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) /dev/gpmdata socket gpm mouse multiplexer
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) =============== =============== ===============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147) Mount points
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) ++++++++++++
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) The following names are reserved for mounting special filesystems
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) under /dev. These special filesystems provide kernel interfaces that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) cannot be provided with standard device nodes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) =============== =============== ===============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) /dev/pts devpts PTY slave filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) /dev/shm tmpfs POSIX shared memory maintenance access
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) =============== =============== ===============================================
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) Terminal devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) ----------------
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) Terminal, or TTY devices are a special class of character devices. A
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) terminal device is any device that could act as a controlling terminal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) for a session; this includes virtual consoles, serial ports, and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) pseudoterminals (PTYs).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) All terminal devices share a common set of capabilities known as line
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) disciplines; these include the common terminal line discipline as well
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) as SLIP and PPP modes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) All terminal devices are named similarly; this section explains the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) naming and use of the various types of TTYs. Note that the naming
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) conventions include several historical warts; some of these are
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) Linux-specific, some were inherited from other systems, and some
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) reflect Linux outgrowing a borrowed convention.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) A hash mark (``#``) in a device name is used here to indicate a decimal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) number without leading zeroes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) Virtual consoles and the console device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) +++++++++++++++++++++++++++++++++++++++
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) Virtual consoles are full-screen terminal displays on the system video
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) monitor. Virtual consoles are named ``/dev/tty#``, with numbering
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) starting at ``/dev/tty1``; ``/dev/tty0`` is the current virtual console.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) ``/dev/tty0`` is the device that should be used to access the system video
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) card on those architectures for which the frame buffer devices
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) (``/dev/fb*``) are not applicable. Do not use ``/dev/console``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) for this purpose.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) The console device, ``/dev/console``, is the device to which system
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) messages should be sent, and on which logins should be permitted in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) single-user mode. Starting with Linux 2.1.71, ``/dev/console`` is managed
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) by the kernel; for previous versions it should be a symbolic link to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) either ``/dev/tty0``, a specific virtual console such as ``/dev/tty1``, or to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) a serial port primary (``tty*``, not ``cu*``) device, depending on the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) configuration of the system.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) Serial ports
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) ++++++++++++
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) Serial ports are RS-232 serial ports and any device which simulates
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) one, either in hardware (such as internal modems) or in software (such
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) as the ISDN driver.) Under Linux, each serial ports has two device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) names, the primary or callin device and the alternate or callout one.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) Each kind of device is indicated by a different letter. For any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) letter X, the names of the devices are ``/dev/ttyX#`` and ``/dev/cux#``,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) respectively; for historical reasons, ``/dev/ttyS#`` and ``/dev/ttyC#``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) correspond to ``/dev/cua#`` and ``/dev/cub#``. In the future, it should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) expected that multiple letters will be used; all letters will be upper
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) case for the "tty" device (e.g. ``/dev/ttyDP#``) and lower case for the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) "cu" device (e.g. ``/dev/cudp#``).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) The names ``/dev/ttyQ#`` and ``/dev/cuq#`` are reserved for local use.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) The alternate devices provide for kernel-based exclusion and somewhat
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) different defaults than the primary devices. Their main purpose is to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) allow the use of serial ports with programs with no inherent or broken
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) support for serial ports. Their use is deprecated, and they may be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) removed from a future version of Linux.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) Arbitration of serial ports is provided by the use of lock files with
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) the names ``/var/lock/LCK..ttyX#``. The contents of the lock file should
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) be the PID of the locking process as an ASCII number.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) It is common practice to install links such as /dev/modem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) which point to serial ports. In order to ensure proper locking in the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) presence of these links, it is recommended that software chase
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) symlinks and lock all possible names; additionally, it is recommended
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) that a lock file be installed with the corresponding alternate
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) device. In order to avoid deadlocks, it is recommended that the locks
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) are acquired in the following order, and released in the reverse:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 1. The symbolic link name, if any (``/var/lock/LCK..modem``)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 2. The "tty" name (``/var/lock/LCK..ttyS2``)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 3. The alternate device name (``/var/lock/LCK..cua2``)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) In the case of nested symbolic links, the lock files should be
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) installed in the order the symlinks are resolved.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) Under no circumstances should an application hold a lock while waiting
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) for another to be released. In addition, applications which attempt
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) to create lock files for the corresponding alternate device names
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) should take into account the possibility of being used on a non-serial
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) port TTY, for which no alternate device would exist.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) Pseudoterminals (PTYs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) ++++++++++++++++++++++
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) Pseudoterminals, or PTYs, are used to create login sessions or provide
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) other capabilities requiring a TTY line discipline (including SLIP or
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) PPP capability) to arbitrary data-generation processes. Each PTY has
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) a master side, named ``/dev/pty[p-za-e][0-9a-f]``, and a slave side, named
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) ``/dev/tty[p-za-e][0-9a-f]``. The kernel arbitrates the use of PTYs by
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) allowing each master side to be opened only once.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) Once the master side has been opened, the corresponding slave device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) can be used in the same manner as any TTY device. The master and
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) slave devices are connected by the kernel, generating the equivalent
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) of a bidirectional pipe with TTY capabilities.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) Recent versions of the Linux kernels and GNU libc contain support for
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) the System V/Unix98 naming scheme for PTYs, which assigns a common
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) device, ``/dev/ptmx``, to all the masters (opening it will automatically
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) give you a previously unassigned PTY) and a subdirectory, ``/dev/pts``,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) for the slaves; the slaves are named with decimal integers (``/dev/pts/#``
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) in our notation). This removes the problem of exhausting the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) namespace and enables the kernel to automatically create the device
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) nodes for the slaves on demand using the "devpts" filesystem.