summaryrefslogtreecommitdiff
path: root/client/gdaemonvfs.c
diff options
context:
space:
mode:
authorJens Georg <mail@jensge.org>2016-05-12 19:28:21 +0200
committerJens Georg <mail@jensge.org>2016-05-20 20:11:38 +0200
commit7196c5c98bfa03a19306be1072ca759864c363f1 (patch)
tree88f985a0837d3f4576cfa7a4000d01b4ca62f331 /client/gdaemonvfs.c
parentb7986553f898976bade0f4dc2f042c30ec550255 (diff)
downloadgvfs-7196c5c98bfa03a19306be1072ca759864c363f1.tar.gz
Always add mount prefix in cached fuse paths
If a fuse path is encountered the first time, the fuse path is re-created taking the mount prefix into account. When the file is created for the path the second time from the cached mount info, the mount prefix is silently ignored, causing the new file not to be equal to the old one (it is even invalid): This change just looks up the mount info in the cache and then continues constructing the path as it would without having the info cached. https://bugzilla.gnome.org/show_bug.cgi?id=766294
Diffstat (limited to 'client/gdaemonvfs.c')
-rw-r--r--client/gdaemonvfs.c63
1 files changed, 29 insertions, 34 deletions
diff --git a/client/gdaemonvfs.c b/client/gdaemonvfs.c
index 8a91570f..be1bbc6c 100644
--- a/client/gdaemonvfs.c
+++ b/client/gdaemonvfs.c
@@ -703,8 +703,7 @@ lookup_mount_info_in_cache (GMountSpec *spec,
}
static GMountInfo *
-lookup_mount_info_by_fuse_path_in_cache (const char *fuse_path,
- char **mount_path)
+lookup_mount_info_by_fuse_path_in_cache (const char *fuse_path)
{
GMountInfo *info;
GList *l;
@@ -717,19 +716,16 @@ lookup_mount_info_by_fuse_path_in_cache (const char *fuse_path,
if (mount_info->fuse_mountpoint != NULL &&
g_str_has_prefix (fuse_path, mount_info->fuse_mountpoint))
- {
- int len = strlen (mount_info->fuse_mountpoint);
- if (fuse_path[len] == 0 ||
- fuse_path[len] == '/')
- {
- if (fuse_path[len] == 0)
- *mount_path = g_strdup ("/");
- else
- *mount_path = g_strdup (fuse_path + len);
- info = g_mount_info_ref (mount_info);
- break;
- }
- }
+ {
+ int len = strlen (mount_info->fuse_mountpoint);
+ /* empty path always matches. Also check if we have a path
+ * not two paths that accidently share the same prefix */
+ if (fuse_path[len] == 0 || fuse_path[len] == '/')
+ {
+ info = g_mount_info_ref (mount_info);
+ break;
+ }
+ }
}
G_UNLOCK (mount_cache);
@@ -976,28 +972,27 @@ _g_daemon_vfs_get_mount_info_by_fuse_sync (const char *fuse_path,
GMountInfo *info;
int len;
const char *mount_path_end;
- GVfsDBusMountTracker *proxy;
+ GVfsDBusMountTracker *proxy = NULL;
GVariant *iter_mount;
- info = lookup_mount_info_by_fuse_path_in_cache (fuse_path,
- mount_path);
- if (info != NULL)
- return info;
-
- proxy = create_mount_tracker_proxy ();
- if (proxy == NULL)
- return NULL;
-
- if (gvfs_dbus_mount_tracker_call_lookup_mount_by_fuse_path_sync (proxy,
- fuse_path,
- &iter_mount,
- NULL,
- NULL))
+ info = lookup_mount_info_by_fuse_path_in_cache (fuse_path);
+ if (!info)
{
- info = handler_lookup_mount_reply (iter_mount, NULL);
- g_variant_unref (iter_mount);
+ proxy = create_mount_tracker_proxy ();
+ if (proxy == NULL)
+ return NULL;
+
+ if (gvfs_dbus_mount_tracker_call_lookup_mount_by_fuse_path_sync (proxy,
+ fuse_path,
+ &iter_mount,
+ NULL,
+ NULL))
+ {
+ info = handler_lookup_mount_reply (iter_mount, NULL);
+ g_variant_unref (iter_mount);
+ }
}
-
+
if (info)
{
if (info->fuse_mountpoint)
@@ -1020,7 +1015,7 @@ _g_daemon_vfs_get_mount_info_by_fuse_sync (const char *fuse_path,
}
}
- g_object_unref (proxy);
+ g_clear_object (&proxy);
return info;
}