summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2006-08-04 14:57:04 -0400
committerDavid Zeuthen <davidz@redhat.com>2006-08-04 14:57:04 -0400
commit963aa432d16ba81c3f5c404a02b8a5befef7521d (patch)
treeabc50de8bdf2fd5ff55c6d7ea895b7110d99b3fd
parentdb389f7d0b99b742dcde5cacfda5dcbc2bd9fc8f (diff)
fix up device mapper device handling
-rw-r--r--hald/linux2/blockdev.c10
-rw-r--r--hald/linux2/hotplug.c15
-rw-r--r--hald/linux2/physdev.c1
3 files changed, 19 insertions, 7 deletions
diff --git a/hald/linux2/blockdev.c b/hald/linux2/blockdev.c
index bf0b0149..ff768b88 100644
--- a/hald/linux2/blockdev.c
+++ b/hald/linux2/blockdev.c
@@ -788,12 +788,13 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
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 gchar *sysfs_path, const gchar *device_f
g_free (target);
}
g_dir_close (dir);
+ HAL_INFO (("Done looking in %s", path));
}
}
@@ -909,7 +911,7 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
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 gchar *sysfs_path, const gchar *device_f
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 d071bf79..00595326 100644
--- a/hald/linux2/hotplug.c
+++ b/hald/linux2/hotplug.c
@@ -280,11 +280,16 @@ hotplug_event_begin_sysfs (HotplugEvent *hotplug_event)
}
} else if (hotplug_event->type == HOTPLUG_EVENT_SYSFS_BLOCK) {
gboolean is_partition;
- size_t len;
-
- len = strlen(hotplug_event->sysfs.sysfs_path);
- is_partition = isdigit(hotplug_event->sysfs.sysfs_path[len - 1]) ||
- strstr (hotplug_event->sysfs.sysfs_path, "/fakevolume") ;
+ char **tokens;
+
+ /* 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 e73dc352..4679a9f8 100644
--- a/hald/linux2/physdev.c
+++ b/hald/linux2/physdev.c
@@ -682,6 +682,7 @@ scsi_add (const gchar *sysfs_path, HalDevice *parent)
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 */