lkml.org 
[lkml]   [2000]   [Sep]   [5]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
Date
From
SubjectPATCH: sd.c -- fix for testing WP bit
Attached is a patch to linux/drivers/scsi/sd.c which fixes the behavior of
the code which tests the WP bit. This patch is generated against
2.4.0-test8-pre4.

Specifically, thsi code fixes the case where the device in question does
not have a page 1 (I found one, this is how I found the bug). Since we're
not really interested in page 1 (we just want the header data), this patch
makes the code request "all pages" (code 0x3f) with an allocation length of
only 8 bytes (the length of the header data).

This works on all devices I have available to test. I see no reason why it
might break other devices.

Linus, please apply.

Matt Dharm

--
Matthew Dharm Home: mdharm-usb@one-eyed-alien.net
Maintainer, Linux USB Mass Storage Driver

Way to go, lava boy.
-- Stef to Greg
User Friendly, 3/26/1998
--- drivers/scsi/sd.c.old Tue Sep 5 14:23:10 2000
+++ drivers/scsi/sd.c Tue Sep 5 14:25:27 2000
@@ -957,17 +957,23 @@
/* FLOPTICAL */

/*
- * for removable scsi disk ( FLOPTICAL ) we have to recognise
- * the Write Protect Flag. This flag is kept in the Scsi_Disk struct
- * and tested at open !
+ * For removable scsi disk ( FLOPTICAL ) we have to recognise
+ * the Write Protect Flag. This flag is kept in the Scsi_Disk
+ * struct and tested at open !
* Daniel Roche ( dan@lectra.fr )
+ *
+ * Changed to get all pages (0x3f) rather than page 1 to
+ * get around devices which do not have a page 1. Since
+ * we're only interested in the header anyway, this should
+ * be fine.
+ * -- Matthew Dharm (mdharm-scsi@one-eyed-alien.net)
*/

memset((void *) &cmd[0], 0, 8);
cmd[0] = MODE_SENSE;
cmd[1] = (rscsi_disks[i].device->lun << 5) & 0xe0;
- cmd[2] = 1; /* page code 1 ?? */
- cmd[4] = 12;
+ cmd[2] = 0x3f; /* Get all pages */
+ cmd[4] = 8; /* But we only want the 8 byte header */
SRpnt->sr_cmd_len = 0;
SRpnt->sr_sense_buffer[0] = 0;
SRpnt->sr_sense_buffer[2] = 0;
\
 
 \ /
  Last update: 2005-03-22 12:38    [W:0.033 / U:2.488 seconds]
©2003-2018 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site