Here are some very simple patches to add rudimentary MD-Data Drive support to the 
Linux SCSI-disk driver. With these patches applied you will be able to label/partition 
MD-Data discs and create arbitrary filesystems on them.
Note that the MDH-10 and MDM-111 MD-Data drives support only 2048 or 2336 bytes per 
sector. For ext2fs, you must specify a block size that is a multiple of 2048 bytes. 
Likewise for the fragment size, if you choose not to take the default. The drive will 
not work with 512 byte blocks, or anything smaller than 2048. The device driver will 
not work with 2336 byte sectors; using the sd driver to access an MD disc with 2336 
byte sectors will hang the kernel.

More extensive support would probably be nice; I guess you can always use the sg 
interface if you want to use the Play Audio commands and such. An mdfs driver might be 
a good thing, to provide compatibility with your existing MDFS formatted Data discs. I 
would really like to get a driver working that understands 2336-byte sectors, but I 
haven't figured out the proper Mode Select/Sense commands for this yet. My drive (with 
firmware rev 1.11) doesn't respond the way I'd been led to believe it should. Any 
suggestions would certainly be appreciated.

PS: The diffs are against Kernel 2.2.18.

  -- Howard Chu
  Chief Architect, Symas Corp.       Director, Highland Sun
  http://www.symas.com               http://highlandsun.com/hyc  
diff -wur lin1/linux/drivers/scsi/scsi.c linux/drivers/scsi/scsi.c
--- lin1/linux/drivers/scsi/scsi.c      Sun Dec 10 16:49:43 2000
+++ linux/drivers/scsi/scsi.c   Mon Apr 30 01:57:57 2001
@@ -178,6 +178,9 @@
     "Unknown          ",
     "Unknown          ",
     "Enclosure        ",
+    "Unknown          ",
+    "Unknown          ",
+    "MiniDisc         ",
 };
 
 /* 
@@ -822,6 +825,7 @@
   case TYPE_SCANNER:
   case TYPE_MEDIUM_CHANGER:
   case TYPE_ENCLOSURE:
+  case TYPE_MINIDISC:
     SDpnt->writeable = 1;
     break;
   case TYPE_WORM:
@@ -2568,7 +2572,8 @@
              * estimate 4k buffer/command for devices of unknown type (should panic).
              */
             if (SDpnt->type == TYPE_WORM || SDpnt->type == TYPE_ROM ||
-                SDpnt->type == TYPE_DISK || SDpnt->type == TYPE_MOD) {
+                SDpnt->type == TYPE_DISK || SDpnt->type == TYPE_MOD ||
+               SDpnt->type == TYPE_MINIDISC) {
                 new_dma_sectors += ((host->sg_tablesize *
                                      sizeof(struct scatterlist) + 511) >> 9) *
                     SDpnt->queue_depth;
diff -wur lin1/linux/drivers/scsi/scsi.h linux/drivers/scsi/scsi.h
--- lin1/linux/drivers/scsi/scsi.h      Tue Jan  4 10:12:21 2000
+++ linux/drivers/scsi/scsi.h   Thu Apr 26 20:32:03 2001
@@ -39,7 +39,7 @@
 # define FALSE 0
 #endif
 
-#define MAX_SCSI_DEVICE_CODE 14
+#define MAX_SCSI_DEVICE_CODE 17
 extern const char *const scsi_device_types[MAX_SCSI_DEVICE_CODE];
 extern spinlock_t scsi_malloc_lock;
 
diff -wur lin1/linux/drivers/scsi/sd.c linux/drivers/scsi/sd.c
--- lin1/linux/drivers/scsi/sd.c        Sun Dec 10 16:49:43 2000
+++ linux/drivers/scsi/sd.c     Mon Apr 30 03:20:39 2001
@@ -1640,7 +1640,8 @@
 
 static int sd_detect(Scsi_Device * SDp){
     char nbuff[6];
-    if(SDp->type != TYPE_DISK && SDp->type != TYPE_MOD) return 0;
+    if(SDp->type != TYPE_DISK && SDp->type != TYPE_MOD
+       && SDp->type != TYPE_MINIDISC) return 0;
 
     sd_devname(sd_template.dev_noticed++, nbuff);
     printk("Detected scsi %sdisk %s at scsi%d, channel %d, id %d, lun %d\n",
@@ -1655,7 +1654,8 @@
     Scsi_Disk * dpnt;
     int i;
 
-    if(SDp->type != TYPE_DISK && SDp->type != TYPE_MOD) return 0;
+    if(SDp->type != TYPE_DISK && SDp->type != TYPE_MOD
+       && SDp->type != TYPE_MINIDISC) return 0;
 
     if(sd_template.nr_dev >= sd_template.dev_max) {
        SDp->attached--;
diff -wur lin1/linux/include/scsi/scsi.h linux/include/scsi/scsi.h
--- lin1/linux/include/scsi/scsi.h      Sun Dec 10 16:49:44 2000
+++ linux/include/scsi/scsi.h   Thu Apr 26 20:27:57 2001
@@ -134,6 +134,8 @@
                                     * - treated as TYPE_DISK */
 #define TYPE_MEDIUM_CHANGER 0x08
 #define TYPE_ENCLOSURE      0x0d    /* Enclosure Services Device */
+#define TYPE_MINIDISC       0x10    /* Sony MiniDisc Data Drive -
+                                    * - treated as TYPE_DISK */
 #define TYPE_NO_LUN         0x7f
 
 /*

Reply via email to