summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Zeuthen <davidz@redhat.com>2012-01-06 13:27:01 -0500
committerDavid Zeuthen <davidz@redhat.com>2012-01-06 13:27:01 -0500
commit0ba3edd76e0065f6a4229a3d4577698bbf252abf (patch)
tree95537b9a5dcfeebd63a94c983417e2cf2675623b
parenta78dee15d6c96e9cb608c4169da4ec2e82190691 (diff)
downloadgvfs-0ba3edd76e0065f6a4229a3d4577698bbf252abf.tar.gz
Use simpler version of g_unix_mount_should_display()
The version in GIO tries to be helpful and returns FALSE for mount points the user cannot access. We don't want that behavior since it makes the whole thing act unpredictable especially if using multiple systems with various user ids. Signed-off-by: David Zeuthen <davidz@redhat.com>
-rw-r--r--monitor/udisks2/gvfsudisks2volumemonitor.c76
1 files changed, 75 insertions, 1 deletions
diff --git a/monitor/udisks2/gvfsudisks2volumemonitor.c b/monitor/udisks2/gvfsudisks2volumemonitor.c
index 0488993f..2884dccf 100644
--- a/monitor/udisks2/gvfsudisks2volumemonitor.c
+++ b/monitor/udisks2/gvfsudisks2volumemonitor.c
@@ -573,12 +573,86 @@ update_all (GVfsUDisks2VolumeMonitor *monitor,
/* ---------------------------------------------------------------------------------------------------- */
+/* This is a SIMPLER version of g_unix_mount_guess_should_display()
+ * that does not do call g_access() on the mount point... (to
+ * e.g. return FALSE if the mount point is not accessible to the
+ * calling process).
+ *
+ * Why? Because having non-intuitive rules like the above, makes it
+ * really hard to debug things when the user reports a bug saying "I
+ * plugged in my USB disk but I can't see it"... for example, this can
+ * happen if plugging in an disk with a single ext4 filesystem where
+ * the files are only visible to another uid. In particular, this is
+ * evident with Fedora's recent transition from uid 500 to uid 1000.
+ *
+ * TODO: file a bug and get this change into GIO's
+ * g_unix_mount_guess_should_display() itself.
+ */
+
+static gboolean
+simple_g_unix_mount_guess_should_display (GUnixMountEntry *mount_entry)
+{
+ gboolean ret = FALSE;
+ const gchar *home_dir = NULL;
+ const gchar *mount_path;
+
+ /* Never display internal mountpoints */
+ if (g_unix_mount_is_system_internal (mount_entry))
+ goto out;
+
+ /* Only display things in
+ * - /media; and
+ * - $HOME; and
+ * - $XDG_RUNTIME_DIR
+ */
+ mount_path = g_unix_mount_get_mount_path (mount_entry);
+ if (mount_path == NULL)
+ goto out;
+
+ /* Hide mounts within a subdirectory starting with a "." - suppose it was a purpose to hide this mount */
+ if (g_strstr_len (mount_path, -1, "/.") != NULL)
+ goto out;
+
+ /* Check /media */
+ if (g_str_has_prefix (mount_path, "/media/"))
+ {
+ ret = TRUE;
+ goto out;
+ }
+
+ /* Check home dir */
+ home_dir = g_get_home_dir ();
+ if (home_dir != NULL)
+ {
+ if (g_str_has_prefix (mount_path, home_dir) && mount_path[strlen (home_dir)] == G_DIR_SEPARATOR)
+ {
+ ret = TRUE;
+ goto out;
+ }
+ }
+
+ /* Check runtime dir */
+ if (g_getenv ("XDG_RUNTIME_DIR") != NULL)
+ {
+ const gchar *run_dir = g_get_user_runtime_dir ();
+ if (g_str_has_prefix (mount_path, run_dir) && mount_path[strlen (run_dir)] == G_DIR_SEPARATOR)
+ {
+ ret = TRUE;
+ goto out;
+ }
+ }
+
+ out:
+ return ret;
+
+}
+
static gboolean
should_include_mount (GVfsUDisks2VolumeMonitor *monitor,
GUnixMountEntry *mount_entry)
{
gboolean ret = FALSE;
- ret = g_unix_mount_guess_should_display (mount_entry);
+ ret = simple_g_unix_mount_guess_should_display (mount_entry);
return ret;
}