summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRoss Lagerwall <rosslagerwall@gmail.com>2014-07-26 11:38:55 +0100
committerRoss Lagerwall <rosslagerwall@gmail.com>2014-10-26 15:58:56 +0000
commit1ff4d6c13358ca3efbece1cf81298b44fdc8e855 (patch)
tree28c9e9784c211dc6e7faf2948a9f2a46cac80901
parent3800f5297b10f34a17502983ca11f89efae9ddea (diff)
downloadgvfs-1ff4d6c13358ca3efbece1cf81298b44fdc8e855.tar.gz
fuse: Close stream on release rather than flush
Before, if an application created, dup()ed the fd and then closed it, the stream would be closed. When attempting to write to the original fd, reopening the stream would fail since it is an error to open an existing file without either truncating it or appending to it. Close the stream on release() rather than flush() to fix this since release() is called only once per open/create rather than for each close. Since g_output_stream_flush() is called after every write, flush() and fsync() are unnecessary. https://bugzilla.gnome.org/show_bug.cgi?id=632296
-rw-r--r--client/gvfsfusedaemon.c48
1 files changed, 4 insertions, 44 deletions
diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
index 92ddf0fb..de37c3b2 100644
--- a/client/gvfsfusedaemon.c
+++ b/client/gvfsfusedaemon.c
@@ -1238,6 +1238,10 @@ vfs_release (const gchar *path, struct fuse_file_info *fi)
if (fh)
{
+ g_mutex_lock (&fh->mutex);
+ file_handle_close_stream (fh);
+ g_mutex_unlock (&fh->mutex);
+
/* get_file_handle_from_info () adds a "working ref", so unref twice. */
file_handle_unref (fh);
file_handle_unref (fh);
@@ -1530,48 +1534,6 @@ vfs_write (const gchar *path, const gchar *buf, size_t len, off_t offset,
}
static gint
-vfs_flush (const gchar *path, struct fuse_file_info *fi)
-{
- FileHandle *fh = get_file_handle_from_info (fi);
-
- debug_print ("vfs_flush: %s\n", path);
-
- if (fh)
- {
- g_mutex_lock (&fh->mutex);
- file_handle_close_stream (fh);
- g_mutex_unlock (&fh->mutex);
-
- /* get_file_handle_from_info () adds a "working ref", so release that. */
- file_handle_unref (fh);
- }
-
- /* TODO: Error handling. */
- return 0;
-}
-
-static gint
-vfs_fsync (const gchar *path, gint sync_data_only, struct fuse_file_info *fi)
-{
- FileHandle *fh = get_file_handle_from_info (fi);
-
- debug_print ("vfs_flush: %s\n", path);
-
- if (fh)
- {
- g_mutex_lock (&fh->mutex);
- file_handle_close_stream (fh);
- g_mutex_unlock (&fh->mutex);
-
- /* get_file_handle_from_info () adds a "working ref", so release that. */
- file_handle_unref (fh);
- }
-
- /* TODO: Error handling. */
- return 0;
-}
-
-static gint
vfs_opendir (const gchar *path, struct fuse_file_info *fi)
{
GFile *file;
@@ -2538,8 +2500,6 @@ static struct fuse_operations vfs_oper =
.open = vfs_open,
.create = vfs_create,
.release = vfs_release,
- .flush = vfs_flush,
- .fsync = vfs_fsync,
.read = vfs_read,
.write = vfs_write,