source: trunk/minix/man/man4/dev.4@ 15

Last change on this file since 15 was 9, checked in by Mattia Monga, 14 years ago

Minix 3.1.2a

File size: 7.8 KB
Line 
1.TH DEV 4
2.SH NAME
3dev \- device files in /dev
4.SH DESCRIPTION
5Device files are the eyes and ears of the system. Through the device files
6one has access to the disks, terminals and other parts of the machine.
7Single bytes or disk blocks may be transferred to or from a device with
8ordinary
9.BR read (2)
10or
11.BR write (2)
12calls, byte positions set with
13.BR lseek (2),
14or more complicated control functions performed with
15.BR ioctl(2).
16.PP
17Device files as found in
18.B /dev
19have several attributes that must be considered. Here are two examples as
20.B "ls \-l"
21shows them:
22.PP
23.RS
24.nf
25.if t .ft C
26brw-rw-rw- 1 root operator 2, 1 Jun 10 1995 fd1
27crw--w---- 1 kjb tty 4, 0 May 11 09:41 console
28.if t .ft P
29.fi
30.RE
31.PP
32Most attributes are the same as for a regular file and have the same
33function. The file type and the major and minor device numbers are special
34to devices.
35.PP
36Character devices are marked with a
37.B c
38as a file type letter. Any I/O on a character device is sent down to the
39device driver without any interpretation. This means that a process doing
40the I/O must know the characteristics of the device and deal with them
41appropriately.
42.PP
43Block devices provoke the file system server into buffering the data on
44those devices. Data read or written by processes is passed through the file
45system block cache. Unaligned bytes read or written are extracted or
46reassembled by the file server from or to whole blocks in the cache. The
47file server transfers data to or from the device driver as blocks to
48positions at block size boundaries. These blocks are MINIX 3 blocks of 1024
49bytes, disk devices usually have a 512 byte block size. Only block devices
50can be mounted as part of the file system tree if they contain a MINIX 3 file
51system.
52.PP
53The major device number (2 for
54.B fd1
55and 4 for
56.BR console )
57are used by FS to find the device driver that manages a device. The minor
58device number (1 for
59.B fd1
60and 0 for
61.BR console )
62is passed to the driver to select a device among a number of related devices
63that are all managed by that driver. The device drivers are usually kernel
64tasks under MINIX 3, small processes that are contained within the address
65space of the kernel. The following tasks and associated devices exist:
66.SS "Memory (major 1)"
67The
68.BR ram ,
69.BR mem ,
70.BR kmem ,
71and
72.BR null
73devices are managed by the memory task.
74The
75.B ram
76device is a block device for a chunk of memory that is the RAM disk. Any
77byte read from or written to the
78.B ram
79device is copied from or to that memory chunk.
80The
81.B mem
82device is a character device for the entire address space of the system, but
83.B kmem
84only for the kernel data area. These two devices allow programs like
85.BR ps (1)
86to hunt around the system looking for interesting bits.
87The
88.B null
89device is a data sink. It happily swallows any bytes written to it, and
90returns nothing on a read.
91.SS "Floppy disk (major 2)"
92The
93.BR fd0 ,
94.BR fd0p0 ,
95.BR fd0p1 ,
96.BR fd0p2 ,
97and
98.BR fd0p3
99block devices are the first floppy disk and the four partitions that may
100exist on a that floppy disk. Likewise are
101.BR fd1
102and
103.BR fd1p[0\-3]
104the device and partitions for the second floppy disk. The floppy disk
105devices are described in detail in
106.BR fd (4).
107Partitioning in general is explained in
108.BR controller (4).
109.SS "Controller 0 (major 3)"
110The first hard disk on controller 0 can be accessed by block device
111.BR c0d0 .
112This device addresses the entire hard disk from the first to the last
113sector. A hard disk is normally partitioned in up to four primary
114partitions,
115.BR c0d0p0 ,
116.BR c0d0p1 ,
117.BR c0d0p2 ,
118and
119.BR c0d0p3 .
120Each of these devices accesses a range of sectors on the
121.B c0d0
122device. It is customary to give each operating system on a disk a primary
123partition. So the Windows C: "drive" can be on
124.BR c0d0p0 ,
125and MINIX 3 can be on
126.BR c0d0p1 .
127MINIX 3 wants to have several partitions on its own, so
128.B c0d0p1
129can be further subdivided into the subpartitions
130.BR c0d0p1s0 ,
131.BR c0d0p1s1 ,
132.BR c0d0p1s2 ,
133and
134.BR c0d0p1s3 .
135.B /dev
136contains devices for the first and second hard disk
137.RB ( c0d0
138and
139.BR c0d1 ),
140their primary partitions
141.RB ( c0d[01]p[0\-3] )
142and subpartitions thereof
143.RB ( c0d[01]p[0\-3]s[0\-3] ).
144More detail can be found in
145.BR controller (4).
146.SS "Terminals (minor 4)"
147The TTY driver manages the system console device, aptly named
148.BR console ,
149the serial lines,
150.BR tty00
151and
152.BR tty01 ,
153and the pseudo ttys.
154Through the console device one can display characters on a screen attached
155to a monochrome, Hercules, color, or VGA adapter. The
156.BR ttyc1 ,
157.BR ttyc2 ,
158etc. devices are the so-called "virtual consoles" that share the one
159console display. One can select which virtual console is to be visible on
160the screen and take input from the keyboard.
161To allow remote login the devices with minor numbers of 128 or higher offer
162virtual terminals. These pseudo ttys come in tty, pty pairs that form a
163pipe between processes running under the tty, and a controlling process
164attached to the pty side.
165See also
166.BR console (4),
167and
168.BR tty (4).
169.SS "Anonymous TTY (major 5)"
170This is just one device named
171.BR tty
172that is a synonym for the controlling tty of a process. This device is not
173managed by any device driver, but is handled by FS itself. A process can
174get access to the terminal it is running under by using
175.BR /dev/tty .
176.SS "Line printer (major 6)"
177The
178.B lp
179device sends any bytes written to it to the printer.
180.SS "TCP/IP (major 7)"
181The TCP/IP task is not a kernel task, but a server like MM and FS. It sits
182between FS and the DP8390 task that manages the ethernet boards. Together
183they implement the TCP/IP protocol. See also
184.BR ip (4).
185.SS "Controller 1 (major 8)"
186Like controller 0 (major 3), but managing a second controller with devices
187.BR /dev/c1* .
188.SS "Controller 2 (major 10)"
189Like controller 0.
190.SS "Controller 3 (major 12)"
191Like controller 0.
192.SS "Audio (major 13)"
193The
194.B audio
195device can be used to produce or record air vibrations using a Soundblaster
19616 type audio card. See
197.BR audio (4).
198.SS "Mixer (major 14)"
199The
200.B mixer
201device is used to control the audio driver.
202.SH FILES
203.TP 10
204.B /dev/*
205All 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
218There are five prominent errors that processes accessing device files may
219provoke:
220.IP "ENODEV \- No such device" 5
221There is no driver managing the device class this device belongs to. Either
222the driver is configured out, or it is not loaded (inet).
223.IP "ENXIO \- No such device or address"
224This device is not available. Either the driver does not support it at all,
225or the hardware isn't available, i.e. accessing the second disk on a system
226with only one disk.
227.IP "EACCES \- Permission denied"
228This error may cause a lot of head scratching if
229.B ls \-l
230shows a device file to be writable. The media you are trying to access is
231simply physically write protected!
232.IP "EINVAL \- Invalid argument"
233Devices may not like reads or writes that are not block multiples, or very
234big transfers, etc. The device manual page should list the limits.
235.IP "EIO \- I/O error"
236This may be a real I/O error, i.e. a read or write on the device failing due
237to a media error. But it may also be the result of an operation that a
238device can't do, or an empty tape drive, etc.
239.SH NOTES
240Some devices are not present by default. The
241.BR MAKEDEV
242script knows how to make them.
243.SS "MS-DOS/Windows equivalents"
244The 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
249A: fd0
250B: fd1
251C: c0d0p0 (usually the first partition)
252D: c0d1p0, c0d2p0 (if it's another disk)
253D: c0d0p1s0 (if it's an extended partition)
254D: c0d1, c0d2, c0d3 (if it's a CD-ROM)
255CON console
256COM1 tty00 (UNIX counts from 0)
257LPT1 lp
258.fi
259.RE
260.SH AUTHOR
261Kees J. Bot (kjb@cs.vu.nl)
Note: See TracBrowser for help on using the repository browser.