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