Also test for the "no medium persent" case and don't tell B_DEV_MEDIA_CHANGED in

such a case as that would try to read info about a non-present medium.


git-svn-id: file:///srv/svn/repos/haiku/haiku/trunk@32862 a95241bf-73f2-0310-859d-f6bbb57e9c96
This commit is contained in:
Michael Lotz 2009-08-31 15:08:38 +00:00
parent 9b37feb4a8
commit 88861a8888
2 changed files with 20 additions and 13 deletions

View File

@ -426,7 +426,8 @@ usb_disk_request_sense(device_lun *lun)
return result;
}
if (parameter.sense_key > SCSI_SENSE_KEY_NOT_READY) {
if (parameter.sense_key > SCSI_SENSE_KEY_NOT_READY
&& parameter.sense_key != SCSI_SENSE_KEY_UNIT_ATTENTION) {
TRACE_ALWAYS("request_sense: key: 0x%02x; asc: 0x%02x; ascq: 0x%02x;\n",
parameter.sense_key, parameter.additional_sense_code,
parameter.additional_sense_code_qualifier);
@ -437,14 +438,6 @@ usb_disk_request_sense(device_lun *lun)
case SCSI_SENSE_KEY_RECOVERED_ERROR:
return B_OK;
case SCSI_SENSE_KEY_NOT_READY:
TRACE("request_sense: device not ready (asc 0x%02x ascq 0x%02x)\n",
parameter.additional_sense_code,
parameter.additional_sense_code_qualifier);
lun->media_present = false;
usb_disk_reset_capacity(lun);
return B_DEV_NO_MEDIA;
case SCSI_SENSE_KEY_HARDWARE_ERROR:
case SCSI_SENSE_KEY_MEDIUM_ERROR:
TRACE_ALWAYS("request_sense: media or hardware error\n");
@ -455,10 +448,21 @@ usb_disk_request_sense(device_lun *lun)
return B_DEV_INVALID_IOCTL;
case SCSI_SENSE_KEY_UNIT_ATTENTION:
TRACE_ALWAYS("request_sense: media changed\n");
lun->media_changed = true;
lun->media_present = true;
return B_DEV_MEDIA_CHANGED;
if (parameter.additional_sense_code != SCSI_ASC_MEDIUM_NOT_PRESENT) {
TRACE_ALWAYS("request_sense: media changed\n");
lun->media_changed = true;
lun->media_present = true;
return B_DEV_MEDIA_CHANGED;
}
// fall through
case SCSI_SENSE_KEY_NOT_READY:
TRACE("request_sense: device not ready (asc 0x%02x ascq 0x%02x)\n",
parameter.additional_sense_code,
parameter.additional_sense_code_qualifier);
lun->media_present = false;
usb_disk_reset_capacity(lun);
return B_DEV_NO_MEDIA;
case SCSI_SENSE_KEY_DATA_PROTECT:
TRACE_ALWAYS("request_sense: write protected\n");

View File

@ -99,6 +99,9 @@ typedef enum {
SCSI_SENSE_KEY_ABORTED_COMMAND = 0x0b,
} scsi_sense_key;
// request sense additional sense codes
#define SCSI_ASC_MEDIUM_NOT_PRESENT 0x3a
// mode sense page code/parameter
#define SCSI_MODE_PAGE_DEVICE_CONFIGURATION 0x10
#define SCSI_DEVICE_SPECIFIC_WRITE_PROTECT 0x80