hal: Branch 'master'

Kay Sievers kay at kemper.freedesktop.org
Tue Jul 10 09:52:21 PDT 2007


 NEWS                               |    4 +-
 hald/linux/probing/probe-storage.c |   11 +++--
 hald/linux/probing/probe-volume.c  |   70 +++++++++++++++----------------------
 3 files changed, 39 insertions(+), 46 deletions(-)

New commits:
diff-tree 03ba32d721e60f7e6e3afa61048278dbbcccfc00 (from f42df3da3119e9cbf6ddf3764fd56ae701c0da1a)
Author: Kay Sievers <kay.sievers at vrfy.org>
Date:   Tue Jul 10 18:53:59 2007 +0200

    volume_id: prepare for future API changes
    
    A future version of libvolume_id will change its API and the "struct
    volume_id" will not be accessible directly anymore. It will require
    udev version 111.

diff --git a/NEWS b/NEWS
index 590ba40..0976327 100644
--- a/NEWS
+++ b/NEWS
@@ -7,7 +7,7 @@ Requirements for HAL 0.5.10 "":
  - Linux kernel     >= 2.6.19
  - util-linux       >= 2.12r1    (--enable-umount-helper requires patch from RH #188193)
  - bash             >= 2.0
- - udev             >= 089
+ - udev             >= 111       (Linux only)
  - dbus             >= 0.61      (with glib bindings)
  - glib             >= 2.6.0
  - expat            >= 1.95.8
@@ -17,7 +17,7 @@ Requirements for HAL 0.5.10 "":
  - dmidecode        >= 2.7       (optional)
  - parted           == 1.7.1, 1.8.0, 1.8.1, 1.8.2, 1.86 (optional)
  - cryptsetup-luks  >= 1.0.1     (optional, needs LUKS patches)
- - libsmbios	    >= 0.13.4    (optional, for DELL machines, Linux only)
+ - libsmbios        >= 0.13.4    (optional, for DELL machines, Linux only)
  - dellWirelessCtl  >= 0.13.4    (optional, for Dell machines, must live in /usr/bin/, Linux only)
  - gperf            >= ??????    (optional, for Re-map multimedia keys, Linux only)
  - ConsoleKit       >= 0.2.0
diff --git a/hald/linux/probing/probe-storage.c b/hald/linux/probing/probe-storage.c
index 608a7f3..eaa8bd5 100644
--- a/hald/linux/probing/probe-storage.c
+++ b/hald/linux/probing/probe-storage.c
@@ -455,14 +455,17 @@ main (int argc, char *argv[])
 		vid = volume_id_open_fd (fd);
 		if (vid != NULL) {
 			if (volume_id_probe_all (vid, 0, size) == 0) {
+				const char *usage;
 				/* signal to hald that we've found something and a fakevolume
 				 * should be added - see hald/linux/blockdev.c:add_blockdev_probing_helper_done()
 				 * and hald/linux/blockdev.c:block_rescan_storage_done().
 				 */
-				if (vid->usage_id == VOLUME_ID_FILESYSTEM ||
-				    vid->usage_id == VOLUME_ID_RAID ||
-				    vid->usage_id == VOLUME_ID_OTHER ||
-				    vid->usage_id == VOLUME_ID_CRYPTO)
+
+				if (volume_id_get_usage(vid, &usage) &&
+				    strcmp(usage, "filesystem") == 0 ||
+				    strcmp(usage, "raid") == 0 ||
+				    strcmp(usage, "other") == 0 ||
+				    strcmp(usage, "crypto") == 0)
 					ret = 2;
 			} else {
 				;
diff --git a/hald/linux/probing/probe-volume.c b/hald/linux/probing/probe-volume.c
index b003b25..de30047 100644
--- a/hald/linux/probing/probe-volume.c
+++ b/hald/linux/probing/probe-volume.c
@@ -93,56 +93,48 @@ set_volume_id_values (LibHalContext *ctx
 {
 	char buf[256];
 	const char *usage;
-	char *volume_label;
+	const char *type;
+	const char *type_version;
+	const char *label;
+	const char *uuid;
 	DBusError error;
 
 	dbus_error_init (&error);
 
-	switch (vid->usage_id) {
-	case VOLUME_ID_FILESYSTEM:
-		usage = "filesystem";
-		break;
-	case VOLUME_ID_OTHER:
-		usage = "other";
-		break;
-	case VOLUME_ID_RAID:
-		usage = "raid";
-		break;
-	case VOLUME_ID_CRYPTO:
-		usage = "crypto";
-		break;
-	case VOLUME_ID_UNUSED:
-		libhal_changeset_set_property_string (cs, "info.product", "Volume (unused)");
-		usage = "unused";
-		return;
-	default:
+	if (!volume_id_get_usage(vid, &usage))
 		usage = "";
-	}
-
 	libhal_changeset_set_property_string (cs, "volume.fsusage", usage);
 	HAL_DEBUG (("volume.fsusage = '%s'", usage));
 
-	if (!libhal_changeset_set_property_string (cs, "volume.fstype", vid->type))
+	if (!volume_id_get_type(vid, &type))
+		type = "";
+	if (!libhal_changeset_set_property_string (cs, "volume.fstype", type))
 		libhal_changeset_set_property_string (cs, "volume.fstype", "");
+	HAL_DEBUG(("volume.fstype = '%s'", type));
 
-	HAL_DEBUG(("volume.fstype = '%s'", vid->type));
+	if (!volume_id_get_type_version(vid, &type_version))
+		type_version = "";
+	libhal_changeset_set_property_string (cs, "volume.fsversion", type_version);
+	HAL_DEBUG(("volume.fsversion = '%s'", type_version));
+
+	if (!volume_id_get_uuid(vid, &uuid))
+		uuid = "";
+	libhal_changeset_set_property_string (cs, "volume.uuid", uuid);
+	HAL_DEBUG(("volume.uuid = '%s'", uuid));
 
-	if (vid->type_version[0] != '\0') {
-		libhal_changeset_set_property_string (cs, "volume.fsversion", vid->type_version);
-		HAL_DEBUG(("volume.fsversion = '%s'", vid->type_version));
-	}
+	if (!volume_id_get_label(vid, &label))
+		label = "";
 
-	libhal_changeset_set_property_string (cs, "volume.uuid", vid->uuid);
-	HAL_DEBUG(("volume.uuid = '%s'", vid->uuid));
+	if (label[0] != '\0') {
+		char *volume_label;
 
-	if(vid->label != NULL && vid->label[0] != '\0') {
 		/* we need to be sure for a utf8 valid label, because dbus accept only utf8 valid strings */
-		volume_label = strdup_valid_utf8 (vid->label);
+		volume_label = strdup_valid_utf8 (label);
 		if( volume_label != NULL ) {
 			libhal_changeset_set_property_string (cs, "volume.label", volume_label);
 			HAL_DEBUG(("volume.label = '%s'", volume_label));
-		
-			if (strlen(volume_label) > 0) {	
+
+			if (volume_label[0] != '\0') {
 				libhal_changeset_set_property_string (cs, "info.product", volume_label);
 				g_free(volume_label);
 				return;
@@ -152,12 +144,11 @@ set_volume_id_values (LibHalContext *ctx
 		}
 	}
 
-	if (vid->type != NULL) {
-		snprintf (buf, sizeof (buf), "Volume (%s)", vid->type);
+	if (type[0] != '\0') {
+		snprintf (buf, sizeof (buf), "Volume (%s)", type);
 	} else {
 		snprintf (buf, sizeof (buf), "Volume (unknown)");
 	}
-
 	libhal_changeset_set_property_string (cs, "info.product", buf);
 }
 
@@ -623,7 +614,7 @@ main (int argc, char *argv[])
 		if (vid != NULL) {
 			int vid_ret;
 			HAL_INFO (("invoking volume_id_probe_all, offset=%d, size=%d", vol_probe_offset, vol_size));
-			vid_ret = volume_id_probe_all (vid, vol_probe_offset , vol_size);
+			vid_ret = volume_id_probe_all (vid, vol_probe_offset, vol_size);
 			HAL_INFO (("volume_id_probe_all returned %d", vid_ret));
 
 			if (vid_ret != 0 && is_disc && vol_probe_offset != 0) {
@@ -644,15 +635,14 @@ 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
-			 * if it's a disc.. look whether it's a partition table (some Apple discs
+			/* If we didn't detect anything, 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 (vid->usage_id == VOLUME_ID_UNUSED && is_disc) {
+			if (vid_ret != 0 && is_disc) {
 				PartitionTable *p;
 				p = part_table_load_from_disk (stordev_dev_file);
 				if (p != NULL) {


More information about the hal-commit mailing list