All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pat LaVarre <p.lavarre@ieee.org>
To: Jens Axboe <axboe@suse.de>
Cc: linux-scsi@vger.kernel.org
Subject: [PATCH 2.4] rewritable USB DVD-RAM vs. mode sense op choice
Date: 16 Aug 2004 10:29:49 -0600	[thread overview]
Message-ID: <1092673789.4297.7.camel@patlinux.iomegacorp.com> (raw)

Jens A:

2.4.26 and 2.4.27 strace of dd of=, mount -w, etc. chokes via EROFS for
USB DVD-RAM.  2.4.25 I have not tried.

This small patch substitutes the MMC op x5A "MODE SENSE (10)" for the op
x1A that in t10.org PDT x05 is vendor-specific.  Such consideration
persuades a standard DVD-RAM drive to admit it rewrites DVD-RAM discs.

Revising the CDB alone of course does not suffice: we also have to step
past a different size of data in header.

Pat LaVarre

diff -urp linux-2.4.27/drivers/scsi/sr.c linux-2.4.27-pel/drivers/scsi/sr.c
--- linux-2.4.27/drivers/scsi/sr.c	2003-06-13 08:51:36.000000000 -0600
+++ linux-2.4.27-pel/drivers/scsi/sr.c	2004-08-16 10:08:37.000000000 -0600
@@ -691,7 +691,7 @@ void get_sectorsize(int i)
 
 void get_capabilities(int i)
 {
-	unsigned char cmd[6];
+	unsigned char cmd[16];
 	unsigned char *buffer;
 	int rc, n;
 
@@ -713,12 +713,12 @@ void get_capabilities(int i)
 		printk(KERN_ERR "sr: out of memory.\n");
 		return;
 	}
-	cmd[0] = MODE_SENSE;
+	memset(cmd, '\0', sizeof cmd);
+	cmd[0] = MODE_SENSE_10;
 	cmd[1] = (scsi_CDs[i].device->scsi_level <= SCSI_2) ?
 		 ((scsi_CDs[i].device->lun << 5) & 0xe0) : 0;
 	cmd[2] = 0x2a;
-	cmd[4] = 128;
-	cmd[3] = cmd[5] = 0;
+	cmd[8] = 128;
 	rc = sr_do_ioctl(i, cmd, buffer, 128, 1, SCSI_DATA_READ, NULL);
 
 	if (rc) {
@@ -731,7 +731,7 @@ void get_capabilities(int i)
 		printk("sr%i: scsi-1 drive\n", i);
 		return;
 	}
-	n = buffer[3] + 4;
+	n = 8 + ((buffer[6] << 8) | buffer[7]); /* 8 = sizeof MODE_SENSE_10 header */
 	scsi_CDs[i].cdi.speed = ((buffer[n + 8] << 8) + buffer[n + 9]) / 176;
 	scsi_CDs[i].readcd_known = 1;
 	scsi_CDs[i].readcd_cdda = buffer[n + 5] & 0x01;



             reply	other threads:[~2004-08-16 16:30 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-08-16 16:29 Pat LaVarre [this message]
2004-08-23 15:48 ` [PATCH 2.4] rewritable USB DVD-RAM vs. mode sense op choice Jens Axboe
2004-08-23 16:46   ` Pat LaVarre
2004-08-23 17:12     ` Jens Axboe
2004-08-23 17:24       ` Pat LaVarre
2004-08-23 22:45       ` Pat LaVarre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1092673789.4297.7.camel@patlinux.iomegacorp.com \
    --to=p.lavarre@ieee.org \
    --cc=axboe@suse.de \
    --cc=linux-scsi@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.