summaryrefslogtreecommitdiffstats
path: root/source/l/hal/patches/fix_md_crash.diff
blob: 8a404c77f8a582bc04e2690070c5d65c5e0eb6f8 (about) (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
Backported from b35bf1fbfc000749010a27f3f35a95ddf6bb0b07 Mon Sep 17 00:00:00 2001
From: Chris Coulson <chrisccoulson@googlemail.com>
Subject: 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

--- a/hald/linux/blockdev.c	2008-05-08 01:23:41.000000000 +0200
+++ b/hald/linux/blockdev.c	2009-06-04 12:48:31.000000000 +0200
@@ -1392,10 +1392,15 @@ hotplug_event_begin_add_blockdev (const 
 		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)
@@ -1404,8 +1409,10 @@ hotplug_event_begin_add_blockdev (const 
 		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");