summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2011-08-15 03:58:22 -0400
committerDavid Zeuthen <davidz@redhat.com>2011-08-15 03:58:22 -0400
commit68c6a224e5eecbdd0082ae20cf62dfe6610d35f4 (patch)
tree254734d2a5d386d8adabd83e39f364f5232cd3e8
parentfa2c478a89ec454a3594bf6fbc5368130819bd38 (diff)
Fix drive lookup logic for partitions
Commit 609fcd3515942140c14561e516923af70a6d4128 accidentally broke setting the BlockDevice:Drive for partitions. Fix it. Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--src/udiskslinuxblock.c12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/udiskslinuxblock.c b/src/udiskslinuxblock.c
index 74fb5a7..bec388d 100644
--- a/src/udiskslinuxblock.c
+++ b/src/udiskslinuxblock.c
@@ -1234,14 +1234,19 @@ find_drive (GDBusObjectManagerServer *object_manager,
GUdevDevice *block_device,
UDisksDrive **out_drive)
{
- const gchar *block_device_sysfs_path;
+ GUdevDevice *whole_disk_block_device;
+ const gchar *whole_disk_block_device_sysfs_path;
gchar *ret;
GList *objects;
GList *l;
ret = NULL;
- block_device_sysfs_path = g_udev_device_get_sysfs_path (block_device);
+ if (g_strcmp0 (g_udev_device_get_devtype (block_device), "disk") == 0)
+ whole_disk_block_device = g_object_ref (block_device);
+ else
+ whole_disk_block_device = g_udev_device_get_parent_with_subsystem (block_device, "block", "disk");
+ whole_disk_block_device_sysfs_path = g_udev_device_get_sysfs_path (whole_disk_block_device);
objects = g_dbus_object_manager_get_objects (G_DBUS_OBJECT_MANAGER (object_manager));
for (l = objects; l != NULL; l = l->next)
@@ -1263,7 +1268,7 @@ find_drive (GDBusObjectManagerServer *object_manager,
const gchar *drive_sysfs_path;
drive_sysfs_path = g_udev_device_get_sysfs_path (drive_device);
- if (g_strcmp0 (block_device_sysfs_path, drive_sysfs_path) == 0)
+ if (g_strcmp0 (whole_disk_block_device_sysfs_path, drive_sysfs_path) == 0)
{
if (out_drive != NULL)
*out_drive = udisks_object_get_drive (UDISKS_OBJECT (object));
@@ -1280,6 +1285,7 @@ find_drive (GDBusObjectManagerServer *object_manager,
out:
g_list_foreach (objects, (GFunc) g_object_unref, NULL);
g_list_free (objects);
+ g_object_unref (whole_disk_block_device);
return ret;
}