nrelease - fix/improve livecd
[dragonfly.git] / share / man / man4 / cd.4
1 .\" Copyright (c) 1996
2 .\"     Julian Elischer <julian@FreeBSD.org>.  All rights reserved.
3 .\"
4 .\" Redistribution and use in source and binary forms, with or without
5 .\" modification, are permitted provided that the following conditions
6 .\" are met:
7 .\" 1. Redistributions of source code must retain the above copyright
8 .\"    notice, this list of conditions and the following disclaimer.
9 .\"
10 .\" 2. Redistributions in binary form must reproduce the above copyright
11 .\"    notice, this list of conditions and the following disclaimer in the
12 .\"    documentation and/or other materials provided with the distribution.
13 .\"
14 .\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
15 .\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
16 .\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
17 .\" ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
18 .\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
19 .\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
20 .\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
21 .\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
22 .\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
23 .\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
24 .\" SUCH DAMAGE.
25 .\"
26 .\" $FreeBSD: src/share/man/man4/cd.4,v 1.17.2.8 2003/06/03 14:32:09 hmp Exp $
27 .\"
28 .Dd February 18, 2019
29 .Dt CD 4
30 .Os
31 .Sh NAME
32 .Nm cd
33 .Nd SCSI CD-ROM driver
34 .Sh SYNOPSIS
35 .Cd device cd
36 .Cd device cd1 at scbus0 target 4 unit 0
37 .Cd "options CHANGER_MIN_BUSY_SECONDS=3"
38 .Cd "options CHANGER_MAX_BUSY_SECONDS=11"
39 .Sh DESCRIPTION
40 The
41 .Nm
42 driver provides support for a
43 .Tn SCSI
44 .Tn CD-ROM
45 (Compact Disc-Read Only Memory) drive.
46 In an attempt to look like a regular disk, the
47 .Nm
48 driver synthesizes a partition table, with one partition covering the entire
49 .Tn CD-ROM .
50 It is possible to modify this partition table using
51 .Xr disklabel 8 ,
52 but it will only last until the
53 .Tn CD-ROM
54 is unmounted.
55 In general the interfaces are similar to those described by
56 .Xr ad 4
57 and
58 .Xr da 4 .
59 .Pp
60 As the
61 .Tn SCSI
62 adapter is probed during boot, the
63 .Tn SCSI
64 bus is scanned for devices.
65 Any devices found which answer as CDROM
66 (type 5) or WORM (type 4) type devices will be `attached' to the
67 .Nm
68 driver.
69 Prior to
70 .Fx 2.1 ,
71 the first device found will be attached as
72 .Li cd0
73 the next,
74 .Li cd1 ,
75 etc.
76 Beginning in
77 .Fx 2.1
78 it is possible to specify what cd unit a device should
79 come on line as; refer to
80 .Xr scsi 4
81 for details on kernel configuration.
82 .Pp
83 The
84 .Cd target
85 string is followed by the device's standard
86 .Tn SCSI
87 device ID number.
88 The
89 .Cd unit
90 string is followed by the Logical Unit Number
91 .Pq Tn LUN
92 of the
93 .Tn SCSI
94 device's sub-device, if any, or zero.
95 .Pp
96 The system utility
97 .Xr disklabel 8
98 may be used to read the synthesized
99 disk label
100 structure, which will contain correct figures for the size of the
101 .Tn CD-ROM
102 should that information be required.
103 .Sh IOCTLS
104 The following
105 .Xr ioctl 2
106 calls which apply to
107 .Tn SCSI
108 .Tn CD-ROM
109 drives are defined
110 in the header files
111 .In sys/cdio.h
112 and
113 .In sys/disklabel.h .
114 .Bl -tag -width ".Dv CDIOCREADSUBCHANNEL"
115 .It Dv DIOCGDINFO
116 .It Dv DIOCSDINFO
117 .Pq Li "struct disklabel"
118 Read or write the in-core copy of the disklabel for the
119 drive.
120 The disklabel is initialized with information
121 read from the scsi inquiry commands, and should be the same as
122 the information printed at boot.
123 This structure is defined in
124 .Xr disklabel 5 .
125 .It Dv CDIOCPLAYTRACKS
126 .Pq Li "struct ioc_play_track"
127 Start audio playback given a track address and length.
128 The structure is defined as follows:
129 .Bd -literal -offset indent
130 struct ioc_play_track
131 {
132         u_char  start_track;
133         u_char  start_index;
134         u_char  end_track;
135         u_char  end_index;
136 };
137 .Ed
138 .It Dv CDIOCPLAYBLOCKS
139 .Pq Li "struct ioc_play_blocks"
140 Start audio playback given a block address and length.
141 The structure is defined as follows:
142 .Bd -literal -offset indent
143 struct ioc_play_blocks
144 {
145         int     blk;
146         int     len;
147 };
148 .Ed
149 .It Dv CDIOCPLAYMSF
150 .Pq Li "struct ioc_play_msf"
151 Start audio playback given a `minutes-seconds-frames' address and
152 length.
153 The structure is defined as follows:
154 .Bd -literal -offset indent
155 struct ioc_play_msf
156 {
157         u_char  start_m;
158         u_char  start_s;
159         u_char  start_f;
160         u_char  end_m;
161         u_char  end_s;
162         u_char  end_f;
163 };
164 .Ed
165 .It Dv CDIOCREADSUBCHANNEL
166 .Pq Li "struct ioc_read_subchannel"
167 Read information from the subchannel at the location specified by this
168 structure:
169 .Bd -literal -offset indent
170 struct ioc_read_subchannel {
171         u_char address_format;
172 #define CD_LBA_FORMAT   1
173 #define CD_MSF_FORMAT   2
174         u_char data_format;
175 #define CD_SUBQ_DATA            0
176 #define CD_CURRENT_POSITION     1
177 #define CD_MEDIA_CATALOG        2
178 #define CD_TRACK_INFO           3
179         u_char track;
180         int     data_len;
181         struct  cd_sub_channel_info *data;
182 };
183 .Ed
184 .It Dv CDIOREADTOCHEADER
185 .Pq Li "struct ioc_toc_header"
186 Return summary information about the table of contents for the mounted
187 .Tn CD-ROM .
188 The information is returned into the following structure:
189 .Bd -literal -offset indent
190 struct ioc_toc_header {
191         u_short len;
192         u_char  starting_track;
193         u_char  ending_track;
194 };
195 .Ed
196 .It Dv CDIOREADTOCENTRYS
197 .Pq Li "struct ioc_read_toc_entry"
198 Return information from the table of contents entries mentioned.
199 .Pq Yes, this command name is misspelled.
200 The argument structure is defined as follows:
201 .Bd -literal -offset indent
202 struct ioc_read_toc_entry {
203         u_char  address_format;
204         u_char  starting_track;
205         u_short data_len;
206         struct  cd_toc_entry *data;
207 };
208 .Ed
209 The requested data is written into an area of size
210 .Li data_len
211 and pointed to by
212 .Li data .
213 .It Dv CDIOCSETPATCH
214 .Pq Li "struct ioc_patch"
215 Attach various audio channels to various output channels.
216 The argument structure is defined thusly:
217 .Bd -literal -offset indent
218 struct ioc_patch {
219         u_char  patch[4];
220         /* one for each channel */
221 };
222 .Ed
223 .It Dv CDIOCGETVOL
224 .It Dv CDIOCSETVOL
225 .Pq Li "struct ioc_vol"
226 Get (set) information about the volume settings of the output channels.
227 The argument structure is as follows:
228 .Bd -literal -offset indent
229 struct  ioc_vol
230 {
231         u_char  vol[4];
232         /* one for each channel */
233 };
234 .Ed
235 .It Dv CDIOCSETMONO
236 Patch all output channels to all source channels.
237 .It Dv CDIOCSETSTEREO
238 Patch left source channel to the left output channel and the right
239 source channel to the right output channel.
240 .It Dv CDIOCSETMUTE
241 Mute output without changing the volume settings.
242 .It Dv CDIOCSETLEFT
243 .It Dv CDIOCSETRIGHT
244 Attach both output channels to the left (right) source channel.
245 .It Dv CDIOCSETDEBUG
246 .It Dv CDIOCCLRDEBUG
247 Turn on (off) debugging for the appropriate device.
248 .It Dv CDIOCPAUSE
249 .It Dv CDIOCRESUME
250 Pause (resume) audio play, without resetting the location of the read-head.
251 .It Dv CDIOCRESET
252 Reset the drive.
253 .It Dv CDIOCSTART
254 .It Dv CDIOCSTOP
255 Tell the drive to spin-up (-down) the
256 .Tn CD-ROM .
257 .It Dv CDIOCALLOW
258 .It Dv CDIOCPREVENT
259 Tell the drive to allow (prevent) manual ejection of the
260 .Tn CD-ROM
261 disc.  Not all drives support this feature.
262 .It Dv CDIOCEJECT
263 Eject the
264 .Tn CD-ROM .
265 .It Dv CDIOCCLOSE
266 Tell the drive to close its door and load the media.
267 Not all drives support this feature.
268 .El
269 .Sh NOTES
270 When a
271 .Tn CD-ROM
272 is changed in a drive controlled by the
273 .Nm
274 driver, then the act of changing the media will invalidate the
275 disklabel and information held within the kernel.
276 To stop corruption,
277 all accesses to the device will be discarded until there are no more
278 open file descriptors referencing the device.
279 During this period, all
280 new open attempts will be rejected.
281 When no more open file descriptors
282 reference the device, the first next open will load a new set of
283 parameters (including disklabel) for the drive.
284 .Pp
285 The audio code in the
286 .Nm
287 driver only support
288 .Tn SCSI-2
289 standard audio commands.
290 Because many
291 .Tn CD-ROM
292 manufacturers have not followed the standard, there are many
293 .Tn CD-ROM
294 drives for which audio will not work.
295 Some work is planned to support
296 some of the more common `broken'
297 .Tn CD-ROM
298 drives; however, this is not yet under way.
299 .Sh CHANGER OPERATION
300 This driver has built-in support for LUN-based CD changers.
301 A LUN-based CD
302 changer is a drive that can hold two or more CDs, but only has one CD
303 player mechanism.
304 Each CD in the drive shows up as a separate logical unit
305 on the
306 .Tn SCSI
307 bus.  The
308 .Nm
309 driver automatically recognizes LUN-based changers, and routes commands for
310 changers through an internal scheduler.
311 The scheduler prevents changer
312 "thrashing", which is caused by sending commands to different LUNs in the
313 changer at the same time.
314 .Pp
315 The scheduler honors minimum and maximum time
316 quanta that the driver will spend on a particular LUN.
317 The minimum time
318 is the guaranteed minimum amount of time that the driver will spend on a
319 given LUN, even if there is no outstanding I/O for that LUN.
320 The maximum
321 time is the maximum amount of time the changer will spend on a LUN if there
322 is outstanding I/O for another LUN.
323 If there is no outstanding I/O for
324 another LUN, the driver will allow indefinite access to a given LUN.
325 .Pp
326 The minimum and maximum time quanta are configurable via kernel options and
327 also via sysctl variables.
328 The kernel options are:
329 .Pp
330 .Bl -item -compact
331 .It
332 .Cd "options ""CHANGER_MIN_BUSY_SECONDS=3"""
333 .It
334 .Cd "options ""CHANGER_MAX_BUSY_SECONDS=11"""
335 .El
336 .Pp
337 The sysctl variables are:
338 .Pp
339 .Bl -item -compact
340 .It
341 .Va kern.cam.cd.changer.min_busy_seconds
342 .It
343 .Va kern.cam.cd.changer.max_busy_seconds
344 .El
345 .Pp
346 It is suggested that the user try experimenting with the minimum and
347 maximum timeouts via the sysctl variables to arrive at the proper values
348 for your changer.
349 Once you have settled on the proper timeouts for your
350 changer, you can then put them in your kernel config file.
351 .Pp
352 If your system does have a LUN-based changer, you may notice that the
353 probe messages for the various LUNs of the changer will continue to appear
354 while the boot process is going on.
355 This is normal, and is caused by the
356 changer scheduling code.
357 .Sh FILES
358 .Bl -tag -width /dev/cd[0-9][a-h] -compact
359 .It Pa /dev/cd[0-9][a-h]
360 raw mode
361 .Tn CD-ROM
362 devices
363 .El
364 .Sh DIAGNOSTICS
365 None.
366 .Sh SEE ALSO
367 .Xr da 4 ,
368 .Xr scsi 4 ,
369 .Xr disklabel 5 ,
370 .Xr disklabel 8 ,
371 .Xr cd 9
372 .Sh HISTORY
373 This
374 .Nm
375 driver is based upon the
376 .Nm
377 driver written by Julian Elischer, which appeared in
378 .Bx 386 0.1 .
379 The
380 CAM version of the
381 .Nm
382 driver was written by Kenneth Merry and first appeared in
383 .Fx 3.0 .
384 .Sh BUGS
385 The names of the structures used for the third argument to
386 .Fn ioctl
387 were poorly chosen, and a number of spelling errors have survived in
388 the names of the
389 .Fn ioctl
390 commands.
391 .Pp
392 There is no mechanism currently to set different minimum and maximum
393 timeouts for different CD changers; the timeout values set by the kernel
394 options or the sysctl variables apply to all LUN-based CD changers in the
395 system.
396 It is possible to implement such support, but the sysctl
397 implementation at least would be rather inelegant, because of the current
398 inability of the sysctl code to handle the addition of nodes after compile
399 time.
400 Thus, it would take one dynamically sized sysctl variable and a
401 userland utility to get/set the timeout values.
402 Implementation of separate
403 timeouts for different CD devices in the kernel config file would likely
404 require modification of
405 .Xr config 8
406 to support the two timeouts when hardwiring
407 .Nm
408 devices.