[glib/halfline/test-case-pipe-confusion: 5/6] glocalfile: Support marking fuse.sshfs filesystems as remote




commit 910a331de9c810dac193d776b62fc7552ed5e11b
Author: Philip Withnall <pwithnall endlessos org>
Date:   Mon Oct 17 16:03:08 2022 +0100

    glocalfile: Support marking fuse.sshfs filesystems as remote
    
    This requires checking the type of a filesystem using `/proc/mounts`
    rather than `statfs()`, since `statfs()` doesn’t give the subtype of the
    mount. So it only returns `fuse` rather than `fuse.sshfs`.
    
    This commit changes the output of `gio info -f ./path/to/local/sshfs/mount`
    from `filesystem::remote: FALSE` to `filesystem::remote: TRUE`.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    Fixes: #2726

 gio/glocalfile.c | 24 +++++++++++++++---------
 1 file changed, 15 insertions(+), 9 deletions(-)
---
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index ed7a663d2a..4f8df369bb 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -787,6 +787,7 @@ get_mount_info (GFileInfo             *fs_info,
   dev_t *dev;
   GUnixMountEntry *mount;
   guint64 cache_time;
+  gboolean is_remote = FALSE;
 
   if (g_lstat (path, &buf) != 0)
     return;
@@ -823,6 +824,8 @@ get_mount_info (GFileInfo             *fs_info,
        {
          if (g_unix_mount_is_readonly (mount))
            mount_info |= MOUNT_INFO_READONLY;
+          if (is_remote_fs_type (g_unix_mount_get_fs_type (mount)))
+            is_remote = TRUE;
          
          g_unix_mount_free (mount);
        }
@@ -838,8 +841,14 @@ get_mount_info (GFileInfo             *fs_info,
       G_UNLOCK (mount_info_hash);
     }
 
-  if (mount_info & MOUNT_INFO_READONLY)
+  if (mount_info & MOUNT_INFO_READONLY &&
+      g_file_attribute_matcher_matches (matcher,
+                                        G_FILE_ATTRIBUTE_FILESYSTEM_READONLY))
     g_file_info_set_attribute_boolean (fs_info, G_FILE_ATTRIBUTE_FILESYSTEM_READONLY, TRUE);
+
+  if (g_file_attribute_matcher_matches (matcher,
+                                        G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE))
+    g_file_info_set_attribute_boolean (fs_info, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE, is_remote);
 }
 
 #endif
@@ -1085,7 +1094,9 @@ g_local_file_query_filesystem_info (GFile         *file,
 #endif /* G_OS_WIN32 */
 
   if (g_file_attribute_matcher_matches (attribute_matcher,
-                                       G_FILE_ATTRIBUTE_FILESYSTEM_READONLY))
+                                        G_FILE_ATTRIBUTE_FILESYSTEM_READONLY) ||
+      g_file_attribute_matcher_matches (attribute_matcher,
+                                        G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE))
     {
 #ifdef G_OS_WIN32
       get_filesystem_readonly (info, local->filename);
@@ -1094,13 +1105,6 @@ g_local_file_query_filesystem_info (GFile         *file,
 #endif /* G_OS_WIN32 */
     }
 
-#ifndef G_OS_WIN32
-  if (g_file_attribute_matcher_matches (attribute_matcher,
-                                        G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE))
-    g_file_info_set_attribute_boolean (info, G_FILE_ATTRIBUTE_FILESYSTEM_REMOTE,
-                                       is_remote_fs_type (fstype));
-#endif
-
   g_file_attribute_matcher_unref (attribute_matcher);
   
   return info;
@@ -2603,6 +2607,8 @@ is_remote_fs_type (const gchar *fsname)
         return TRUE;
       if (strcmp (fsname, "smb2") == 0)
         return TRUE;
+      if (strcmp (fsname, "fuse.sshfs") == 0)
+        return TRUE;
     }
 
   return FALSE;


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