hal/hald/linux block_class_device.c, 1.21, 1.22 linux_dvd_rw_utils.c,
1.5, 1.6 linux_dvd_rw_utils.h, 1.4, 1.5
David Zeuthen
david at pdx.freedesktop.org
Thu May 13 14:21:34 PDT 2004
Update of /cvs/hal/hal/hald/linux
In directory pdx:/tmp/cvs-serv31109/hald/linux
Modified Files:
block_class_device.c linux_dvd_rw_utils.c linux_dvd_rw_utils.h
Log Message:
2004-05-13 David Zeuthen <david at fubar.dk>
* hald/linux/block_class_device.c
(detect_media): Move disc properties into volume.disc.* namespace and
only set them for optical discs. Use disc_is_appendable() to set
volume.disc.is_appendable. Specifically, the following properties
are now available for discs (e.g. iff volume.is_disc is TRUE)
volume.disc.has_audio - TRUE iff the disc got audio tracks
volume.disc.has_data - TRUE iff the disc got data tracks
volume.disc.is_appendable - TRUE iff further data can be written
volume.disc.is_blank - TRUE iff the data is blank
volume.disc.is_rewriteable - TRUE iff the disc can be reformatted
volume.disc.type - type of disc, can assume "cd_rom", "cd_r",
"cd_rw", "dvd_rom", dvd_r", "dvd_rw",
"dvd_ram", "dvd_plus_r", "dvd_plus_rw"
(block_class_pre_process): Don't set volume.disc_type, but set the
boolean property volume.is_disc.
* hald/linux/linux_dvd_rw_utils.c (disc_is_appendable): new function
2004-05-09 David Zeuthen <david at fubar.dk>
* hald/linux/linux_dvd_rw_utils.h:
s/get_dvd_media_type/get_disc_type/
* hald/linux/linux_dvd_rw_utils.c (get_dvd_media_type):
s/get_dvd_media_type/get_disc_type/
Index: block_class_device.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/block_class_device.c,v
retrieving revision 1.21
retrieving revision 1.22
diff -u -d -r1.21 -r1.22
--- a/block_class_device.c 13 May 2004 17:27:15 -0000 1.21
+++ b/block_class_device.c 13 May 2004 21:21:32 -0000 1.22
@@ -535,12 +535,30 @@
"Disc");
/* set defaults */
- hal_device_property_set_string (child, "volume.label", "");
- hal_device_property_set_string (child, "volume.uuid", "");
- hal_device_property_set_string (child, "volume.disc_type", "");
- hal_device_property_set_string (child, "volume.fstype", "");
- hal_device_property_set_string (child, "volume.mount_point", "");
- hal_device_property_set_bool (child, "volume.is_mounted", FALSE);
+ hal_device_property_set_string (
+ child, "volume.label", "");
+ hal_device_property_set_string (
+ child, "volume.uuid", "");
+ hal_device_property_set_string (
+ child, "volume.fstype", "");
+ hal_device_property_set_string (
+ child, "volume.mount_point", "");
+ hal_device_property_set_bool (
+ child, "volume.is_mounted", FALSE);
+ hal_device_property_set_bool (
+ child, "volume.is_disc", TRUE);
+ hal_device_property_set_string (
+ child, "volume.disc.type", "unknown");
+ hal_device_property_set_bool (
+ child, "volume.disc.has_audio", FALSE);
+ hal_device_property_set_bool (
+ child, "volume.disc.has_data", FALSE);
+ hal_device_property_set_bool (
+ child, "volume.disc.is_blank", FALSE);
+ hal_device_property_set_bool (
+ child, "volume.disc.is_appendable", FALSE);
+ hal_device_property_set_bool (
+ child, "volume.disc.is_rewritable", FALSE);
/* set UDI as appropriate */
@@ -551,31 +569,29 @@
hal_device_property_set_string (child, "info.udi", udi);
hal_device_set_udi (child, udi);
- /* set disc media type as appropriate */
+ /* check for audio/data/blank */
type = ioctl (fd, CDROM_DISC_STATUS, CDSL_CURRENT);
switch (type) {
case CDS_AUDIO: /* audio CD */
- hal_device_property_set_string (child,
- "volume.disc_type",
- "audio");
+ hal_device_property_set_bool (
+ child, "volume.disc.has_audio", TRUE);
break;
case CDS_MIXED: /* mixed mode CD */
- hal_device_property_set_string (child,
- "volume.disc_type",
- "mixed");
+ hal_device_property_set_bool (
+ child, "volume.disc.has_audio", TRUE);
+ hal_device_property_set_bool (
+ child, "volume.disc.has_data", TRUE);
break;
case CDS_DATA_1: /* data CD */
case CDS_DATA_2:
case CDS_XA_2_1:
case CDS_XA_2_2:
- hal_device_property_set_string (child,
- "volume.disc_type",
- "data");
+ hal_device_property_set_bool (
+ child, "volume.disc.has_data", TRUE);
break;
case CDS_NO_INFO: /* blank or invalid CD */
- hal_device_property_set_string (child,
- "volume.disc_type",
- "blank");
+ hal_device_property_set_bool (
+ child, "volume.disc.is_blank", TRUE);
break;
default: /* should never see this */
@@ -585,57 +601,113 @@
break;
}
- type = get_dvd_media_type (fd);
- if ((type != -1) && ((type&0xF0) == 0x10)) {
+ /* see table 373 in MMC-3 for details on disc type
+ * http://www.t10.org/drafts.htm#mmc3
+ */
+ type = get_disc_type (fd);
+ HAL_INFO (("get_disc_type returned 0x%02x", type));
+ if (type != -1) {
switch (type) {
+ case 0x08: /* CD-ROM */
+ hal_device_property_set_string (
+ child,
+ "volume.disc.type",
+ "cd_rom");
+ break;
+ case 0x09: /* CD-R */
+ hal_device_property_set_string (
+ child,
+ "volume.disc.type",
+ "cd_r");
+ break;
+ case 0x0a: /* CD-RW */
+ hal_device_property_set_string (
+ child,
+ "volume.disc.type",
+ "cd_rw");
+ hal_device_property_set_bool (
+ child,
+ "volume.disc.is_rewritable",
+ TRUE);
+ break;
case 0x10: /* DVD-ROM */
- HAL_INFO (("########### huu hey"));
hal_device_property_set_string (
child,
- "volume.disc_type",
+ "volume.disc.type",
"dvd_rom");
break;
case 0x11: /* DVD-R Sequential */
hal_device_property_set_string (
child,
- "volume.disc_type",
+ "volume.disc.type",
"dvd_r");
break;
case 0x12: /* DVD-RAM */
hal_device_property_set_string (
child,
- "volume.disc_type",
+ "volume.disc.type",
"dvd_ram");
+ hal_device_property_set_bool (
+ child,
+ "volume.disc.is_rewritable",
+ TRUE);
break;
case 0x13: /* DVD-RW Restricted Overwrite */
hal_device_property_set_string (
child,
- "volume.disc_type",
- "dvd_rw_restricted_overwrite");
+ "volume.disc.type",
+ "dvd_rw");
+ hal_device_property_set_bool (
+ child,
+ "volume.disc.is_rewritable",
+ TRUE);
break;
case 0x14: /* DVD-RW Sequential */
hal_device_property_set_string (
child,
- "volume.disc_type",
+ "volume.disc.type",
"dvd_rw");
+ hal_device_property_set_bool (
+ child,
+ "volume.disc.is_rewritable",
+ TRUE);
break;
case 0x1A: /* DVD+RW */
hal_device_property_set_string (
child,
- "volume.disc_type",
+ "volume.disc.type",
"dvd_plus_rw");
+ hal_device_property_set_bool (
+ child,
+ "volume.disc.is_rewritable",
+ TRUE);
break;
case 0x1B: /* DVD+R */
hal_device_property_set_string (
child,
- "volume.disc_type",
+ "volume.disc.type",
"dvd_plus_r");
+ hal_device_property_set_bool (
+ child,
+ "volume.disc.is_rewritable",
+ TRUE);
break;
default:
break;
}
}
+ HAL_INFO (("BAR"));
+
+ if (disc_is_appendable (fd)) {
+ hal_device_property_set_bool (
+ child,
+ "volume.disc.is_appendable",
+ TRUE);
+ }
+
+ HAL_INFO (("FOO"));
+
close(fd);
detect_fs (child);
@@ -824,7 +896,7 @@
hal_device_property_set_string (d, "info.category", "volume");
hal_device_property_set_string (d, "volume.label", "");
hal_device_property_set_string (d, "volume.uuid", "");
- hal_device_property_set_string (d, "volume.disc_type", "");
+ hal_device_property_set_bool (d, "volume.is_disc", FALSE);
/* block device that is a partition; e.g. a storage volume */
Index: linux_dvd_rw_utils.c
===================================================================
RCS file: /cvs/hal/hal/hald/linux/linux_dvd_rw_utils.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- a/linux_dvd_rw_utils.c 5 May 2004 20:46:34 -0000 1.5
+++ b/linux_dvd_rw_utils.c 13 May 2004 21:21:32 -0000 1.6
@@ -351,13 +351,11 @@
}
int
-get_dvd_media_type (int fd)
+get_disc_type (int fd)
{
ScsiCommand *cmd;
int retval = -1;
unsigned char header[8];
- unsigned char *list;
- int i, len;
cmd = scsi_command_new_from_fd (fd);
@@ -377,3 +375,29 @@
scsi_command_free (cmd);
return retval;
}
+
+
+int
+disc_is_appendable (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]&0x03) == 0x01);
+
+ 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.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- a/linux_dvd_rw_utils.h 5 May 2004 20:46:34 -0000 1.4
+++ b/linux_dvd_rw_utils.h 13 May 2004 21:21:32 -0000 1.5
@@ -11,6 +11,7 @@
int get_dvd_r_rw_profile (int fd);
int get_read_write_speed (int fd, int *read_speed, int *write_speed);
-int get_dvd_media_type (int fd);
+int get_disc_type (int fd);
+int disc_is_appendable (int fd);
#endif /* LINUX_DVD_RW_UTILS_H */
More information about the hal-commit
mailing list