[gvfs/wip/oholy/bind-mounts: 3/5] udisks2: Improve handling of mounts which doesn't point into fs root



commit ab82d984e7961516cd36d5c5e3450897f44cc46f
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Apr 27 12:56:42 2018 +0200

    udisks2: Improve handling of mounts which doesn't point into fs root
    
    UDisks2 handling of mounts which doesn't point into fs root (created
    over bind operation, or btrfs subvolumes) is not optimal, see:
    https://github.com/storaged-project/udisks/issues/478
    
    Also GIO API doesn't expect that one GVolume can have multiple
    mountpoints. Thus don't try to match UDisksBlock with mount which
    doesn't point into fs root and create standalone GVfsUDisks2Mount
    for it (or use GVfsUDisks2Volume corresponding with fstab entry).
    
    https://gitlab.gnome.org/GNOME/gvfs/issues/330

 monitor/udisks2/gvfsudisks2volumemonitor.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
---
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index 57917b50..2b2285f9 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -760,7 +760,10 @@ should_include_volume_check_mount_points (GVfsUDisks2VolumeMonitor *monitor,
       mount_entry = g_unix_mount_at (mount_point, NULL);
       if (mount_entry != NULL)
         {
-          if (should_include_mount (monitor, mount_entry))
+          const gchar *root = g_unix_mount_get_root_path (mount_entry);
+
+          if ((root == NULL || g_strcmp0 (root, "/") == 0) &&
+              should_include_mount (monitor, mount_entry))
             {
               g_unix_mount_free (mount_entry);
               ret = TRUE;
@@ -1706,7 +1709,11 @@ update_mounts (GVfsUDisks2VolumeMonitor  *monitor,
   for (l = added; l != NULL; l = l->next)
     {
       GUnixMountEntry *mount_entry = l->data;
-      volume = find_volume_for_device (monitor, g_unix_mount_get_device_path (mount_entry));
+      const gchar *root = g_unix_mount_get_root_path (mount_entry);
+
+      volume = NULL;
+      if (root == NULL || g_strcmp0 (root, "/") == 0)
+        volume = find_volume_for_device (monitor, g_unix_mount_get_device_path (mount_entry));
       if (volume == NULL)
         volume = find_fstab_volume_for_mount_entry (monitor, mount_entry);
       mount = gvfs_udisks2_mount_new (monitor, mount_entry, volume); /* adopts mount_entry */
@@ -1738,7 +1745,11 @@ update_mounts (GVfsUDisks2VolumeMonitor  *monitor,
         }
       if (gvfs_udisks2_mount_get_volume (mount) == NULL)
         {
-          volume = find_volume_for_device (monitor, g_unix_mount_get_device_path (mount_entry));
+          const gchar *root = g_unix_mount_get_root_path (mount_entry);
+
+          volume = NULL;
+          if (root == NULL || g_strcmp0 (root, "/") == 0)
+            volume = find_volume_for_device (monitor, g_unix_mount_get_device_path (mount_entry));
           if (volume == NULL)
             volume = find_fstab_volume_for_mount_entry (monitor, mount_entry);
           if (volume != NULL)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]