[gvfs] udisks2: Add support for PARTLABEL and PARTUUID
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gvfs] udisks2: Add support for PARTLABEL and PARTUUID
- Date: Tue, 20 Feb 2018 08:41:23 +0000 (UTC)
commit 0ce3af810e64efe22439284cb1eaa46f914dab21
Author: Ondrej Holy <oholy redhat com>
Date: Mon Feb 19 18:03:26 2018 +0100
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
monitor/udisks2/gvfsudisks2volumemonitor.c | 53 ++++++++++++++++++++++++++++
1 files changed, 53 insertions(+), 0 deletions(-)
---
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index fab7ccd..cd6f78d 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;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]