Re: [PATCH] usb-storage: Bypass certain SCSI commands on disks with "use_192_bytes_for_3f" attribute

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




On 2025/2/6 22:58, Alan Stern wrote:
Is usb-storage really the right place to put this test?  Wouldn't it
be better to put it in the SCSI layer where the ioctl is converted to
a SCSI command?  That way it would affect all SCSI devices with the
use_192_bytes_for_3f flag, not just USB devices.
Yes, yes... This problem may occur not only in USB devices. It is more appropriate to modify it at the SCSI layer. I'll send the patch v2 soon.

Also, instead of making the command fail completely, wouldn't it be
better to change the transfer length to 192 if the original value was
larger?

But I personally think that it is not appropriate to modify it directly to 192. After all, it is called by the user through ioctl, and the kernel itself will not construct such a data frame. As shown in the following code:

    sd_read_write_protect_flag(struct scsi_disk *sdkp, unsigned char *buffer)
     {
            int res;
            struct scsi_device *sdp = sdkp->device;       
            struct scsi_mode_data data;          
            int old_wp = sdkp->write_prot;       
   
            set_disk_ro(sdkp->disk, 0);          
            if (sdp->skip_ms_page_3f) {          
                    sd_first_printk(KERN_NOTICE, sdkp, "Assuming Write Enabled\n");
                    return;
            }

            if (sdp->use_192_bytes_for_3f) {     
                    res = sd_do_mode_sense(sdp, 0, 0x3F, buffer, 192, &data, NULL);


--
WangYuli

Attachment: OpenPGP_0xC5DA1F3046F40BEE.asc
Description: OpenPGP public key

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux