summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2012-01-05 14:09:46 -0500
committerDavid Zeuthen <davidz@redhat.com>2012-01-05 14:09:46 -0500
commita78dee15d6c96e9cb608c4169da4ec2e82190691 (patch)
tree2d9149959c49172c0c45dedb41cc4fbc5b6179cf
parentb6f13596478ddf234ae814cd007ab806a80cb5c1 (diff)
downloadgvfs-a78dee15d6c96e9cb608c4169da4ec2e82190691.tar.gz
Properly handle LABEL= and UUID= fstab entries
Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--monitor/udisks2/gvfsudisks2volumemonitor.c46
1 files changed, 43 insertions, 3 deletions
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index 8e117ac2..0488993f 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -939,12 +939,31 @@ find_volume_for_device (GVfsUDisks2VolumeMonitor *monitor,
const gchar *device)
{
GVfsUDisks2Volume *ret = NULL;
+ GList *blocks = NULL;
GList *l;
struct stat statbuf;
/* don't consider e.g. network mounts */
- if (!g_str_has_prefix (device, "/dev/"))
- goto out;
+ if (g_str_has_prefix (device, "LABEL="))
+ {
+ blocks = udisks_client_get_block_for_label (monitor->client, device + 6);
+ if (blocks != NULL)
+ device = udisks_block_get_device (UDISKS_BLOCK (blocks->data));
+ else
+ goto out;
+ }
+ else if (g_str_has_prefix (device, "UUID="))
+ {
+ blocks = udisks_client_get_block_for_uuid (monitor->client, device + 6);
+ if (blocks != NULL)
+ device = udisks_block_get_device (UDISKS_BLOCK (blocks->data));
+ else
+ goto out;
+ }
+ else if (!g_str_has_prefix (device, "/dev/"))
+ {
+ goto out;
+ }
if (stat (device, &statbuf) != 0)
goto out;
@@ -970,6 +989,8 @@ find_volume_for_device (GVfsUDisks2VolumeMonitor *monitor,
}
out:
+ g_list_foreach (blocks, (GFunc) g_object_unref, NULL);
+ g_list_free (blocks);
return ret;
}
@@ -1193,9 +1214,26 @@ mount_point_has_device (GVfsUDisks2VolumeMonitor *monitor,
const gchar *device;
struct stat statbuf;
UDisksBlock *block;
+ GList *blocks = NULL;
device = g_unix_mount_point_get_device_path (mount_point);
- if (!g_str_has_prefix (device, "/dev/"))
+ if (g_str_has_prefix (device, "LABEL="))
+ {
+ blocks = udisks_client_get_block_for_label (monitor->client, device + 6);
+ if (blocks != NULL)
+ device = udisks_block_get_device (UDISKS_BLOCK (blocks->data));
+ else
+ goto out;
+ }
+ else if (g_str_has_prefix (device, "UUID="))
+ {
+ blocks = udisks_client_get_block_for_uuid (monitor->client, device + 6);
+ if (blocks != NULL)
+ device = udisks_block_get_device (UDISKS_BLOCK (blocks->data));
+ else
+ goto out;
+ }
+ else if (!g_str_has_prefix (device, "/dev/"))
{
/* NFS, CIFS and other non-device mounts always have a device */
ret = TRUE;
@@ -1234,6 +1272,8 @@ mount_point_has_device (GVfsUDisks2VolumeMonitor *monitor,
ret = TRUE;
out:
+ g_list_foreach (blocks, (GFunc) g_object_unref, NULL);
+ g_list_free (blocks);
return ret;
}