.\" @(#)readcd.1	1.1 00/04/23 Copyright 1996 J. Schilling
.\" 
.\" This is free documentation; you can redistribute it and/or
.\" modify it under the terms of the GNU General Public License as
.\" published by the Free Software Foundation; either version 2 of
.\" the License, or (at your option) any later version.
.\"
.\" The GNU General Public License's references to "object code"
.\" and "executables" are to be interpreted as the output of any
.\" document formatting or typesetting system, including
.\" intermediate and printed output.
.\"
.\" This manual is distributed in the hope that it will be useful,
.\" but WITHOUT ANY WARRANTY; without even the implied warranty of
.\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
.\" GNU General Public License for more details.
.\"
.\" You should have received a copy of the GNU General Public
.\" License along with this manual; if not, write to the Free
.\" Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139,
.\" USA.
.\"
.if t .ds a \v'-0.55m'\h'0.00n'\z.\h'0.40n'\z.\v'0.55m'\h'-0.40n'a
.if t .ds o \v'-0.55m'\h'0.00n'\z.\h'0.45n'\z.\v'0.55m'\h'-0.45n'o
.if t .ds u \v'-0.55m'\h'0.00n'\z.\h'0.40n'\z.\v'0.55m'\h'-0.40n'u
.if t .ds A \v'-0.77m'\h'0.25n'\z.\h'0.45n'\z.\v'0.77m'\h'-0.70n'A
.if t .ds O \v'-0.77m'\h'0.25n'\z.\h'0.45n'\z.\v'0.77m'\h'-0.70n'O
.if t .ds U \v'-0.77m'\h'0.30n'\z.\h'0.45n'\z.\v'0.77m'\h'-0.75n'U
.if t .ds s \\(*b
.if t .ds S SS
.if n .ds a ae
.if n .ds o oe
.if n .ds u ue
.if n .ds s sz
.TH READCD 1 "Version 1.8.1" "J\*org Schilling" "Schily\'s USER COMMANDS"
.SH NAME
readcd \- read or write data Compact Discs
.SH SYNOPSIS
.B readcd
.BI dev= device
[
.I options
]

.SH DESCRIPTION
.B Readcd
is used to read or write Compact Discs.
.PP
The
.I device
refers to
.IR scsibus / target / lun
of the drive. Communication on 
.I SunOS
is done with the SCSI general driver
.B scg.
Other operating systems are using a library simulation of this driver.
Possible syntax is:
.B dev=
.IR scsibus , target , lun
or
.B dev=
.IR target , lun .
In the latter case, the drive has to be connected to the default 
SCSI bus of the machine.
.IR Scsibus ,
.I target 
and 
.I lun
are integer numbers. 
Some operating systems or SCSI transport implementations may require to
specify a filename in addition.
In this case the corect syntax for the device is:
.B dev=
.IR devicename : scsibus , target , lun
or
.B dev=
.IR devicename : target , lun .
If the name of the device node that has been specified on such a system
referres to exactly one SCSI device, a shorthand in the form
.B dev=
.IR devicename : @
or
.B dev=
.IR devicename : @ , lun
may be used instead of
.B dev=
.IR devicename : scsibus , target , lun .

.PP
To make 
.B readcd
portable to all \s-2UNIX\s0 platforms, the syntax
.B dev=
.IR devicename : scsibus , target , lun
is preferred as is hides OS specific knowledge about device names from the user.
A specific OS must not necessarily support a way to specify a real device file name nor a
way to specify 
.IR scsibus , target , lun .

.PP
.I Scsibus 
0 is the default SCSI bus on the machine. Watch the boot messages for more 
information or look into 
.B /var/adm/messages 
for more information about the SCSI configuration of your machine.
If you have problems to figure out what values for 
.IR scsibus , target , lun
should be used, try the 
.B \-scanbus
option of 
.BR cdrecord .

.SH OPTIONS
.PP
If no options except the 
.I dev=
option have been specified, 
.B readcd
goes into intercative mode.
Select a primary function and then follow the instructions.
.PP
.TP
.B \-version
Print version information and exit.
.TP
.B \-v
Increment the level of general verbosity by one.
.TP
.B \-V
Increment the verbose level in respect of SCSI command transport by one.
This helps to debug problems
during the writing process, that occur in the drive.
If you get incomprehensible error messages you should use this flag
to get more detailed output.
.B \-VV
will show data buffer content in addition.
Using
.B \-V
or
.B \-VV
slows down the process and may be the reason for a buffer underrun.
.TP
.B \-w
Switch to write mode. If this option is not present,
.B readcd
reads from the specified device.
.TP
.BI sectors= range
Specify a sector range that should be read.
The range is specified by the starting sector number, a minus sign and the
ending sector number.

.SH EXAMPLES
.PP
For all examples below, it will be assumed that the drive is
connected to the primary SCSI bus of the machine. The SCSI target id is
set to 2.
.PP
To read the complete media from a CD-ROM writing the data to the file
.IR cdimage.raw :
.PP
    readcd dev=2,0 f=cdimage.raw
.PP
To read sectors from range 150 ... 10000 from a CD-ROM writing the data to the file
.IR cdimage.raw :
.PP
    readcd dev=2,0 sectors=150-10000 f=cdimage.raw
.PP
To write the data from the file
.I cdimage.raw
(e.g. a filesystem image from 
.BR mkisofs )
to a DVD-RAM, call:
.PP
    readcd dev=2,0 -w f=cdimage.raw

.SH FILES
.SH SEE ALSO
.BR cdrecord (1),
.BR mkisofs (1),
.BR scg (7),
.BR fbk (7).

.SH NOTES
.PP
If you don't want to allow users to become root on your system,
.B readcd
may safely be installed suid root. This allows all users or a group of
users with no root privileges to use 
.B readcd.
.B Readcd
in this case will only allow access to CD-ROM type drives-
To give all user access to use 
.B readcd, 
enter:
.PP
	chown root /usr/local/bin/readcd
.br
	chmod 4711 /usr/local/bin/readcd
.PP
To give a restricted group of users access to 
.B readcd
enter:
.PP
	chown root /usr/local/bin/readcd
.br
	chgrp cdburners /usr/local/bin/readcd
.br
	chmod 4710 /usr/local/bin/readcd
.PP
and add a group 
.I cdburners
on your system.
.PP
Never give write permissions for non root users to the 
.I /dev/scg?
devices unless you would allow anybody to read/write/format
all your disks.
.PP
You should not connect old drives that do not support
disconnect/reconnect to either the SCSI bus that is connected to the
CD-Recorder or the source disk.
.PP
When using 
.B readcd
with the broken 
.B "Linux SCSI generic driver."
You should note that 
.B readcd
uses a hack, that tries to emulate the functionality of the scg driver.
Unfortunately, the sg driver on 
.B Linux
has several severe bugs:
.TP
\(bu
It cannot see if a SCSI command could not be sent at all.
.TP
\(bu
It cannot get the SCSI status byte. 
.B Readcd
for that reason cannot report failing SCSI commands in some
situations.
.TP
\(bu
It cannot get real DMA count of transfer. 
.B Readcd
cannot tell you if there is an DMA residual count.
.TP
\(bu
It cannot get number of bytes valid in auto sense data.
.B Readcd
cannot tell you if device transfers no sense data at all.
.TP
\(bu
It fetches to few data in auto request sense (CCS/SCSI-2/SCSI-3 needs >= 18).

.SH DIAGNOSTICS
.PP
.PP
A typical error message for a SCSI command looks like:
.sp
.RS
.nf
readcd: I/O error. test unit ready: scsi sendcmd: no error
CDB:  00 20 00 00 00 00
status: 0x2 (CHECK CONDITION)
Sense Bytes: 70 00 05 00 00 00 00 0A 00 00 00 00 25 00 00 00 00 00
Sense Key: 0x5 Illegal Request, Segment 0
Sense Code: 0x25 Qual 0x00 (logical unit not supported) Fru 0x0
Sense flags: Blk 0 (not valid)
.fi
.sp
.RE
The first line gives information about the transport of the command.
The text after the first colon gives the error text for the system call
from the view of the kernel. It usually is:
.B "I/O error
unless other problems happen. The next words contain a short description for
the SCSI command that fails. The rest of the line tells you if there were
any problems for the transport of the command over the SCSI bus.
.B "fatal error
means that it was not possible to transport the command (i.e. no device present
at the requested SCSI address).
.PP
The second line prints the SCSI command descriptor block for the failed command.
.PP
The third line gives information on the SCSI status code returned by the 
command, if the transport of the command succeeds. 
This is error information from the SCSI device.
.PP
The fourth line is a hex dump of the auto request sense information for the 
command.
.PP
The fifth line is the error text for the sense key if available, followed
by the segment number that is only valid if the command was a
.I copy
command. If the error message is not directly related to the current command,
the text
.I deferred error
is appended.
.PP
The sixth line is the error text for the sense code and the sense qualifier if available.
If the type of the device is known, the sense data is decoded from tables
in
.IR scsierrs.c " .
The text is followed by the error value for a field replaceable unit.
.PP
The seventh line prints the block number that is related to the failed command
and text for several error flags. The block number may not be valid.

.SH BUGS

.SH CREDITS

.SH "MAILING LISTS
If you want to actively take part on the development of cdrecord,
you may join the cdwriting mailing list by sending mail to:
.nf
.sp
	other-cdwrite-request@lists.debian.org
.sp
.fi
and include the word 
.I subscribe
in the body.
The mail address of the list is:
.nf
.sp
	cdwrite@lists.debian.org
.fi

.SH AUTHOR
.nf
J\*org Schilling
Seestr. 110
D-13353 Berlin
Germany
.fi
.PP
Additional information can be found on:
.br
http://www.fokus.gmd.de/usr/schilling/cdrecord.html
.PP
Mail bugs and suggestions to:
.PP
.B
joerg@schily.isdn.cs.tu-berlin.de
or
.B
js@cs.tu-berlin.de
or
.B
schilling@fokus.gmd.de