From: Stuart Hayes <Stuart_Hayes@dell.com>
To: axboe@suse.de
Cc: linux-kernel@vger.kernel.org, <stuart_hayes@dell.com>
Subject: PATCH (for 2.6.3-rc1) for cdrom driver dvd_read_struct
Date: Tue, 10 Feb 2004 10:46:08 -0600 (CST) [thread overview]
Message-ID: <Pine.LNX.4.44.0402101035050.29125-100000@tux.linuxdev.us.dell.com> (raw)
The attached patch will make the "dvd_read_struct" function in cdrom.c
check that the DVD drive can currently do the DVD read structure command
before sending the command to the drive. It does this by checking the
"dvd read" feature using the "get configuration" command.
Currently, cdrom.c only checks that the drive is a DVD drive before
allowing the dvd read structure command to go to the drive--it does not
make sure that the DVD drive has a DVD in it. Without this patch, if CD
medium is in a DVD drive, and the DVD_READ_STRUCT ioctl is used, the drive
will spew an ugly "illegal request" error (magicdev does this).
Thanks
Stuart
diff -BurN linux-2.6.3-rc1/drivers/cdrom/cdrom.c linux-2.6.3-rc1-cdrompatch/drivers/cdrom/cdrom.c
--- linux-2.6.3-rc1/drivers/cdrom/cdrom.c 2004-02-09 15:55:18.000000000 -0600
+++ linux-2.6.3-rc1-cdrompatch/drivers/cdrom/cdrom.c 2004-02-10 09:20:31.000000000 -0600
@@ -1643,8 +1643,41 @@
return ret;
}
+static int check_feature_current(struct cdrom_device_info *cdi, __u16 feature)
+{
+ int ret;
+ u_char buf[12];
+ struct cdrom_generic_command cgc;
+ struct cdrom_device_ops *cdo = cdi->ops;
+
+ init_cdrom_command(&cgc, buf, sizeof(buf), CGC_DATA_READ);
+ cgc.cmd[0] = GPCMD_GET_CONFIGURATION;
+ cgc.cmd[1] = 2; /* only get one feature descriptor */
+ cgc.cmd[2] = feature >> 8;
+ cgc.cmd[3] = feature & 0xff;
+ cgc.cmd[8] = 12;
+
+ if ((ret = cdo->generic_packet(cdi, &cgc)))
+ return ret;
+ if (buf[3] < 8) /* i.e., drive doesn't support the feature */
+ return -EMEDIUMTYPE;
+ if ((buf[10] & 1)==0) /* feature is not current */
+ return -EMEDIUMTYPE;
+ return 0;
+}
+
static int dvd_read_struct(struct cdrom_device_info *cdi, dvd_struct *s)
{
+ int ret;
+
+ /* do a GET_CONFIGURATION to make sure drive can do
+ * DVD_READ_STRUCTURE command with current media
+ */
+ ret = check_feature_current(cdi, CDF_DVD_READ);
+ if (ret)
+ return ret;
+
+ /* actually read the requested DVD structure */
switch (s->type) {
case DVD_STRUCT_PHYSICAL:
return dvd_read_physical(cdi, s);
diff -BurN linux-2.6.3-rc1/include/linux/cdrom.h linux-2.6.3-rc1-cdrompatch/include/linux/cdrom.h
--- linux-2.6.3-rc1/include/linux/cdrom.h 2004-02-09 15:55:25.000000000 -0600
+++ linux-2.6.3-rc1-cdrompatch/include/linux/cdrom.h 2004-02-10 09:20:29.000000000 -0600
@@ -722,6 +722,7 @@
/*
* feature profile
*/
+#define CDF_DVD_READ 0x1F
#define CDF_MRW 0x28
/*
next reply other threads:[~2004-02-10 16:53 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-02-10 16:46 Stuart Hayes [this message]
2004-02-10 17:12 ` Jens Axboe
2004-02-11 11:51 ` Jamie Lokier
2004-02-11 12:09 ` Jens Axboe
2004-02-10 18:06 Stuart_Hayes
2004-02-10 18:27 ` Matt Domsch
2004-02-10 23:26 ` Adam Kropelin
2004-02-11 12:10 ` Jens Axboe
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=Pine.LNX.4.44.0402101035050.29125-100000@tux.linuxdev.us.dell.com \
--to=stuart_hayes@dell.com \
--cc=axboe@suse.de \
--cc=linux-kernel@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®