3 dev \- device files in /dev
5 Device files are the eyes and ears of the system. Through the device files
6 one has access to the disks, terminals and other parts of the machine.
7 Single bytes or disk blocks may be transferred to or from a device with
12 calls, byte positions set with
14 or more complicated control functions performed with
17 Device files as found in
19 have several attributes that must be considered. Here are two examples as
26 brw-rw-rw- 1 root operator 2, 1 Jun 10 1995 fd1
27 crw--w---- 1 kjb tty 4, 0 May 11 09:41 console
32 Most attributes are the same as for a regular file and have the same
33 function. The file type and the major and minor device numbers are special
36 Character devices are marked with a
38 as a file type letter. Any I/O on a character device is sent down to the
39 device driver without any interpretation. This means that a process doing
40 the I/O must know the characteristics of the device and deal with them
43 Block devices provoke the file system server into buffering the data on
44 those devices. Data read or written by processes is passed through the file
45 system block cache. Unaligned bytes read or written are extracted or
46 reassembled by the file server from or to whole blocks in the cache. The
47 file server transfers data to or from the device driver as blocks to
48 positions at block size boundaries. These blocks are MINIX 3 blocks of 1024
49 bytes, disk devices usually have a 512 byte block size. Only block devices
50 can be mounted as part of the file system tree if they contain a MINIX 3 file
53 The major device number (2 for
57 are used by FS to find the device driver that manages a device. The minor
62 is passed to the driver to select a device among a number of related devices
63 that are all managed by that driver. The device drivers are usually kernel
64 tasks under MINIX 3, small processes that are contained within the address
65 space of the kernel. The following tasks and associated devices exist:
66 .SS "Memory (major 1)"
73 devices are managed by the memory task.
76 device is a block device for a chunk of memory that is the RAM disk. Any
77 byte read from or written to the
79 device is copied from or to that memory chunk.
82 device is a character device for the entire address space of the system, but
84 only for the kernel data area. These two devices allow programs like
86 to hunt around the system looking for interesting bits.
89 device is a data sink. It happily swallows any bytes written to it, and
90 returns nothing on a read.
91 .SS "Floppy disk (major 2)"
99 block devices are the first floppy disk and the four partitions that may
100 exist on a that floppy disk. Likewise are
104 the device and partitions for the second floppy disk. The floppy disk
105 devices are described in detail in
107 Partitioning in general is explained in
109 .SS "Controller 0 (major 3)"
110 The first hard disk on controller 0 can be accessed by block device
112 This device addresses the entire hard disk from the first to the last
113 sector. A hard disk is normally partitioned in up to four primary
120 Each of these devices accesses a range of sectors on the
122 device. It is customary to give each operating system on a disk a primary
123 partition. So the Windows C: "drive" can be on
125 and MINIX 3 can be on
127 MINIX 3 wants to have several partitions on its own, so
129 can be further subdivided into the subpartitions
136 contains devices for the first and second hard disk
140 their primary partitions
141 .RB ( c0d[01]p[0\-3] )
142 and subpartitions thereof
143 .RB ( c0d[01]p[0\-3]s[0\-3] ).
144 More detail can be found in
146 .SS "Terminals (minor 4)"
147 The TTY driver manages the system console device, aptly named
154 Through the console device one can display characters on a screen attached
155 to a monochrome, Hercules, color, or VGA adapter. The
158 etc. devices are the so-called "virtual consoles" that share the one
159 console display. One can select which virtual console is to be visible on
160 the screen and take input from the keyboard.
161 To allow remote login the devices with minor numbers of 128 or higher offer
162 virtual terminals. These pseudo ttys come in tty, pty pairs that form a
163 pipe between processes running under the tty, and a controlling process
164 attached to the pty side.
169 .SS "Anonymous TTY (major 5)"
170 This is just one device named
172 that is a synonym for the controlling tty of a process. This device is not
173 managed by any device driver, but is handled by FS itself. A process can
174 get access to the terminal it is running under by using
176 .SS "Line printer (major 6)"
179 device sends any bytes written to it to the printer.
180 .SS "TCP/IP (major 7)"
181 The TCP/IP task is not a kernel task, but a server like PM and VFS. It sits
182 between VFS and the drivers that manage the ethernet boards. Together
183 they implement the TCP/IP protocol.
184 .SS "Controller 1 (major 8)"
185 Like controller 0 (major 3), but managing a second controller with devices
187 .SS "Controller 2 (major 10)"
189 .SS "Controller 3 (major 12)"
191 .SS "Audio (major 13)"
194 device can be used to produce or record air vibrations using a Soundblaster
195 16 type audio card. See
197 .SS "Mixer (major 14)"
200 device is used to control the audio driver.
204 device is used to implement unix domain sockets.
221 There are five prominent errors that processes accessing device files may
223 .IP "ENODEV \- No such device" 5
224 There is no driver managing the device class this device belongs to, typically
225 because it is not loaded.
226 .IP "ENXIO \- No such device or address"
227 This device is not available. Either the driver does not support it at all,
228 or the hardware isn't available, i.e. accessing the second disk on a system
230 .IP "EACCES \- Permission denied"
231 This error may cause a lot of head scratching if
233 shows a device file to be writable. The media you are trying to access is
234 simply physically write protected!
235 .IP "EINVAL \- Invalid argument"
236 Devices may not like reads or writes that are not block multiples, or very
237 big transfers, etc. The device manual page should list the limits.
238 .IP "EIO \- I/O error"
239 This may be a real I/O error, i.e. a read or write on the device failing due
240 to a media error. But it may also be the result of an operation that a
241 device can't do, or an empty tape drive, etc.
243 Some devices are not present by default. The
245 script knows how to make them.
246 .SS "MS-DOS/Windows equivalents"
247 The names of MS-DOS/Windows devices probably map to MINIX 3 devices as follows:
251 .ta +\w'COM1mmm'u +\w'c0d1, c0d2, c0d3mmm'u
254 C: c0d0p0 (usually the first partition)
255 D: c0d1p0, c0d2p0 (if it's another disk)
256 D: c0d0p1s0 (if it's an extended partition)
257 D: c0d1, c0d2, c0d3 (if it's a CD-ROM)
259 COM1 tty00 (UNIX counts from 0)
264 Kees J. Bot (kjb@cs.vu.nl)