diff options
author | Alexander Larsson <alexl@redhat.com> | 2009-03-04 18:27:10 +0000 |
---|---|---|
committer | Alexander Larsson <alexl@src.gnome.org> | 2009-03-04 18:27:10 +0000 |
commit | 80915d66fb393cc87929ec9cc814c455525b5c30 (patch) | |
tree | ed6752448c2e54c1d7e21551bf2cd90054f18142 | |
parent | b40a2805f8b9e9c7e89c6cdc8b0fdd31a20a7253 (diff) | |
download | gvfs-80915d66fb393cc87929ec9cc814c455525b5c30.tar.gz |
Bug 573837 – gvfs-fuse does not support ftruncate size != 0
2009-03-04 Alexander Larsson <alexl@redhat.com>
Bug 573837 – gvfs-fuse does not support ftruncate size != 0
* client/gvfsfusedaemon.c:
Support ftruncate to the current size as a NOP.
Fixes OOo saving
svn path=/trunk/; revision=2286
-rw-r--r-- | ChangeLog | 8 | ||||
-rw-r--r-- | client/gvfsfusedaemon.c | 48 |
2 files changed, 51 insertions, 5 deletions
@@ -1,5 +1,13 @@ 2009-03-04 Alexander Larsson <alexl@redhat.com> + Bug 573837 – gvfs-fuse does not support ftruncate size != 0 + + * client/gvfsfusedaemon.c: + Support ftruncate to the current size as a NOP. + Fixes OOo saving + +2009-03-04 Alexander Larsson <alexl@redhat.com> + * monitor/proxy/gproxyvolumemonitor.c: Break circular dependencies on dispose. diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c index a74924c6..9071776f 100644 --- a/client/gvfsfusedaemon.c +++ b/client/gvfsfusedaemon.c @@ -75,8 +75,7 @@ typedef struct { gchar *path; FileOp op; gpointer stream; - gint length; - size_t pos; + goffset pos; } FileHandle; static GThread *subthread = NULL; @@ -1739,12 +1738,46 @@ vfs_rmdir (const gchar *path) return result; } +static gboolean +file_handle_get_size (FileHandle *fh, + goffset *size) +{ + GFileInfo *info; + gboolean res; + + if (fh->stream == NULL) + return FALSE; + + info = NULL; + if (fh->op == FILE_OP_READ) + info = g_file_input_stream_query_info (fh->stream, + G_FILE_ATTRIBUTE_STANDARD_SIZE, + NULL, NULL); + else if (fh->op == FILE_OP_WRITE) + info = g_file_output_stream_query_info (fh->stream, + G_FILE_ATTRIBUTE_STANDARD_SIZE, + NULL, NULL); + + res = FALSE; + if (info) + { + if (g_file_info_has_attribute (info, G_FILE_ATTRIBUTE_STANDARD_SIZE)) + { + *size = g_file_info_get_size (info); + res = TRUE; + } + g_object_unref (info); + } + return res; +} + static gint vfs_ftruncate (const gchar *path, off_t size, struct fuse_file_info *fi) { GFile *file; GError *error = NULL; gint result = 0; + goffset current_size; debug_print ("vfs_ftruncate: %s\n", path); @@ -1784,9 +1817,14 @@ vfs_ftruncate (const gchar *path, off_t size, struct fuse_file_info *fi) fh->stream = NULL; } } - else - { - result = -ENOTSUP; + else if (file_handle_get_size (fh, ¤t_size) && + current_size == size) + { + /* Don't have to do anything to succeed */ + } + else + { + result = -ENOTSUP; } if (error) |