On Wed, Sep 15 1999, Sam Skivington wrote:
> Hi. I hope this is the right mailing list for my question...and sorry to
> sound like a complete newbie...
>
> I can do this already with normal (zip and hard) disks, but I want to read
> data from a CD ROM device. not audio data, just normal (mode1) data.
>
> How do I go about it? I guess my first step is to use READ TOC, and later
> on I must use SEEK10 and, later still, READ10, but what is the complete
> sequence for finding out where and reading, say, the first block of data
> from track 1 (mode 1 format) on a cd?
>
> If there is any C code out there which can do it I'd be very grateful if
> someone could point me in the direction of it.
If it's normal data CD's that you are interested in (and it
appears so), then you can just use 'dd'. You can use something
like the below to get the exact LBA address of the start of
each track.
ioctl(fd, CDROMREADTOCHDR, &hdr);
/* get info on each track seperately */
for (i = hdr.cdth_trk0; i <= hdr.cdth_trk1; i++) {
entry.cdte_format = CDROM_LBA;
entry.cdte_track = i;
ioctl(fd, CDROMREADTOCENTRY, &entry);
printf("track %d, lba = %d\n", i, entry.cdte_addr.lba);
}
On a multisession CD with 3 data tracks :
track 1, lba = 0
track 2, lba = 48531
track 3, lba = 61981
And you might want to check ioctl return values :)
--
* Jens Axboe <[EMAIL PROTECTED]>
* Linux CD-ROM Maintainer
* http://www.kernel.dk
-
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to [EMAIL PROTECTED]