Ticket #10043: 0001-usb_disk-accept-B_DEV_MEDIA_CHANGED-as-a-ready-unit.patch

File 0001-usb_disk-accept-B_DEV_MEDIA_CHANGED-as-a-ready-unit.patch, 3.0 KB (added by korli, 11 years ago)

accept B_DEV_MEDIA_CHANGED

  • headers/private/drivers/scsi_sense.h

    From 31a804eb65e0673ac26f6ddb483f9bfe4bc8c854 Mon Sep 17 00:00:00 2001
    From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Duval?= <jerome.duval@gmail.com>
    Date: Mon, 7 Oct 2013 19:25:55 +0200
    Subject: [PATCH] usb_disk: accept B_DEV_MEDIA_CHANGED as a ready unit.
    
    * revert 0x2800 sense action change.
    ---
     headers/private/drivers/scsi_sense.h                      | 6 ++----
     src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp | 7 ++++---
     2 files changed, 6 insertions(+), 7 deletions(-)
    
    diff --git a/headers/private/drivers/scsi_sense.h b/headers/private/drivers/scsi_sense.h
    index 7e9bf4e..fa1204e 100644
    a b  
    44 *
    55 * Authors:
    66 *  Jérôme Duval
    7  * 
     7 *
    88 * Generated based on http://www.t10.org/lists/asc-num.txt 20130919
    99 *  and http://www.t10.org/lists/2sensekey.htm
    1010 */
    scsi_sense_asc_table sSCSISenseAscTable[] =  
    315315    { 0x2705, "Permanent write protect", err_act_fail, B_READ_ONLY_DEVICE },    // T   R
    316316    { 0x2706, "Conditional write protect", err_act_fail, B_READ_ONLY_DEVICE },  // R       F
    317317    { 0x2707, "Space allocation failed write protect", err_act_fail, B_READ_ONLY_DEVICE },  // D         B
    318     { 0x2800, "Not ready to ready change, medium may have changed", err_act_retry, B_DEV_MEDIA_CHANGED },   // DTLPWROMAEBKVF
     318    { 0x2800, "Not ready to ready change, medium may have changed", err_act_fail, B_DEV_MEDIA_CHANGED },    // DTLPWROMAEBKVF
    319319    { 0x2801, "Import or export element accessed", err_act_fail, ENXIO },   // DT  WROM  B
    320320    { 0x2802, "Format-layer may have changed", err_act_fail, B_DEV_MEDIA_CHANGED }, // R
    321321    { 0x2803, "Import/export element accessed, medium changed", err_act_fail, B_ERROR },    // M
    scsi_get_sense_asc_info(uint16 asc_asq, const char **label, err_act *action, sta  
    792792    *label = NULL;
    793793    return B_BAD_VALUE;
    794794}
    795 
    796 
  • src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp

    diff --git a/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp b/src/add-ons/kernel/drivers/disk/usb/usb_disk/usb_disk.cpp
    index 6c874f3..5da2965 100644
    a b usb_disk_request_sense(device_lun *lun, err_act *_action)  
    481481        lun->media_present = false;
    482482        usb_disk_reset_capacity(lun);
    483483    }
    484    
     484
    485485    if (_action != NULL)
    486486        *_action = action;
    487487
    usb_disk_device_added(usb_device newDevice, void **cookie)  
    799799            TRACE("usb lun %"B_PRIu8" inquiry attempt %"B_PRIu32" begin\n",
    800800                i, tries);
    801801            status_t ready = usb_disk_test_unit_ready(lun, &action);
    802             if (ready == B_OK || ready == B_DEV_NO_MEDIA) {
     802            if (ready == B_OK || ready == B_DEV_NO_MEDIA
     803                || ready == B_DEV_MEDIA_CHANGED) {
    803804                if (lun->device_type == B_CD)
    804805                    lun->write_protected = true;
    805806                // TODO: check for write protection; disabled since some
    usb_disk_ioctl(void *cookie, uint32 op, void *buffer, size_t length)  
    11001101                    break;
    11011102                }
    11021103                snooze(500000);
    1103             }           
     1104            }
    11041105            TRACE("B_GET_MEDIA_STATUS: 0x%08" B_PRIx32 "\n",
    11051106                *(status_t *)buffer);
    11061107            result = B_OK;