[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kern/47676: Off-by-one error in reported CD capacity means last sector cannot be read
The following reply was made to PR kern/47676; it has been noted by GNATS.
From: "Mark" <markk%clara.co.uk@localhost>
To: "Reinoud Zandijk" <reinoud%NetBSD.org@localhost>
Subject: Re: kern/47676: Off-by-one error in reported CD capacity means last
sector cannot be read
Date: Thu, 28 Mar 2013 19:08:18 -0000
On Thu, March 28, 2013 18:07, Reinoud Zandijk wrote:
> The real reason of the error might not even be in NetBSD's cd.c itself
> though i'm preparing a patch to cleanup things.
> What is going on is that the device is lying to you! The on disk low level
> format is quite overcomplex complete with sector data interleaving etc. it
> was also originally designed for audio.
> What can be done is on detection of a CD-R, adjust the size of the tracks
> as per definition of mmc; i might need to add 2 sectors.
When I noticed the bug, I was using an emulated CD drive, so there were no
strange real-CD-drive-related issues.
I read the SCSI-2 spec (s2-r10l.pdf) READ CD-ROM CAPACITY description (on
page 313, PDF page 349). That says:
"The logical block address returned shall be greater than or equal to the
last readable or playable block. If greater, this address may be in a
transition area beyond the last valid logical block for read or audio play
operations. The value returned shall not be not be more than 75 sectors
(MSF units) greater than the logical block address of the last readable or
playable block. (This value arises because the CD-ROM table of contents
lead-out track location has a +/- 75 sector tolerance when the lead-out
track is encoded as an audio track.)"
So essentially, for CD drives compliant with the old SCSI-2 spec, the last
LBA value returned by READ CAPACITY is equal or greater to the "real" last
For some drives/discs that would mean getting an error message near the
end if you try to do
dd if=/dev/rcd0c of=image.iso bs=2048
But at least all readable sectors would be read.
The later MMC spec (I looked at ftp://ftp.seagate.com/sff/INF-8090.PDF
page 783) doesn't allow the returned highest LBA to be greater than the
actual highest LBA for non-CD media. It has this to say about CD media:
"For CD media, the logical unit shall use the AAh point found in the last
Table of Contents, convert to an LBA, and subtract one. If that block is a
run-out block (found on incrementally recorded CD-R and CD-RW), the
logical unit shall subtract two."
Can run-out blocks (whatever they are) on incrementally recorded CD-R/W be
read? Because it seems that that's the only case where adding 2 could be
of any use. In all other cases the highest LBA reported by the drive is
equal to or greater than the actual highest accessible LBA.
Main Index |
Thread Index |