mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2024-12-25 15:06:14 +01:00
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
This commit is contained in:
parent
b7f2b09c30
commit
bcb5eee0ea
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user