Session: try harder to read the disc geometry.

On some discs and drives, the command may not work the first time.
Trying a second time succeeds more often.

Fixes #11467.
This commit is contained in:
Adrien Destugues
2014-11-14 16:00:37 +01:00
parent b31d5cd2b6
commit 3c3eb09760
@@ -275,23 +275,26 @@ read_table_of_contents(int deviceFD, uint32 first_session, uchar* buffer,
memset(raw_command.sense_data, 0, raw_command.sense_data_length); memset(raw_command.sense_data, 0, raw_command.sense_data_length);
raw_command.timeout = kScsiTimeout; raw_command.timeout = kScsiTimeout;
if (ioctl(deviceFD, B_RAW_DEVICE_COMMAND, &raw_command) == 0) { // This does not always work on the first try, so do it twice just in case.
if (raw_command.scsi_status == 0 && raw_command.cam_status == 1) { for (int attempt = 0; attempt < 2; attempt++) {
// SUCCESS!!! if (ioctl(deviceFD, B_RAW_DEVICE_COMMAND, &raw_command) == 0) {
DBG(dump_full_table_of_contents(buffer, buffer_length)); if (raw_command.scsi_status == 0 && raw_command.cam_status == 1) {
// SUCCESS!!!
DBG(dump_full_table_of_contents(buffer, buffer_length));
return B_OK;
} else {
error = B_FILE_ERROR;
TRACE(("%s: scsi ioctl succeeded, but scsi command failed\n",
kModuleDebugName));
}
} else { } else {
error = B_FILE_ERROR; error = errno;
TRACE(("%s: scsi ioctl succeeded, but scsi command failed\n", TRACE(("%s: scsi command failed with error 0x%" B_PRIx32 "\n",
kModuleDebugName)); kModuleDebugName, error));
} }
} else {
error = errno;
TRACE(("%s: scsi command failed with error 0x%" B_PRIx32 "\n",
kModuleDebugName, error));
} }
return error; return error;
} }