mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-04-21 22:59:16 +02:00
gio: Only show mounts in /run/media/$USER
And reflect the recent changes + sync with gvfs+udisks2 rules. https://bugzilla.gnome.org/show_bug.cgi?id=669797
This commit is contained in:
parent
b0739f2223
commit
f3fca56b7e
@ -2071,13 +2071,15 @@ gboolean
|
|||||||
g_unix_mount_guess_should_display (GUnixMountEntry *mount_entry)
|
g_unix_mount_guess_should_display (GUnixMountEntry *mount_entry)
|
||||||
{
|
{
|
||||||
const char *mount_path;
|
const char *mount_path;
|
||||||
|
const gchar *user_name;
|
||||||
|
gsize user_name_len;
|
||||||
|
|
||||||
/* Never display internal mountpoints */
|
/* Never display internal mountpoints */
|
||||||
if (g_unix_mount_is_system_internal (mount_entry))
|
if (g_unix_mount_is_system_internal (mount_entry))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
/* Only display things in /media (which are generally user mountable)
|
/* Only display things in /media (which are generally user mountable)
|
||||||
and home dir (fuse stuff) and $XDG_RUNTIME_DIR */
|
and home dir (fuse stuff) and /run/media/$USER */
|
||||||
mount_path = mount_entry->mount_path;
|
mount_path = mount_entry->mount_path;
|
||||||
if (mount_path != NULL)
|
if (mount_path != NULL)
|
||||||
{
|
{
|
||||||
@ -2086,7 +2088,12 @@ g_unix_mount_guess_should_display (GUnixMountEntry *mount_entry)
|
|||||||
if (g_strstr_len (mount_path, -1, "/.") != NULL)
|
if (g_strstr_len (mount_path, -1, "/.") != NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
if (g_getenv ("XDG_RUNTIME_DIR") != NULL && g_str_has_prefix (mount_path, g_get_user_runtime_dir ()))
|
/* Check /run/media/$USER/ */
|
||||||
|
user_name = g_get_user_name ();
|
||||||
|
user_name_len = strlen (user_name);
|
||||||
|
if (strncmp (mount_path, "/run/media/", sizeof ("/run/media/") - 1) == 0 &&
|
||||||
|
strncmp (mount_path + sizeof ("/run/media/") - 1, user_name, user_name_len) == 0 &&
|
||||||
|
mount_path[sizeof ("/run/media/") - 1 + user_name_len] == '/')
|
||||||
is_in_runtime_dir = TRUE;
|
is_in_runtime_dir = TRUE;
|
||||||
|
|
||||||
if (is_in_runtime_dir || g_str_has_prefix (mount_path, "/media/"))
|
if (is_in_runtime_dir || g_str_has_prefix (mount_path, "/media/"))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user