1 | .TH CONTROLLER 4
|
---|
2 | .SH NAME
|
---|
3 | controller, disk, tape, at, bios, esdi, aha1540, ncr810, dosfile, fatfile \- controllers, disks and tapes
|
---|
4 | .SH DESCRIPTION
|
---|
5 | .de SP
|
---|
6 | .if t .sp 0.4
|
---|
7 | .if n .sp
|
---|
8 | ..
|
---|
9 | The
|
---|
10 | .BI c n *
|
---|
11 | family of devices refer to drivers that control disks, disk like devices,
|
---|
12 | and tapes. MINIX 3 contains a number of drivers for several different
|
---|
13 | controllers. These controllers can have disks, cdroms and tapes attached to
|
---|
14 | them. Boot Monitor variables specify which drivers are activated using
|
---|
15 | the variables
|
---|
16 | .BR c0 ,
|
---|
17 | .BR c1 ,
|
---|
18 | etc. The names of the devices in
|
---|
19 | .BR /dev
|
---|
20 | that correspond with the driver for controller 0 are all named beginning
|
---|
21 | with
|
---|
22 | .BR c0 .
|
---|
23 | .PP
|
---|
24 | For each controller, the minor device numbers are organized as follows:
|
---|
25 | .PP
|
---|
26 | .RS
|
---|
27 | .nf
|
---|
28 | .ta +\w'122-127nnmm'u +\w'd0p0s0nnmm'u +\w'disk 0, part 0, subpart 0nnmm'u
|
---|
29 | .ft B
|
---|
30 | minor device what? obsolete
|
---|
31 | .ft P
|
---|
32 | 0 d0 disk 0 hd0
|
---|
33 | 1 d0p0 disk 0, partition 0 hd1
|
---|
34 | 2 d0p1 disk 0, partition 1 hd2
|
---|
35 | 3 d0p2 disk 0, partition 2 hd3
|
---|
36 | 4 d0p3 disk 0, partition 3 hd4
|
---|
37 | 5 d1 disk 1 hd5
|
---|
38 | 6 d1p0 disk 1, partition 0 hd6
|
---|
39 | 7 d1p1 disk 1, partition 1 hd7
|
---|
40 | 8 d1p2 disk 1, partition 2 hd8
|
---|
41 | 9 d1p3 disk 1, partition 3 hd9
|
---|
42 | \&... ...
|
---|
43 | 39 d7p3 disk 7, partition 3 hd39
|
---|
44 | .SP
|
---|
45 | 64 t0n tape 0, non-rewinding
|
---|
46 | 65 t0 tape 0, rewind on close
|
---|
47 | 66 t1n tape 1, non-rewinding
|
---|
48 | 67 t1 tape 1, rewind on close
|
---|
49 | \&... ...
|
---|
50 | 78 t7n tape 7, non-rewinding
|
---|
51 | 79 t7 tape 7, rewind on close
|
---|
52 | .SP
|
---|
53 | 120 r0 raw access device 0
|
---|
54 | 121 r1 raw access device 1
|
---|
55 | \&... ...
|
---|
56 | 127 r7 raw access device 7
|
---|
57 | .SP
|
---|
58 | 128 d0p0s0 disk 0, part 0, subpart 0 hd1a
|
---|
59 | 129 d0p0s1 disk 0, part 0, subpart 1 hd1b
|
---|
60 | 130 d0p0s2 disk 0, part 0, subpart 2 hd1c
|
---|
61 | 131 d0p0s3 disk 0, part 0, subpart 3 hd1d
|
---|
62 | 132 d0p1s0 disk 0, part 1, subpart 0 hd2a
|
---|
63 | \&... ...
|
---|
64 | 144 d1p0s0 disk 1, part 0, subpart 0 hd6a
|
---|
65 | \&... ...
|
---|
66 | 255 d7p3s3 disk 7, part 3, subpart 3 hd39d
|
---|
67 | .fi
|
---|
68 | .RE
|
---|
69 | .PP
|
---|
70 | The device names in
|
---|
71 | .B /dev
|
---|
72 | also name the controller, of course, so the usual place for the MINIX 3
|
---|
73 | root device, the first subpartition of the second partition of disk 0 on
|
---|
74 | controller 0 is
|
---|
75 | .BR /dev/c0d0p1s0 .
|
---|
76 | Note that everything is numbered from 0! The first controller is controller
|
---|
77 | 0, the first disk is disk 0, etc. So the second partition is
|
---|
78 | .BR p1 .
|
---|
79 | .PP
|
---|
80 | The fourth column in the table above shows the disk devices names that were
|
---|
81 | used by previous versions of MINIX 3 for what is now controller 0. These
|
---|
82 | devices are no longer present in
|
---|
83 | .BR /dev .
|
---|
84 | .SS Disks
|
---|
85 | Most disks are arrays of 512 byte sectors. The disk devices are normally
|
---|
86 | block devices, which means they are block buffered by the MINIX 3 file system
|
---|
87 | cache using 1024 byte blocks. The FS cache allows I/O at any byte offset,
|
---|
88 | and takes care of cutting and pasting incomplete blocks together. If one
|
---|
89 | creates a character device for a disk device, then I/O must be in multiples
|
---|
90 | of the disk block size.
|
---|
91 | .PP
|
---|
92 | For each disk there is a device that covers the entire disk, these are named
|
---|
93 | .BR c0d0 ,
|
---|
94 | .BR c0d1 ,
|
---|
95 | etc, up to
|
---|
96 | .B c0d7
|
---|
97 | for controller 0. If a partition table is placed in the first sector of the
|
---|
98 | disk, then the disk is subdivided into regions named partitions. Up to four
|
---|
99 | partitions may be defined, named
|
---|
100 | .BR c0d0p0
|
---|
101 | to
|
---|
102 | .BR c0d0p3
|
---|
103 | for disk 0 on controller 0. To make things interesting you can also place a
|
---|
104 | partition table in the first sector of a MINIX 3 partition, which divides the
|
---|
105 | partition into up to four subpartitions. Normally MINIX 3 is installed into a
|
---|
106 | single partition, with the root, swap and /usr file systems in subpartitions.
|
---|
107 | .PP
|
---|
108 | If a partition is an extended partition then it contains a linked list of
|
---|
109 | partition tables each of which may specify a logical partition. Up to four
|
---|
110 | of these logical partitions are presented by the driver as subpartitions of
|
---|
111 | the extended partition.
|
---|
112 | .PP
|
---|
113 | A sector containing a partition table starts with 446 bytes of boot code,
|
---|
114 | followed by four partition table entries of 16 bytes each, and ends with
|
---|
115 | the magic number 0xAA55 (little endian, so first 0x55 then 0xAA.) Partition
|
---|
116 | table information is defined in <ibm/partition.h>:
|
---|
117 | .PP
|
---|
118 | .nf
|
---|
119 | .ta +2n +29n +37n
|
---|
120 | /* Description of entry in the partition table. */
|
---|
121 |
|
---|
122 | struct part_entry {
|
---|
123 | unsigned char bootind; /* boot indicator 0/ACTIVE_FLAG */
|
---|
124 | unsigned char start_head; /* head value for first sector */
|
---|
125 | unsigned char start_sec; /* sector value + high 2 cyl bits */
|
---|
126 | unsigned char start_cyl; /* low 8 cylinder bits */
|
---|
127 | unsigned char sysind; /* system indicator */
|
---|
128 | unsigned char last_head; /* h/s/c for the last sector */
|
---|
129 | unsigned char last_sec;
|
---|
130 | unsigned char last_cyl;
|
---|
131 | unsigned long lowsec; /* logical first sector */
|
---|
132 | unsigned long size; /* size of partition in sectors */
|
---|
133 | };
|
---|
134 |
|
---|
135 | .ta +24n +7n +37n
|
---|
136 | #define ACTIVE_FLAG 0x80 /* value for active in bootind field */
|
---|
137 | #define NR_PARTITIONS 4 /* number of entries in table */
|
---|
138 | #define PART_TABLE_OFF 0x1BE /* offset of table in boot sector */
|
---|
139 |
|
---|
140 | /* Partition types (sysind). */
|
---|
141 | #define NO_PART 0x00 /* unused entry */
|
---|
142 | #define MINIX_PART 0x81 /* MINIX 3 partition type */
|
---|
143 | .fi
|
---|
144 | .PP
|
---|
145 | The cylinder numbers are encoded in a very strange way, bits 8 and 9 are
|
---|
146 | in the high two bits of the sector number. The sector numbers count from 1,
|
---|
147 | not 0! More useful are the lowsec and size fields however, they simply give
|
---|
148 | the location of the partition as an absolute sector offset and length within
|
---|
149 | the drive.
|
---|
150 | .PP
|
---|
151 | The partition table entry defined above is specific to IBM type disks. The
|
---|
152 | device drivers use another partition entry structure to pass information on
|
---|
153 | a partition. This is what <minix/partition.h> looks like:
|
---|
154 | .sp
|
---|
155 | .nf
|
---|
156 | .ta +2n +25n
|
---|
157 | struct partition {
|
---|
158 | u64_t base; /* byte offset to the partition start */
|
---|
159 | u64_t size; /* number of bytes in the partition */
|
---|
160 | unsigned cylinders; /* disk geometry for partitioning */
|
---|
161 | unsigned heads;
|
---|
162 | unsigned sectors;
|
---|
163 | };
|
---|
164 | .fi
|
---|
165 | .PP
|
---|
166 | The base and size fields are the byte offset and length of a partition.
|
---|
167 | The geometry of the disk is also given for the benefit of
|
---|
168 | partition table editors. This information can be obtained from an open disk
|
---|
169 | device with the call:
|
---|
170 | .sp
|
---|
171 | .RS
|
---|
172 | .ft B
|
---|
173 | ioctl(\fIfd\fP, DIOCGETP, &\fIentry\fP);
|
---|
174 | .ft R
|
---|
175 | .RE
|
---|
176 | .sp
|
---|
177 | One can change the placement of the device to the lowsec and size fields of
|
---|
178 | .I entry
|
---|
179 | by using the
|
---|
180 | .B DIOCSETP
|
---|
181 | call instead. Only the base and size fields are used for
|
---|
182 | .BR DIOCSETP .
|
---|
183 | .PP
|
---|
184 | The partition tables when read from disk by the driver are checked and
|
---|
185 | truncated to fit within the primary partition or drive. The first sector
|
---|
186 | is normally left free for the partition table.
|
---|
187 | .PP
|
---|
188 | The partition tables are read when the in-use count (opens and mounts)
|
---|
189 | changes from 0 to 1. So an idle disk is automatically repartitioned on the
|
---|
190 | next access. This means that DIOCSETP only has effect if the disk is in
|
---|
191 | use.
|
---|
192 | .SS "Disk-like devices"
|
---|
193 | Devices like a CD-ROM are treated as read-only disks, and can be accessed
|
---|
194 | using disk devices. A CD-ROM usually has a block size of 2048 bytes, but
|
---|
195 | the driver knows this, and allows one to read at any byte offset by reading
|
---|
196 | what isn't needed into a scratch buffer.
|
---|
197 | .SS Tapes
|
---|
198 | There are two kinds of tape devices: Non-rewinding, and rewind-on-close.
|
---|
199 | The non-rewinding devices treat the tape as a series of files. The
|
---|
200 | rewind-on-close devices look at the tape as a single file, and when you close
|
---|
201 | such a device the tape is told to rewind.
|
---|
202 | See
|
---|
203 | .BR mt (1),
|
---|
204 | and
|
---|
205 | .BR mtio (4)
|
---|
206 | for a description of the commands that may be sent to the tape, either from
|
---|
207 | the command prompt or from a program.
|
---|
208 | .PP
|
---|
209 | There are two kinds of tape drives: Fixed and variable block size tape
|
---|
210 | drives. Examples of the first kind are cartridge
|
---|
211 | tapes, with a fixed 512 bytes block size. An Exabyte tape drive has a
|
---|
212 | variable block size, with a minimum of 1 byte and a maximum of 245760 bytes
|
---|
213 | (see the documentation of such devices.)
|
---|
214 | The maximum is truncated to 32767 bytes for Minix-86 and 61440 bytes for
|
---|
215 | Minix-vmd, because the driver can't move more bytes in a single request.
|
---|
216 | .PP
|
---|
217 | A read or write to a fixed block size tape must be a precise multiple of the
|
---|
218 | block size, any other count gives results in an I/O error. A read from a
|
---|
219 | variable block sized tape must be large enough to accept the block that is
|
---|
220 | read, otherwise an I/O error will be returned. A write can be any size
|
---|
221 | above the minimum, creating a block of that size. If the write count is
|
---|
222 | larger than the maximum block size then more blocks are written until the
|
---|
223 | count becomes zero. The last block must be larger than the minimum of
|
---|
224 | course. (This minimum is often as small as 1 byte, as for the Exabyte.)
|
---|
225 | .PP
|
---|
226 | The
|
---|
227 | .B mt blksize
|
---|
228 | command may be used to select a fixed block size for a variable block sized
|
---|
229 | tape. This will speed up I/O considerably for small block sizes. (Some
|
---|
230 | systems can only use fixed mode and will write an Exabyte tape with 1024
|
---|
231 | byte blocks, which read very slow in variable mode.)
|
---|
232 | .PP
|
---|
233 | A tape is a sequence of blocks and filemarks. A tape may be opened and
|
---|
234 | blocks may be read from it upto a filemark, after that all further reads
|
---|
235 | return 0. After the tape is closed and reopened one can read the blocks
|
---|
236 | following the filemark if using a non-rewinding device. This makes the tape
|
---|
237 | look like a sequence of files.
|
---|
238 | .PP
|
---|
239 | If a tape has been written to or opened in write-only mode, then a filemark
|
---|
240 | is written if the tape is closed or if a space command is issued. No extra
|
---|
241 | filemark is written if the drive is instructed to write filemarks.
|
---|
242 | .SS "Raw Access Devices"
|
---|
243 | Under Minix-vmd one can use the raw access devices to program a SCSI
|
---|
244 | device entirely from user mode. The disk and tape devices probe for devices
|
---|
245 | when opened, start disks and load tapes, but the raw access devices do
|
---|
246 | nothing at all. Given an open file descriptor to any SCSI character device
|
---|
247 | (not just the raw access devices) one can use the following ioctl:
|
---|
248 | .PP
|
---|
249 | .RS
|
---|
250 | ioctl(fd, SCIOCCMD, &scsicmd)
|
---|
251 | .RE
|
---|
252 | .PP
|
---|
253 | The structure whose address is passed as the third argument is defined
|
---|
254 | in <sys/scsi.h> as follows:
|
---|
255 | .PP
|
---|
256 | .RS
|
---|
257 | .nf
|
---|
258 | struct scsicmd {
|
---|
259 | void *cmd;
|
---|
260 | size_t cmdlen;
|
---|
261 | void *buf;
|
---|
262 | size_t buflen;
|
---|
263 | void *sense;
|
---|
264 | size_t senselen;
|
---|
265 | int dir;
|
---|
266 | };
|
---|
267 | .fi
|
---|
268 | .RE
|
---|
269 | .PP
|
---|
270 | .B Cmd
|
---|
271 | and
|
---|
272 | .B cmdlen
|
---|
273 | hold the address and length of an object holding a Group 0 or Group 1
|
---|
274 | SCSI command. The next two fields describe a buffer of at most 8 kilobytes
|
---|
275 | used in the data in or out phase.
|
---|
276 | .B Dir
|
---|
277 | is 0 if data is to be read from the device, 1 if data is written to the
|
---|
278 | device. If the ioctl succeeds then 0 is returned, otherwise -1 with
|
---|
279 | .B errno
|
---|
280 | set to
|
---|
281 | .B EIO
|
---|
282 | and the request sense info returned in the buffer described by the sense and
|
---|
283 | senselen fields. If the sense key is zero on error then a host adapter
|
---|
284 | error occurred, this means that the device is most likely turned off or not
|
---|
285 | present.
|
---|
286 | .SH DRIVERS
|
---|
287 | By setting the Boot variables
|
---|
288 | .BR c0
|
---|
289 | to
|
---|
290 | .BR c3
|
---|
291 | under MINIX 3, or
|
---|
292 | .BR c0
|
---|
293 | to
|
---|
294 | .BR c4
|
---|
295 | under Minix-vmd one attaches a set of disk and tape devices to a driver.
|
---|
296 | See
|
---|
297 | .BR boot (8)
|
---|
298 | for a list of boot variables that configure each of these drivers.
|
---|
299 | The following drivers are available:
|
---|
300 | .SS at
|
---|
301 | The standard IBM/AT disk driver that also supports IDE disks. This is the
|
---|
302 | default driver for controller 0 on AT class machines. (Most PCs are in that
|
---|
303 | class.)
|
---|
304 | .SS bios
|
---|
305 | A disk driver that uses BIOS calls to do disk I/O. This is the default
|
---|
306 | driver on anything but an AT. (Old XTs and PS/2s.) On an XT this is the
|
---|
307 | best driver you can use, but on any other machine this driver may be
|
---|
308 | somewhat slow, because the system has to switch out of protected mode to
|
---|
309 | make a BIOS call. On a fast enough machine with a high enough setting of
|
---|
310 | DMA_SECTORS (see
|
---|
311 | .BR config (8))
|
---|
312 | it works well enough.
|
---|
313 | .SS esdi
|
---|
314 | A hard disk driver for use on some PS/2 models.
|
---|
315 | .SS "xt \fR(MINIX 3 only)"
|
---|
316 | A hard disk driver for IBM/XT type hard disks. Useful for old 286 based
|
---|
317 | machines that have such a disk. On XTs you are better off with the
|
---|
318 | .B bios
|
---|
319 | driver.
|
---|
320 | .SS aha1540
|
---|
321 | A SCSI driver for the Adaptec 1540 host adapter family, which includes the
|
---|
322 | 1540, 1540A, 1540B, 1540C, 1540CF, 1640, and 1740. Also supported is the
|
---|
323 | compatible BusLogic 545.
|
---|
324 | .SS ncr810
|
---|
325 | This will eventually become a Symbios 810 SCSI driver. (Formerly owned by
|
---|
326 | NCR.) KJB has read the docs on this card three times, but has still done
|
---|
327 | nothing, the lazy bum.
|
---|
328 | .SS dosfile
|
---|
329 | The "DOS file as disk" driver that is used when MINIX 3 is running
|
---|
330 | under DOS. It treats a large DOS file as a MINIX 3 disk. Only primary
|
---|
331 | partitions are supported, there are no subpartitions. This is the default
|
---|
332 | driver when MINIX 3 is started under DOS.
|
---|
333 | .SS fatfile
|
---|
334 | Uses a large file on a FAT file system as a disk. It needs one of the other
|
---|
335 | disk drivers to do the actual I/O. This driver only knows how to interpret
|
---|
336 | a FAT file system to find the file to use. With a fast native disk driver
|
---|
337 | this driver is much faster than the
|
---|
338 | .B dosfile
|
---|
339 | driver.
|
---|
340 | .SH FILES
|
---|
341 | .TP 25
|
---|
342 | /dev/c*d*
|
---|
343 | Disks devices.
|
---|
344 | .TP
|
---|
345 | /dev/c*d*p*
|
---|
346 | Partitions.
|
---|
347 | .TP
|
---|
348 | /dev/c*d*p*s*
|
---|
349 | Subpartitions.
|
---|
350 | .TP
|
---|
351 | /dev/c*t*n, /dev/c*t*
|
---|
352 | Tapes.
|
---|
353 | .TP
|
---|
354 | /dev/c*r*
|
---|
355 | Raw access devices.
|
---|
356 | .SH "SEE ALSO"
|
---|
357 | .BR dd (1),
|
---|
358 | .BR mt (1),
|
---|
359 | .BR eject (1),
|
---|
360 | .BR ioctl (2),
|
---|
361 | .BR int64 (3),
|
---|
362 | .BR mtio (4),
|
---|
363 | .BR boot (8),
|
---|
364 | .BR config (8),
|
---|
365 | .BR monitor (8),
|
---|
366 | .BR part (8),
|
---|
367 | .BR repartition (8).
|
---|
368 | .SH BUGS
|
---|
369 | The subpartitioning is incompatible with the MS-DOS method of extended
|
---|
370 | partitions. The latter does not map well to the sparse minor device number
|
---|
371 | space.
|
---|
372 | .PP
|
---|
373 | The primary partition table is sorted by lowsec like MS-DOS does, subpartition
|
---|
374 | tables are not. Just think about what happens when you delete a partition in
|
---|
375 | the MS-DOS scheme.
|
---|
376 | .PP
|
---|
377 | Don't move a partition that is mounted or kept open by some process. The
|
---|
378 | file system may write cached blocks to the new location.
|
---|
379 | .PP
|
---|
380 | The BIOS driver is not slow at all on a buffered disk.
|
---|
381 | .PP
|
---|
382 | Some IDE disks send an interrupt when they spin down under hardware power
|
---|
383 | management. The driver acknowledges the interrupt as it is supposed to do by
|
---|
384 | reading the status register. The disk then spins up again... You have to
|
---|
385 | disable the spin down in the computer setup to fix the problem.
|
---|
386 | .SH AUTHOR
|
---|
387 | Kees J. Bot (kjb@cs.vu.nl)
|
---|