summaryrefslogtreecommitdiff
path: root/monitor/udisks2
diff options
context:
space:
mode:
authorOndrej Holy <oholy@redhat.com>2018-02-19 18:03:26 +0100
committerOndrej Holy <oholy@redhat.com>2018-02-20 09:06:18 +0100
commit0ce3af810e64efe22439284cb1eaa46f914dab21 (patch)
tree5466cf682f4aaa1ce439d1304b4c3e9dc8e61bc0 /monitor/udisks2
parent76e4121c05bd81cf005d714554b8085686101de2 (diff)
downloadgvfs-0ce3af810e64efe22439284cb1eaa46f914dab21.tar.gz
udisks2: Add support for PARTLABEL and PARTUUID
Currently, PARTLABEL and PARTUUID is not handled and consequently redundant GVfsUDisks2Volume is presented. Add support for them. https://bugzilla.gnome.org/show_bug.cgi?id=793545
Diffstat (limited to 'monitor/udisks2')
-rw-r--r--monitor/udisks2/gvfsudisks2volumemonitor.c53
1 files changed, 53 insertions, 0 deletions
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index fab7ccdc..cd6f78d5 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -1186,6 +1186,37 @@ find_lonely_mount_for_mount_point (GVfsUDisks2VolumeMonitor *monitor,
/* ---------------------------------------------------------------------------------------------------- */
+static const char *
+_udisks_client_get_device_for_part (UDisksClient *client, const char *label, const char *uuid)
+{
+ GList *objects;
+ const char *device = NULL;
+ GList *l;
+
+ objects = g_dbus_object_manager_get_objects (udisks_client_get_object_manager (client));
+ for (l = objects; l != NULL; l = l->next)
+ {
+ UDisksPartition *partition;
+ UDisksBlock *block;
+
+ partition = udisks_object_peek_partition (UDISKS_OBJECT (l->data));
+ block = udisks_object_peek_block (UDISKS_OBJECT (l->data));
+ if (partition == NULL || block == NULL)
+ continue;
+
+ if ((label != NULL && g_strcmp0 (udisks_partition_get_name (partition), label) == 0) ||
+ (uuid != NULL && g_strcmp0 (udisks_partition_get_uuid (partition), uuid) == 0))
+ {
+ device = udisks_block_get_device (block);
+ break;
+ }
+ }
+
+ g_list_free_full (objects, g_object_unref);
+
+ return device;
+}
+
static GVfsUDisks2Volume *
find_volume_for_device (GVfsUDisks2VolumeMonitor *monitor,
const gchar *device)
@@ -1212,11 +1243,22 @@ find_volume_for_device (GVfsUDisks2VolumeMonitor *monitor,
else
goto out;
}
+ else if (g_str_has_prefix (device, "PARTLABEL="))
+ {
+ device = _udisks_client_get_device_for_part (monitor->client, device + 10, NULL);
+ }
+ else if (g_str_has_prefix (device, "PARTUUID="))
+ {
+ device = _udisks_client_get_device_for_part (monitor->client, NULL, device + 9);
+ }
else if (!g_str_has_prefix (device, "/dev/"))
{
goto out;
}
+ if (device == NULL)
+ goto out;
+
if (stat (device, &statbuf) != 0)
goto out;
@@ -1485,6 +1527,14 @@ mount_point_has_device (GVfsUDisks2VolumeMonitor *monitor,
else
goto out;
}
+ else if (g_str_has_prefix (device, "PARTLABEL="))
+ {
+ device = _udisks_client_get_device_for_part (monitor->client, device + 10, NULL);
+ }
+ else if (g_str_has_prefix (device, "PARTUUID="))
+ {
+ device = _udisks_client_get_device_for_part (monitor->client, NULL, device + 9);
+ }
else if (!g_str_has_prefix (device, "/dev/"))
{
/* NFS, CIFS and other non-device mounts always have a device */
@@ -1492,6 +1542,9 @@ mount_point_has_device (GVfsUDisks2VolumeMonitor *monitor,
goto out;
}
+ if (device == NULL)
+ goto out;
+
if (stat (device, &statbuf) != 0)
goto out;