summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Coulson <chrisccoulson@googlemail.com>2009-05-15 18:30:14 +0200
committerMartin Pitt <martin.pitt@ubuntu.com>2009-05-15 18:30:14 +0200
commitb35bf1fbfc000749010a27f3f35a95ddf6bb0b07 (patch)
treed0da8144bde08b1a53c09b8663f0988177dd3dd3
parentf920b2ea40ef8741036740c4eb13a8584a5a8238 (diff)
fix crash when assembling certain MD devices
Don't assume that the parent of a volume has storage capability; e. g. if we are an MD partition then this is the case as we were re-parented to the root computer device object earlier. FD#21603
-rw-r--r--hald/linux/blockdev.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/hald/linux/blockdev.c b/hald/linux/blockdev.c
index f343e759..69ba0262 100644
--- a/hald/linux/blockdev.c
+++ b/hald/linux/blockdev.c
@@ -1498,8 +1498,15 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
hal_device_property_set_bool (d, "volume.is_mounted", FALSE);
hal_device_property_set_bool (d, "volume.is_mounted_read_only", FALSE);
hal_device_property_set_bool (d, "volume.linux.is_device_mapper", is_device_mapper);
- hal_device_property_set_bool (d, "volume.is_disc", strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0);
-
+ /* Don't assume that the parent has storage capability, eg
+ * if we are an MD partition then this is the case as we were
+ * re-parented to the root computer device object earlier.
+ */
+ if (hal_device_has_property(parent, "storage.drive_type")) {
+ hal_device_property_set_bool (d, "volume.is_disc", strcmp (hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0);
+ } else {
+ hal_device_property_set_bool (d, "volume.is_disc", FALSE);
+ }
is_physical_partition = TRUE;
if (is_fakevolume || is_device_mapper)
@@ -1508,8 +1515,10 @@ hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const gchar *device_f
hal_device_property_set_bool (d, "volume.is_partition", is_physical_partition);
hal_device_property_set_string (d, "info.category", "volume");
- if (strcmp(hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0) {
- hal_device_add_capability (d, "volume.disc");
+ if (hal_device_has_property(parent, "storage.drive_type")) {
+ if (strcmp(hal_device_property_get_string (parent, "storage.drive_type"), "cdrom") == 0) {
+ hal_device_add_capability (d, "volume.disc");
+ }
}
hal_device_add_capability (d, "volume");
hal_device_add_capability (d, "block");