File glib2-trash-on-other-partitions.patch of Package glib2.9083

diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index 345214d..4624907 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -1859,6 +1859,43 @@ _g_local_file_is_lost_found_dir (const char *path, dev_t path_dev)
 }
 #endif
 
+/* find the mount entry for the directory containing 'file'.
+ * used to figure out what sort of filesystem the home trash
+ * folder is sitting on.
+ */
+static GUnixMountEntry *
+find_mount_entry_for_file (GFile *file)
+{
+  GUnixMountEntry *entry;
+  char *pathname;
+
+  pathname = g_file_get_path (file);
+  do
+    {
+      char *slash;
+
+      slash = strrchr (pathname, '/');
+
+      /* leave the leading '/' in place */
+      if (slash == pathname)
+        slash++;
+
+      *slash = '\0';
+
+      entry = g_unix_mount_at (pathname, NULL);
+    }
+  while (entry == NULL && pathname[1]);
+
+  g_free (pathname);
+
+  /* if the GUnixMount stuff is gummed up, this might fail.  we can't
+   * really proceed, since decide_watch_type() needs to know this.
+   */
+  g_assert (entry != NULL);
+
+  return entry;
+}
+
 static gboolean
 g_local_file_trash (GFile         *file,
 		    GCancellable  *cancellable,
@@ -1879,6 +1916,8 @@ g_local_file_trash (GFile         *file,
   char *dirname, *globaldir;
   GVfsClass *class;
   GVfs *vfs;
+  GUnixMountEntry *mount_entry;
+  gboolean is_system_internal;
 
   if (g_lstat (local->filename, &file_stat) != 0)
     {
@@ -1894,6 +1933,10 @@ g_local_file_trash (GFile         *file,
   homedir = g_get_home_dir ();
   g_stat (homedir, &home_stat);
 
+  mount_entry = find_mount_entry_for_file (file);
+  is_system_internal = g_unix_mount_is_system_internal(mount_entry) && !(file_stat.st_dev == home_stat.st_dev);
+  g_unix_mount_free (mount_entry);
+
   is_homedir_trash = FALSE;
   trashdir = NULL;
   if (file_stat.st_dev == home_stat.st_dev)
@@ -1917,6 +1960,13 @@ g_local_file_trash (GFile         *file,
 	}
       topdir = g_strdup (g_get_user_data_dir ());
     }
+  else if (is_system_internal)
+    {
+          g_set_error_literal (error, G_IO_ERROR,
+                               G_IO_ERROR_NOT_SUPPORTED,
+                               _("Not support system internal directory for trash"));
+          return FALSE;
+    }
   else
     {
       uid_t uid;
openSUSE Build Service is sponsored by