hal: Branch 'master'
David Zeuthen
david at kemper.freedesktop.org
Fri Aug 4 12:54:19 PDT 2006
hald/linux2/blockdev.c | 7 ++++---
hald/linux2/blockdev.h | 2 +-
hald/linux2/hotplug.c | 23 ++++++++++-------------
3 files changed, 15 insertions(+), 17 deletions(-)
New commits:
diff-tree 57a4df10e1d8d2919d2fc2ad358bbfd0de702953 (from ed5a49f12738fb2ce182f2781aa1d57d7ff4567b)
Author: David Zeuthen <davidz at redhat.com>
Date: Fri Aug 4 15:53:49 2006 -0400
use a more robust way of detecting partitions and fix block.is_volume
diff --git a/hald/linux2/blockdev.c b/hald/linux2/blockdev.c
index ff768b8..bffc4e8 100644
--- a/hald/linux2/blockdev.c
+++ b/hald/linux2/blockdev.c
@@ -872,7 +872,7 @@ hotplug_event_begin_add_blockdev (const
hal_device_property_set_int (d, "block.major", major);
hal_device_property_set_int (d, "block.minor", minor);
- hal_device_property_set_bool (d, "block.is_volume", is_partition);
+ hal_device_property_set_bool (d, "block.is_volume", is_partition || is_device_mapper);
if (hal_device_has_property(parent, "info.bus") &&
(strcmp(hal_device_property_get_string(parent, "info.bus"), "platform") == 0) &&
@@ -1346,11 +1346,11 @@ force_unmount (HalDevice *d, void *end_t
}
void
-hotplug_event_begin_remove_blockdev (const gchar *sysfs_path, gboolean is_partition, void *end_token)
+hotplug_event_begin_remove_blockdev (const gchar *sysfs_path, void *end_token)
{
HalDevice *d;
- HAL_INFO (("block_rem: sysfs_path=%s is_part=%d", sysfs_path, is_partition));
+ HAL_INFO (("block_rem: sysfs_path=%s is_part=%d", sysfs_path));
d = hal_device_store_match_key_value_string (hald_get_gdl (), "linux.sysfs_path", sysfs_path);
if (d == NULL) {
@@ -1361,6 +1361,7 @@ hotplug_event_begin_remove_blockdev (con
HalDevice *stor_dev;
gboolean is_fakevolume;
gboolean is_device_mapper;
+ gboolean is_partition;
is_partition = hal_device_property_get_bool (d, "volume.is_partition");
is_device_mapper = hal_device_property_get_bool (d, "volume.linux.is_device_mapper");
diff --git a/hald/linux2/blockdev.h b/hald/linux2/blockdev.h
index 942b22d..9095d8c 100644
--- a/hald/linux2/blockdev.h
+++ b/hald/linux2/blockdev.h
@@ -30,7 +30,7 @@
void hotplug_event_begin_add_blockdev (const gchar *sysfs_path, const char *device_file, gboolean is_partition, HalDevice *parent, void *end_token);
-void hotplug_event_begin_remove_blockdev (const gchar *sysfs_path, gboolean is_partition, void *end_token);
+void hotplug_event_begin_remove_blockdev (const gchar *sysfs_path, void *end_token);
gboolean blockdev_rescan_device (HalDevice *d);
diff --git a/hald/linux2/hotplug.c b/hald/linux2/hotplug.c
index 0059532..eaca546 100644
--- a/hald/linux2/hotplug.c
+++ b/hald/linux2/hotplug.c
@@ -279,20 +279,18 @@ hotplug_event_begin_sysfs (HotplugEvent
(void *) hotplug_event);
}
} else if (hotplug_event->type == HOTPLUG_EVENT_SYSFS_BLOCK) {
- gboolean is_partition;
- 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;
+ int range;
+ gboolean is_partition;
+
+ /* it's a partition if and only if it doesn't have the range file...
+ * notably the device mapper partitions do have a range file, but that's
+ * fine, we don't count them as partitions anyway...
+ */
+ is_partition = TRUE;
+ if (hal_util_get_int_from_file (hotplug_event->sysfs.sysfs_path, "range", &range, 0))
+ is_partition = FALSE;
if (is_partition) {
gchar *parent_path;
@@ -327,7 +325,6 @@ hotplug_event_begin_sysfs (HotplugEvent
(void *) hotplug_event);
} else if (hotplug_event->action == HOTPLUG_ACTION_REMOVE) {
hotplug_event_begin_remove_blockdev (hotplug_event->sysfs.sysfs_path,
- is_partition,
(void *) hotplug_event);
}
} else {
More information about the hal-commit
mailing list