[9] | 1 | .TH DEV 4
|
---|
| 2 | .SH NAME
|
---|
| 3 | dev \- device files in /dev
|
---|
| 4 | .SH DESCRIPTION
|
---|
| 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
|
---|
| 8 | ordinary
|
---|
| 9 | .BR read (2)
|
---|
| 10 | or
|
---|
| 11 | .BR write (2)
|
---|
| 12 | calls, byte positions set with
|
---|
| 13 | .BR lseek (2),
|
---|
| 14 | or more complicated control functions performed with
|
---|
| 15 | .BR ioctl(2).
|
---|
| 16 | .PP
|
---|
| 17 | Device files as found in
|
---|
| 18 | .B /dev
|
---|
| 19 | have several attributes that must be considered. Here are two examples as
|
---|
| 20 | .B "ls \-l"
|
---|
| 21 | shows them:
|
---|
| 22 | .PP
|
---|
| 23 | .RS
|
---|
| 24 | .nf
|
---|
| 25 | .if t .ft C
|
---|
| 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
|
---|
| 28 | .if t .ft P
|
---|
| 29 | .fi
|
---|
| 30 | .RE
|
---|
| 31 | .PP
|
---|
| 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
|
---|
| 34 | to devices.
|
---|
| 35 | .PP
|
---|
| 36 | Character devices are marked with a
|
---|
| 37 | .B c
|
---|
| 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
|
---|
| 41 | appropriately.
|
---|
| 42 | .PP
|
---|
| 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
|
---|
| 51 | system.
|
---|
| 52 | .PP
|
---|
| 53 | The major device number (2 for
|
---|
| 54 | .B fd1
|
---|
| 55 | and 4 for
|
---|
| 56 | .BR console )
|
---|
| 57 | are used by FS to find the device driver that manages a device. The minor
|
---|
| 58 | device number (1 for
|
---|
| 59 | .B fd1
|
---|
| 60 | and 0 for
|
---|
| 61 | .BR console )
|
---|
| 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)"
|
---|
| 67 | The
|
---|
| 68 | .BR ram ,
|
---|
| 69 | .BR mem ,
|
---|
| 70 | .BR kmem ,
|
---|
| 71 | and
|
---|
| 72 | .BR null
|
---|
| 73 | devices are managed by the memory task.
|
---|
| 74 | The
|
---|
| 75 | .B ram
|
---|
| 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
|
---|
| 78 | .B ram
|
---|
| 79 | device is copied from or to that memory chunk.
|
---|
| 80 | The
|
---|
| 81 | .B mem
|
---|
| 82 | device is a character device for the entire address space of the system, but
|
---|
| 83 | .B kmem
|
---|
| 84 | only for the kernel data area. These two devices allow programs like
|
---|
| 85 | .BR ps (1)
|
---|
| 86 | to hunt around the system looking for interesting bits.
|
---|
| 87 | The
|
---|
| 88 | .B null
|
---|
| 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)"
|
---|
| 92 | The
|
---|
| 93 | .BR fd0 ,
|
---|
| 94 | .BR fd0p0 ,
|
---|
| 95 | .BR fd0p1 ,
|
---|
| 96 | .BR fd0p2 ,
|
---|
| 97 | and
|
---|
| 98 | .BR fd0p3
|
---|
| 99 | block devices are the first floppy disk and the four partitions that may
|
---|
| 100 | exist on a that floppy disk. Likewise are
|
---|
| 101 | .BR fd1
|
---|
| 102 | and
|
---|
| 103 | .BR fd1p[0\-3]
|
---|
| 104 | the device and partitions for the second floppy disk. The floppy disk
|
---|
| 105 | devices are described in detail in
|
---|
| 106 | .BR fd (4).
|
---|
| 107 | Partitioning in general is explained in
|
---|
| 108 | .BR controller (4).
|
---|
| 109 | .SS "Controller 0 (major 3)"
|
---|
| 110 | The first hard disk on controller 0 can be accessed by block device
|
---|
| 111 | .BR c0d0 .
|
---|
| 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
|
---|
| 114 | partitions,
|
---|
| 115 | .BR c0d0p0 ,
|
---|
| 116 | .BR c0d0p1 ,
|
---|
| 117 | .BR c0d0p2 ,
|
---|
| 118 | and
|
---|
| 119 | .BR c0d0p3 .
|
---|
| 120 | Each of these devices accesses a range of sectors on the
|
---|
| 121 | .B c0d0
|
---|
| 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
|
---|
| 124 | .BR c0d0p0 ,
|
---|
| 125 | and MINIX 3 can be on
|
---|
| 126 | .BR c0d0p1 .
|
---|
| 127 | MINIX 3 wants to have several partitions on its own, so
|
---|
| 128 | .B c0d0p1
|
---|
| 129 | can be further subdivided into the subpartitions
|
---|
| 130 | .BR c0d0p1s0 ,
|
---|
| 131 | .BR c0d0p1s1 ,
|
---|
| 132 | .BR c0d0p1s2 ,
|
---|
| 133 | and
|
---|
| 134 | .BR c0d0p1s3 .
|
---|
| 135 | .B /dev
|
---|
| 136 | contains devices for the first and second hard disk
|
---|
| 137 | .RB ( c0d0
|
---|
| 138 | and
|
---|
| 139 | .BR c0d1 ),
|
---|
| 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
|
---|
| 145 | .BR controller (4).
|
---|
| 146 | .SS "Terminals (minor 4)"
|
---|
| 147 | The TTY driver manages the system console device, aptly named
|
---|
| 148 | .BR console ,
|
---|
| 149 | the serial lines,
|
---|
| 150 | .BR tty00
|
---|
| 151 | and
|
---|
| 152 | .BR tty01 ,
|
---|
| 153 | and the pseudo ttys.
|
---|
| 154 | Through the console device one can display characters on a screen attached
|
---|
| 155 | to a monochrome, Hercules, color, or VGA adapter. The
|
---|
| 156 | .BR ttyc1 ,
|
---|
| 157 | .BR ttyc2 ,
|
---|
| 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.
|
---|
| 165 | See also
|
---|
| 166 | .BR console (4),
|
---|
| 167 | and
|
---|
| 168 | .BR tty (4).
|
---|
| 169 | .SS "Anonymous TTY (major 5)"
|
---|
| 170 | This is just one device named
|
---|
| 171 | .BR tty
|
---|
| 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
|
---|
| 175 | .BR /dev/tty .
|
---|
| 176 | .SS "Line printer (major 6)"
|
---|
| 177 | The
|
---|
| 178 | .B lp
|
---|
| 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 MM and FS. It sits
|
---|
| 182 | between FS and the DP8390 task that manages the ethernet boards. Together
|
---|
| 183 | they implement the TCP/IP protocol. See also
|
---|
| 184 | .BR ip (4).
|
---|
| 185 | .SS "Controller 1 (major 8)"
|
---|
| 186 | Like controller 0 (major 3), but managing a second controller with devices
|
---|
| 187 | .BR /dev/c1* .
|
---|
| 188 | .SS "Controller 2 (major 10)"
|
---|
| 189 | Like controller 0.
|
---|
| 190 | .SS "Controller 3 (major 12)"
|
---|
| 191 | Like controller 0.
|
---|
| 192 | .SS "Audio (major 13)"
|
---|
| 193 | The
|
---|
| 194 | .B audio
|
---|
| 195 | device can be used to produce or record air vibrations using a Soundblaster
|
---|
| 196 | 16 type audio card. See
|
---|
| 197 | .BR audio (4).
|
---|
| 198 | .SS "Mixer (major 14)"
|
---|
| 199 | The
|
---|
| 200 | .B mixer
|
---|
| 201 | device is used to control the audio driver.
|
---|
| 202 | .SH FILES
|
---|
| 203 | .TP 10
|
---|
| 204 | .B /dev/*
|
---|
| 205 | All MINIX 3 devices
|
---|
| 206 | .SH "SEE ALSO"
|
---|
| 207 | .BR read (2),
|
---|
| 208 | .BR write (2),
|
---|
| 209 | .BR lseek (2),
|
---|
| 210 | .BR ioctl (2),
|
---|
| 211 | .BR console (4),
|
---|
| 212 | .BR fd (4),
|
---|
| 213 | .BR controller (4),
|
---|
| 214 | .BR ip (4),
|
---|
| 215 | .BR tty (4),
|
---|
| 216 | .BR MAKEDEV (8).
|
---|
| 217 | .SH DIAGNOSTICS
|
---|
| 218 | There are five prominent errors that processes accessing device files may
|
---|
| 219 | provoke:
|
---|
| 220 | .IP "ENODEV \- No such device" 5
|
---|
| 221 | There is no driver managing the device class this device belongs to. Either
|
---|
| 222 | the driver is configured out, or it is not loaded (inet).
|
---|
| 223 | .IP "ENXIO \- No such device or address"
|
---|
| 224 | This device is not available. Either the driver does not support it at all,
|
---|
| 225 | or the hardware isn't available, i.e. accessing the second disk on a system
|
---|
| 226 | with only one disk.
|
---|
| 227 | .IP "EACCES \- Permission denied"
|
---|
| 228 | This error may cause a lot of head scratching if
|
---|
| 229 | .B ls \-l
|
---|
| 230 | shows a device file to be writable. The media you are trying to access is
|
---|
| 231 | simply physically write protected!
|
---|
| 232 | .IP "EINVAL \- Invalid argument"
|
---|
| 233 | Devices may not like reads or writes that are not block multiples, or very
|
---|
| 234 | big transfers, etc. The device manual page should list the limits.
|
---|
| 235 | .IP "EIO \- I/O error"
|
---|
| 236 | This may be a real I/O error, i.e. a read or write on the device failing due
|
---|
| 237 | to a media error. But it may also be the result of an operation that a
|
---|
| 238 | device can't do, or an empty tape drive, etc.
|
---|
| 239 | .SH NOTES
|
---|
| 240 | Some devices are not present by default. The
|
---|
| 241 | .BR MAKEDEV
|
---|
| 242 | script knows how to make them.
|
---|
| 243 | .SS "MS-DOS/Windows equivalents"
|
---|
| 244 | The names of MS-DOS/Windows devices probably map to MINIX 3 devices as follows:
|
---|
| 245 | .PP
|
---|
| 246 | .RS
|
---|
| 247 | .nf
|
---|
| 248 | .ta +\w'COM1mmm'u +\w'c0d1, c0d2, c0d3mmm'u
|
---|
| 249 | A: fd0
|
---|
| 250 | B: fd1
|
---|
| 251 | C: c0d0p0 (usually the first partition)
|
---|
| 252 | D: c0d1p0, c0d2p0 (if it's another disk)
|
---|
| 253 | D: c0d0p1s0 (if it's an extended partition)
|
---|
| 254 | D: c0d1, c0d2, c0d3 (if it's a CD-ROM)
|
---|
| 255 | CON console
|
---|
| 256 | COM1 tty00 (UNIX counts from 0)
|
---|
| 257 | LPT1 lp
|
---|
| 258 | .fi
|
---|
| 259 | .RE
|
---|
| 260 | .SH AUTHOR
|
---|
| 261 | Kees J. Bot (kjb@cs.vu.nl)
|
---|