[glib: 1/6] glocalfile: Allow trashing only for locations supported by trash:///



commit d1eaf72c001279aa15a2135a0749ef864c8edb42
Author: Ondrej Holy <oholy redhat com>
Date:   Fri Jun 1 13:41:53 2018 +0200

    glocalfile: Allow trashing only for locations supported by trash:///
    
    New bugs appears periodically in nautilus/gvfs/glib components that not
    all trashed files are shown in trash:///. It used to be problem mostly
    for "bind mounts" and btrfs subvolumes only. Currently, it is also
    problem for nfs, cifs and other filesystems, which have been recently
    added by commmit 0d69462f on the list of system internal filesystems.
    
    This happens because the trash backend doesn't monitor files on system
    internal mounts. Such behavior is not against the trash-spec, however,
    we should be consistent within GNOME.
    
    This behavior has the nice side-effect that it solves issues with hangs
    on network filesystems: https://gitlab.gnome.org/GNOME/glib/issues/605,
    because those are currently on the system internal filesystem list.
    
    https://gitlab.gnome.org/GNOME/glib/issues/251

 gio/glocalfile.c | 17 ++++++++++++++++-
 1 file changed, 16 insertions(+), 1 deletion(-)
---
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index 3cd0137d6..52e0ec294 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -1930,6 +1930,7 @@ g_local_file_trash (GFile         *file,
     {
       uid_t uid;
       char uid_str[32];
+      GUnixMountEntry *mount;
 
       uid = geteuid ();
       g_snprintf (uid_str, sizeof (uid_str), "%lu", (unsigned long)uid);
@@ -1942,7 +1943,21 @@ g_local_file_trash (GFile         *file,
                           file, G_IO_ERROR_NOT_SUPPORTED);
          return FALSE;
        }
-      
+
+      mount = g_unix_mount_at (topdir, NULL);
+      if (mount == NULL || g_unix_mount_is_system_internal (mount))
+        {
+          g_set_error (error, G_IO_ERROR, G_IO_ERROR_NOT_SUPPORTED,
+                       _("Trashing on system internal mounts is not supported"));
+
+          g_clear_pointer (&mount, g_unix_mount_free);
+          g_free (topdir);
+
+          return FALSE;
+        }
+
+      g_clear_pointer (&mount, g_unix_mount_free);
+
       /* Try looking for global trash dir $topdir/.Trash/$uid */
       globaldir = g_build_filename (topdir, ".Trash", NULL);
       if (g_lstat (globaldir, &global_stat) == 0 &&


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