lkml.org 
[lkml]   [1999]   [May]   [3]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
SubjectDVD-ram patch.
Date
From

Hi,

I have a DVD-RAM drive. This device tells the SCSI layers that it's a
CDROM drive. This allows me to do CDROM-stuff with it.

However I would like to write to the device, as 2.5G of removeable
writable disk space is not insignificant.... ;-)
The trick that I grabbed off the net was to "ghost" the drive
into a MO-device and a "cdrom drive". This way I seem to be able
to write and to use it as a CDROM.

In the mean while I found that a certain toshiba CDROM drive was
misbehaving, and that we currently have a "special feature list" for
that kind of stuff.

I appreciate feedback, so go ahead.... (I'm sorry that I haven't
upgraded to 2.2.6 yet, if it doesn't patch into 2.2.6, please tell
me.)
Roger Wolff.


diff -ur linux-2.2.5.clean/drivers/scsi/scsi.c linux/drivers/scsi/scsi.c
--- linux-2.2.5.clean/drivers/scsi/scsi.c Wed Apr 7 17:04:00 1999
+++ linux/drivers/scsi/scsi.c Mon May 3 10:25:47 1999
@@ -102,13 +102,16 @@
* lock up.
*/

-#define BLIST_NOLUN 0x01
-#define BLIST_FORCELUN 0x02
-#define BLIST_BORKEN 0x04
-#define BLIST_KEY 0x08
-#define BLIST_SINGLELUN 0x10
-#define BLIST_NOTQ 0x20
-#define BLIST_SPARSELUN 0x40
+#define BLIST_NOLUN 0x001
+#define BLIST_FORCELUN 0x002
+#define BLIST_BORKEN 0x004
+#define BLIST_KEY 0x008
+#define BLIST_SINGLELUN 0x010
+#define BLIST_NOTQ 0x020
+#define BLIST_SPARSELUN 0x040
+#define BLIST_ISDISK 0x080
+#define BLIST_ISROM 0x100
+#define BLIST_GHOST 0x200

/*
* Data declarations.
@@ -286,6 +289,9 @@
{"YAMAHA","CDR100","1.00", BLIST_NOLUN}, /* Locks up if polled for lun != 0 */
{"YAMAHA","CDR102","1.00", BLIST_NOLUN}, /* Locks up if polled for lun != 0 */
{"iomega","jaz 1GB","J.86", BLIST_NOTQ | BLIST_NOLUN},
+{"CREATIVE","DVD-RAM RAM","*", BLIST_GHOST},
+{"MATSHITA","PD-2 LF-D100","*", BLIST_GHOST},
+{"TOSHIBA","CDROM","*", BLIST_ISROM},
/*
* Must be at end of list...
*/
@@ -632,6 +638,8 @@
struct Scsi_Device_Template *sdtpnt;
Scsi_Device * SDtail, *SDpnt=*SDpnt2;
int bflags, type=-1;
+ static int ghost_channel=-1, ghost_dev=-1;
+ int org_lun = lun;

SDpnt->host = shpnt;
SDpnt->id = dev;
@@ -639,6 +647,12 @@
SDpnt->channel = channel;
SDpnt->online = TRUE;

+ if ((channel == ghost_channel) && (dev == ghost_dev) && (lun == 1)) {
+ SDpnt->lun = 0;
+ } else {
+ ghost_channel = ghost_dev = -1;
+ }
+
/* Some low level driver could use device->type (DB) */
SDpnt->type = -1;

@@ -731,15 +745,37 @@
}

/*
- * It would seem some TOSHIBA CDROM gets things wrong
+ * Get any flags for this device.
*/
- if (!strncmp (scsi_result + 8, "TOSHIBA", 7) &&
- !strncmp (scsi_result + 16, "CD-ROM", 6) &&
- scsi_result[0] == TYPE_DISK) {
+ bflags = get_device_flags (scsi_result);
+
+ /* The Toshiba ROM was "gender-changed" here as an inline hack.
+ This is now much more generic.
+ This is a mess: What we really want is to leave the scsi_result
+ alone, and just change the SDpnt structure. And the SDpnt is what
+ we want print_inquiry to print.
+ */
+ if (bflags & BLIST_ISDISK) {
+ scsi_result[0] = TYPE_DISK;
+ scsi_result[1] |= 0x80; /* removable */
+ }
+
+ if (bflags & BLIST_ISROM) {
scsi_result[0] = TYPE_ROM;
scsi_result[1] |= 0x80; /* removable */
}

+ if (bflags & BLIST_GHOST) {
+ if ((ghost_channel == channel) && (ghost_dev == dev) && (org_lun == 1)) {
+ lun=1;
+ } else {
+ ghost_channel = channel;
+ ghost_dev = dev;
+ scsi_result[0] = TYPE_MOD;
+ scsi_result[1] |= 0x80; /* removable */
+ }
+ }
+
memcpy (SDpnt->vendor, scsi_result + 8, 8);
memcpy (SDpnt->model, scsi_result + 16, 16);
memcpy (SDpnt->rev, scsi_result + 32, 4);
@@ -802,10 +838,6 @@
*/
SDpnt->disconnect = 0;

- /*
- * Get any flags for this device.
- */
- bflags = get_device_flags (scsi_result);

/*
* Set the tagged_queue flag for SCSI-II devices that purport to support
@@ -930,6 +962,15 @@
*/
if (bflags & BLIST_FORCELUN) {
*max_dev_lun = 8;
+ return 1;
+ }
+
+ /*
+ * If this device is Ghosted, scan upto two luns. (It physically only
+ * has one).
+ */
+ if (bflags & BLIST_GHOST) {
+ *max_dev_lun = 2;
return 1;
}
/*
--
** R.E.Wolff@BitWizard.nl ** http://www.BitWizard.nl/ ** +31-15-2137555 **
*-- BitWizard writes Linux device drivers for any device you may have! --*
------ Microsoft SELLS you Windows, Linux GIVES you the whole house ------

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:51    [from the cache]
©2003-2011 Jasper Spaans