[gvfs/wip/oholy/x-gvfs-ignore: 2/3] trash: Ignore mounts with x-gvfs-ignore



commit 2d8822178633913763639583e21280ec08197b5d
Author: Ondrej Holy <oholy redhat com>
Date:   Thu Feb 28 11:21:55 2019 +0100

    trash: Ignore mounts with x-gvfs-ignore
    
    Trash backend accesses all mounts in order to monitor trash folders.
    This is not always ideal as it can cause automount of autofs filesystems,
    wake up disks from standby etc. This patch introduces x-gvfs-ignore
    option, which allows marking mounts which should be ignored by gvfs.
    
    Closes: https://gitlab.gnome.org/GNOME/gvfs/issues/375

 daemon/trashlib/meson.build    |  1 +
 daemon/trashlib/trashwatcher.c | 30 +++++++++++++++++++++++++++++-
 2 files changed, 30 insertions(+), 1 deletion(-)
---
diff --git a/daemon/trashlib/meson.build b/daemon/trashlib/meson.build
index 8b8e20c3..0794ec7f 100644
--- a/daemon/trashlib/meson.build
+++ b/daemon/trashlib/meson.build
@@ -10,6 +10,7 @@ deps = [
   gio_dep,
   gio_unix_dep,
   glib_dep,
+  libgvfscommon_dep,
 ]
 
 libtrash = static_library(
diff --git a/daemon/trashlib/trashwatcher.c b/daemon/trashlib/trashwatcher.c
index 6b455235..f61eaa50 100644
--- a/daemon/trashlib/trashwatcher.c
+++ b/daemon/trashlib/trashwatcher.c
@@ -15,6 +15,7 @@
 
 #include "trashitem.h"
 #include "trashdir.h"
+#include <gvfsutils.h>
 
 typedef enum
 {
@@ -211,6 +212,33 @@ trash_mount_remove (TrashMount **mount_ptr)
   g_slice_free (TrashMount, mount);
 }
 
+static gboolean
+should_include (GUnixMountEntry *mount_entry)
+{
+  GUnixMountPoint *mount_point = NULL;
+  const gchar *options;
+  gchar *value;
+  gboolean ret = TRUE;
+
+  mount_point = gvfs_get_mount_point_for_mount (mount_entry);
+  if (mount_point != NULL)
+    options = g_unix_mount_point_get_options (mount_point);
+  else
+    options = g_unix_mount_get_options (mount_entry);
+
+  value = gvfs_lookup_fstab_options_value (options, "x-gvfs-ignore");
+  if (value != NULL)
+    {
+      ret = FALSE;
+      g_free (value);
+    }
+
+  if (mount_point != NULL)
+    g_unix_mount_point_free (mount_point);
+
+  return ret;
+}
+
 static void
 trash_watcher_remount (TrashWatcher *watcher)
 {
@@ -229,7 +257,7 @@ trash_watcher_remount (TrashWatcher *watcher)
     {
       int result;
 
-      if (new && g_unix_mount_is_system_internal (new->data))
+      if (new && (g_unix_mount_is_system_internal (new->data) || !should_include (new->data)))
         {
           g_unix_mount_free (new->data);
           new = new->next;


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