hal: Branch 'master'

David Zeuthen david at kemper.freedesktop.org
Fri Aug 4 11:57:33 PDT 2006


 hald/linux2/blockdev.c |   10 ++++++++--
 hald/linux2/hotplug.c  |   13 +++++++++----
 hald/linux2/physdev.c  |    1 +
 3 files changed, 18 insertions(+), 6 deletions(-)

New commits:
diff-tree 963aa432d16ba81c3f5c404a02b8a5befef7521d (from db389f7d0b99b742dcde5cacfda5dcbc2bd9fc8f)
Author: David Zeuthen <davidz at redhat.com>
Date:   Fri Aug 4 14:57:04 2006 -0400

    fix up device mapper device handling

diff --git a/hald/linux2/blockdev.c b/hald/linux2/blockdev.c
index bf0b014..ff768b8 100644
--- a/hald/linux2/blockdev.c
+++ b/hald/linux2/blockdev.c
@@ -788,12 +788,13 @@ hotplug_event_begin_add_blockdev (const 
 	d = hal_device_new ();
 
 	/* OK, no parent... it might a device-mapper device => check slaves/ subdir in sysfs */
-	if (parent == NULL) {
+	if (parent == NULL && !is_partition) {
 		GDir *dir;
 		GError *err = NULL;
 		char path[HAL_PATH_MAX];
 
 		g_snprintf (path, HAL_PATH_MAX, "%s/slaves", sysfs_path);
+		HAL_INFO (("Looking in %s", path));
 		if ((dir = g_dir_open (path, 0, &err)) == NULL) {
 			HAL_WARNING (("Unable to open %s: %s", path, err->message));
 			g_error_free (err);
@@ -841,6 +842,7 @@ hotplug_event_begin_add_blockdev (const 
 				g_free (target);
 			}
 			g_dir_close (dir);
+			HAL_INFO (("Done looking in %s", path));
 		}
 		
 	}
@@ -909,7 +911,7 @@ hotplug_event_begin_add_blockdev (const 
 		goto out2;
 	}
 
-	if (!is_partition) {
+	if (!is_partition && !is_device_mapper) {
 		const char *udi_it;
 		const char *physdev_udi;
 		HalDevice *scsidev;
@@ -1052,6 +1054,10 @@ hotplug_event_begin_add_blockdev (const 
 		hal_device_property_set_bool (d, "storage.media_check_enabled", is_removable);
 
 		parent_bus = hal_device_property_get_string (parent, "info.bus");
+		if (parent_bus == NULL) {
+			HAL_INFO (("parent_bus is NULL - wrong parent?"));
+			goto error;
+		}
 		HAL_INFO (("parent_bus is %s", parent_bus));
 
 		/* per-bus specific properties */
diff --git a/hald/linux2/hotplug.c b/hald/linux2/hotplug.c
index d071bf7..0059532 100644
--- a/hald/linux2/hotplug.c
+++ b/hald/linux2/hotplug.c
@@ -280,11 +280,16 @@ hotplug_event_begin_sysfs (HotplugEvent 
 		}
 	} else if (hotplug_event->type == HOTPLUG_EVENT_SYSFS_BLOCK) {
 		gboolean is_partition;
-		size_t len;
+		char **tokens;
 
-		len = strlen(hotplug_event->sysfs.sysfs_path);
-		is_partition = isdigit(hotplug_event->sysfs.sysfs_path[len - 1]) ||
-			       strstr (hotplug_event->sysfs.sysfs_path, "/fakevolume") ;
+		/* it's a partition if and only if it's of the form /sys/block/sda/sda1 e.g.
+		 * four instead of three elements in the path
+		 */
+		is_partition = FALSE;
+		tokens = g_strsplit (hotplug_event->sysfs.sysfs_path, "/", 0);
+		if (g_strv_length (tokens) > 4 ) /* includes terminating NULL */
+			is_partition = TRUE;
+		g_strfreev (tokens);
 
 		if (hotplug_event->action == HOTPLUG_ACTION_ADD) {
 			HalDevice *parent = NULL;
diff --git a/hald/linux2/physdev.c b/hald/linux2/physdev.c
index e73dc35..4679a9f 100644
--- a/hald/linux2/physdev.c
+++ b/hald/linux2/physdev.c
@@ -682,6 +682,7 @@ scsi_add (const gchar *sysfs_path, HalDe
 	hal_util_set_string_from_file (d, "scsi.model", sysfs_path, "model");
 	hal_util_set_string_from_file (d, "scsi.vendor", sysfs_path, "vendor");
 	hal_util_get_int_from_file (sysfs_path, "type", &type, 0);
+	HAL_INFO (("%s/type -> %d (-> scsi.type)", sysfs_path, type));
 	switch (type) {
 	case 0:
 		/* Disk */



More information about the hal-commit mailing list