hal: Branch 'origin' - 3 commits

David Zeuthen david at kemper.freedesktop.org
Sun Sep 17 01:29:42 PDT 2006


 fdi/policy/10osvendor/20-storage-methods.fdi |   11 ++
 hald/linux/probing/probe-volume.c            |  111 +++++++++++++++++----------
 2 files changed, 82 insertions(+), 40 deletions(-)

New commits:
diff-tree dbbb676c54531b04ea03a81769b24e6b4bf23166 (from 3afd2d0818bc4ea5e33f343874e2b6534f187d58)
Author: David Zeuthen <davidz at redhat.com>
Date:   Sun Sep 17 03:31:14 2006 -0400

    probe for partitions on data discs where we fail to detect an fs
    
    This makes us support Apple optical discs since they use a partition
    table.

diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index bf57638..a87bd31 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -553,7 +553,7 @@ main (int argc, char *argv[])
 				}
 			}
 		}
-
+		
 		/* try again, to get last session that way */
 		if (vol_probe_offset == 0) {
 			struct cdrom_multisession ms_info;
@@ -570,12 +570,18 @@ main (int argc, char *argv[])
 
 	if (should_probe_for_fs) {
 
+		if ((stordev_dev_file = libhal_device_get_property_string (
+			     ctx, parent_udi, "block.device", &error)) == NULL) {
+			goto out;
+		}
+
 		/* Optical discs have problems reporting the exact
 		 * size so we should never look for data there since
 		 * it causes problems with the broken ide-cd driver
 		 */
-		if (is_disc)
+		if (is_disc) {
 			vol_size = 0;
+		}
 
 		/* probe for file system */
 		vid = volume_id_open_fd (fd);
@@ -586,32 +592,49 @@ main (int argc, char *argv[])
 				libhal_changeset_set_property_string (cs, "info.product", "Volume");
 			}
 
-			/* VOLUME_ID_UNUSED means vol_id didn't detect anything that it knows about - look if 
-			 * it's an extended msdos partition table 
+			/* VOLUME_ID_UNUSED means vol_id didn't detect anything that it knows about
+			 * if it's a disc.. look whether it's a partition table (some Apple discs
+			 * uses Apple Partition Map) and look at partitions
+			 *
+			 * (kind of a hack - ugh  - we ought to export all these as fakevolumes... but
+			 *  this is good enough for now... the only discs I know of that does this
+			 *  is in fact Apple's install disc.)
 			 */
-#if 0
-			if (vid->usage_id == VOLUME_ID_UNUSED) {
-				unsigned char buf[2];
-
-				HAL_DEBUG (("looking whether partition is an extended msdos partition table", vid->usage_id));
-
-				/* TODO: Is it good enough to just look for this magic? Kay? */
-				lseek (fd, MSDOS_SIG_OFF, SEEK_SET);
-				if (read (fd, &buf, 2) != 2) {
-					HAL_DEBUG (("read failed (%s)", strerror (errno)));
-				} else {
-					if (memcmp (buf, MSDOS_MAGIC, 2) == 0) {
-						HAL_DEBUG (("partition is an extended msdos partition table"));
-
-						libhal_changeset_set_property_string (cs, "volume.fsusage", "partitiontable");
-						libhal_changeset_set_property_string (cs, "volume.fstype", "msdos_extended_partitiontable");
-						libhal_changeset_set_property_string (cs, "volume.fsversion", "");
-						
+			if (vid->usage_id == VOLUME_ID_UNUSED && is_disc) {
+				PartitionTable *p;
+				p = part_table_load_from_disk (stordev_dev_file);
+				if (p != NULL) {
+					int i;
+
+					HAL_INFO (("Partition table with scheme '%s' on optical disc",
+						   part_get_scheme_name (part_table_get_scheme (p))));
+
+					for (i = 0; i < part_table_get_num_entries (p); i++) {
+						char *part_type;
+
+						part_type = part_table_entry_get_type (p, i);
+						HAL_INFO ((" partition %d has type '%s'", i, part_type));
+						if (strcmp (part_type, "Apple_HFS") == 0) {
+							guint64 part_offset;
+
+							part_offset = part_table_entry_get_offset (p, i);
+							if (volume_id_probe_all (
+								    vid, vol_probe_offset + part_offset, 0) == 0) {
+
+								set_volume_id_values(ctx, udi, cs, vid);
+							}
+
+							/* and we're done */
+							break;
+						}
+						g_free (part_type);
 					}
+					
+
+					HAL_INFO (("Done looking at part table"));
+					part_table_free (p);
 				}
-				
 			}
-#endif
 
 			volume_id_close(vid);
 		}
@@ -622,11 +645,6 @@ main (int argc, char *argv[])
 		    partition_start > 0) {
 			PartitionTable *p;
 
-			if ((stordev_dev_file = libhal_device_get_property_string (
-					ctx, parent_udi, "block.device", &error)) == NULL) {
-				goto out;
-			}
-
 			HAL_INFO (("Loading part table"));
 			p = part_table_load_from_disk (stordev_dev_file);
 			if (p != NULL) {
diff-tree 3afd2d0818bc4ea5e33f343874e2b6534f187d58 (from 0b35caedb2ec3feeffca481827b393fdf7057c5d)
Author: David Zeuthen <davidz at redhat.com>
Date:   Sun Sep 17 03:00:58 2006 -0400

    export Eject() even on discs where we can't detect a file system

diff --git a/fdi/policy/10osvendor/20-storage-methods.fdi b/fdi/policy/10osvendor/20-storage-methods.fdi
index bd85ed7..29e8cd0 100644
--- a/fdi/policy/10osvendor/20-storage-methods.fdi
+++ b/fdi/policy/10osvendor/20-storage-methods.fdi
@@ -189,6 +189,17 @@
 
     </match>
 
+    <!-- make sure we export Eject on discs where we don't recognize the file system -->
+    <match key="volume.is_disc" bool="true">
+      <match key="volume.fsusage" string="">
+        <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.Volume</append>
+        <append key="org.freedesktop.Hal.Device.Volume.method_names" type="strlist">Eject</append>
+        <append key="org.freedesktop.Hal.Device.Volume.method_signatures" type="strlist">as</append>
+	<append key="org.freedesktop.Hal.Device.Volume.method_argnames" type="strlist">extra_options</append>
+        <append key="org.freedesktop.Hal.Device.Volume.method_execpaths" type="strlist">hal-storage-eject</append>
+      </match>
+    </match>
+
     <match key="storage.requires_eject" bool="true">
         <!-- storage Eject causes eject on each volume on this storage -->
         <append key="info.interfaces" type="strlist">org.freedesktop.Hal.Device.Storage</append>
diff-tree 0b35caedb2ec3feeffca481827b393fdf7057c5d (from 26a21a593757dc9459c21b2de57bd6f1ab750ba2)
Author: David Zeuthen <davidz at redhat.com>
Date:   Sun Sep 17 03:00:26 2006 -0400

    enable looking for data track on optical discs
    
    This fixes two bugs; a) when a mixed disc got data as the last track
    (the usual case for bonus CD's); and b) picking the label from the
    last session. This was actually disabled by Kay some time ago with a
    note that a few drives have broken firmware. We need to blacklist
    those.

diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index 24e3a1b..bf57638 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -380,7 +380,7 @@ main (int argc, char *argv[])
 	if (is_disc) {
 		int type;
 		guint64 capacity;
-		struct cdrom_tochdr; /* toc_hdr; */
+		struct cdrom_tochdr toc_hdr;
 
 		/* defaults */
 		libhal_changeset_set_property_string (cs, "volume.disc.type", "unknown");
@@ -519,11 +519,22 @@ main (int argc, char *argv[])
 			libhal_changeset_set_property_bool (cs, "volume.disc.is_appendable", TRUE);
 		}
 
-#if 0
-		/* This seems to cause problems on some drives with broken firmware,
-		 * comment it out until we really need multisession support */
+		/* In November 2005, Kay wrote:
+		 *
+		 *  "This seems to cause problems on some drives with broken firmware,
+		 *   comment it out until we really need multisession support."
+		 *
+		 * However, we really need this for
+		 *
+		 *  - supporting mixed CD's - we want to probe the data track which
+		 *    may not be the first track; normally it's the last one...
+		 *  - getting the right label for multi-session discs (fd.o bug #2860)
+		 *
+		 * So if there are still drives around with broken firmware we need
+		 * to blacklist them.
+		 */
 
-		/* check for multisession disks */
+		/* check if last track is a data track */
 		if (ioctl (fd, CDROMREADTOCHDR, &toc_hdr) == 0) {
 			struct cdrom_tocentry toc_entr;
 			unsigned int vol_session_count = 0;
@@ -535,13 +546,13 @@ main (int argc, char *argv[])
 			memset (&toc_entr, 0x00, sizeof (toc_entr));
 			toc_entr.cdte_track = vol_session_count;
 			toc_entr.cdte_format = CDROM_LBA;
-			if (ioctl (fd, CDROMREADTOCENTRY, &toc_entr) == 0)
-				if ((toc_entr.cdte_ctrl & CDROM_DATA_TRACK) == 4) {
-					HAL_DEBUG(("last session starts at block = %u", toc_entr.cdte_addr.lba));
+			if (ioctl (fd, CDROMREADTOCENTRY, &toc_entr) == 0) {
+				if (toc_entr.cdte_ctrl & CDROM_DATA_TRACK) {
+					HAL_DEBUG (("last session starts at block = %u", toc_entr.cdte_addr.lba));
 					vol_probe_offset = toc_entr.cdte_addr.lba * block_size;
 				}
+			}
 		}
-#endif
 
 		/* try again, to get last session that way */
 		if (vol_probe_offset == 0) {
@@ -549,9 +560,11 @@ main (int argc, char *argv[])
 
 			memset(&ms_info, 0x00, sizeof(ms_info));
 			ms_info.addr_format = CDROM_LBA;
-			if (ioctl(fd, CDROMMULTISESSION, &ms_info) == 0)
-				if (!ms_info.xa_flag)
+			if (ioctl(fd, CDROMMULTISESSION, &ms_info) == 0) {
+				if (!ms_info.xa_flag) {
 					vol_probe_offset = ms_info.addr.lba * block_size;
+				}
+			}
 		}
 	}
 


More information about the hal-commit mailing list