hal/hald/linux block_class_device.c, 1.70, 1.71 linux_dvd_rw_utils.c,
1.6, 1.7 linux_dvd_rw_utils.h, 1.5, 1.6
David Zeuthen
david at freedesktop.org
Sun Sep 19 07:08:12 PDT 2004
Update of /cvs/hal/hal/hald/linux
In directory gabe:/tmp/cvs-serv28095/hald/linux
Modified Files:
block_class_device.c linux_dvd_rw_utils.c linux_dvd_rw_utils.h
Log Message:
2004-09-19 David Zeuthen <david at fubar.dk>
Patch from Alexander Larsson <alexl at redhat.com>. It seems that
some models of cd-rw drives doesn't seem to support the GET
CONFIGURATION command. At least mine returns sense 5h. However, to
automatically support cdrom blanking, nautilus-cd-burner needs to
correctly know if the medium is rewritable. Thus the attached
patch uses the READ DISC INFORMATION command to get that
information.
* hald/linux/block_class_device.c (detect_disc): Use disc_is_rewriteable
* hald/linux/linux_dvd_rw_utils.c (disc_is_rewritable): New function
* hald/linux/linux_dvd_rw_utils.h: Add prototype for new function
Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.70
retrieving revision 1.71
diff -u -d -r1.70 -r1.71
--- block_class_device.c 14 Sep 2004 12:08:40 -0000 1.70
+++ block_class_device.c 19 Sep 2004 14:08:10 -0000 1.71
@@ -692,7 +692,14 @@
break;
}
}
-
+
+ /* On some hardware the get_disc_type call fails,
+ so we use this as a backup */
+ if (disc_is_rewritable (fd)) {
+ hal_device_property_set_bool (
+ d, "volume.disc.is_rewritable", TRUE);
+ }
+
if (disc_is_appendable (fd)) {
hal_device_property_set_bool (
d, "volume.disc.is_appendable", TRUE);
Index: linux_dvd_rw_utils.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/linux_dvd_rw_utils.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- linux_dvd_rw_utils.c 13 May 2004 21:21:32 -0000 1.6
+++ linux_dvd_rw_utils.c 19 Sep 2004 14:08:10 -0000 1.7
@@ -401,3 +401,28 @@
scsi_command_free (cmd);
return retval;
}
+
+int
+disc_is_rewritable (int fd)
+{
+ ScsiCommand *cmd;
+ int retval = -1;
+ unsigned char header[32];
+
+ cmd = scsi_command_new_from_fd (fd);
+
+ /* see section 5.19 of MMC-3 from http://www.t10.org/drafts.htm#mmc3 */
+ scsi_command_init (cmd, 0, 0x51); /* READ_DISC_INFORMATION */
+ scsi_command_init (cmd, 8, 32);
+ scsi_command_init (cmd, 9, 0);
+ if (scsi_command_transport (cmd, READ, header, 32)) {
+ /* READ_DISC_INFORMATION failed */
+ scsi_command_free (cmd);
+ return 0;
+ }
+
+ retval = ((header[2]&0x10) != 0);
+
+ scsi_command_free (cmd);
+ return retval;
+}
Index: linux_dvd_rw_utils.h
===================================================================
RCS file: /cvs/hal/hal/hald/linux/linux_dvd_rw_utils.h,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- linux_dvd_rw_utils.h 13 May 2004 21:21:32 -0000 1.5
+++ linux_dvd_rw_utils.h 19 Sep 2004 14:08:10 -0000 1.6
@@ -13,5 +13,6 @@
int get_read_write_speed (int fd, int *read_speed, int *write_speed);
int get_disc_type (int fd);
int disc_is_appendable (int fd);
+int disc_is_rewritable (int fd);
#endif /* LINUX_DVD_RW_UTILS_H */
More information about the hal-commit
mailing list