Incorrect data returned from dvd drive (firmware bug?)
Incorrect data returned from dvd drive (firmware bug?)
- Subject: Incorrect data returned from dvd drive (firmware bug?)
- From: Antoine Missout <email@hidden>
- Date: Fri, 5 Nov 2010 12:09:24 -0400
Hi,
I've been working on a module to send scsi read commands directly to the dvd drive.
This has the advantage of being able to specify a shorter timeout than the default of 30 seconds.
While debugging to make sure my output was identical to reading the drive using normal APIs (open/read),
I found out that the internal drive shipped by Apple returns incorrect data in an inconsistent manner.
On another drive, the data returned is consistent. See the code for details.
I've tried sending kSCSICmd_SYNCHRONIZE_CACHE prior to any read, but that doesn't change anything (I guess it doesn't flush the cache as I would expect).
Is there any workaround I could do to have consistent data on this drive (any scsi command I could send) ?
This should be fairly easy to reproduce with any arccos protected dvd, but I could ship the one I have if needed.
Regards,
Antoine Missout
/*
// DVD used is THE_KARATE_KID, 8,539,996,160 bytes
// it has a bad sector at sector 203824 (among other places)
// this bad sector is not due to a scratch
// and has been engineered (arccos)
// USING MATSHITA DVD-R UJ-868 Firmware Revision KB19
11:25:12:~/temp $ ./read_error
expected: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
first read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x66, 0x35
read error as expected
error read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
second read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
11:25:16:~/temp $ ./read_error
expected: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
first read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
read error as expected
error read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x66, 0x35
second read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x66, 0x35
// USING HL-DT-ST BDDVDRW CH08LS10 Firmware Revision 1.00
11:54:28:~/temp $ ./read_error
expected: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
first read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
read error as expected
error read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
second read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
11:56:56:~/temp $ ./read_error
expected: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
first read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
read error as expected
error read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
second read: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d
*/
#include <fcntl.h>
#include <unistd.h>
#include <stdio.h>
#include <sys/errno.h>
#include <strings.h>
unsigned char sector[2048 * 256];
int error(const char *e)
{
printf("failed: %s\n", e);
return 2;
}
void dump(const char *m)
{
printf("%s: 0xx", m, sector[0]);
int i; for (i = 1; i < 8; i++) printf(", 0xx", sector[i]);
printf("\n");
}
int main(int argc, const char *argv[])
{
int fd = open("/dev/rdisk1", 0); // put proper rdisk here
if (!fd) return error("cannot open");
off_t target = 203803 * 2048;
printf("expected: 0x00, 0x00, 0x01, 0xba, 0x44, 0x03, 0x5f, 0x7d\n");
{
off_t r = lseek(fd, target, SEEK_SET);
if (r != target) return error("cannot seek");
memset(sector, 0, 2048 * 256);
r = read(fd, §or, 2048);
if (r != 2048) return error("cannot read");
dump("first read");
}
{
off_t r = lseek(fd, target, SEEK_SET);
if (r != target) return error("cannot seek");
memset(sector, 0, 2048 * 256);
r = read(fd, §or, 2048 * 256);
if (r == -1 && errno == EIO)
printf("read error as expected\n");
else
printf("unexpected read: %d %d\n", (int)r, errno);
dump("error read");
}
{
off_t r = lseek(fd, target, SEEK_SET);
if (r != target) return error("cannot seek");
memset(sector, 0, 2048 * 256);
r = read(fd, §or, 2048);
if (r != 2048) return error("cannot read");
dump("second read");
}
close(fd);
return 0;
}
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Darwin-kernel mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden