[gvfs/wip/oholy/fuse-seek-fallback: 9/9] fuse: Reopen file and skip to desired offset if seek is not supported



commit 108979c2802ec07ab6eaee2a76d3762525c69b68
Author: Ondrej Holy <oholy redhat com>
Date:   Tue Jan 14 13:34:40 2020 +0100

    fuse: Reopen file and skip to desired offset if seek is not supported
    
    The fuse daemon can fail when client attempts to seek backwards and seek
    is not supported by the concrete backend. There is fallback for forward
    seeks using `g_input_stream_skip`. Let's reopen the file and use the same
    approach also for backwards seeks. This is pretty ugly to reopen the file
    but similar approach is used already to emulate read/write mode.
    
    Fixes: https://gitlab.gnome.org/GNOME/gvfs/issues/441

 client/gvfsfusedaemon.c | 8 ++++++++
 1 file changed, 8 insertions(+)
---
diff --git a/client/gvfsfusedaemon.c b/client/gvfsfusedaemon.c
index 47f4e4c6..e2038504 100644
--- a/client/gvfsfusedaemon.c
+++ b/client/gvfsfusedaemon.c
@@ -1363,6 +1363,14 @@ vfs_read (const gchar *path, gchar *buf, size_t size,
           if (result == 0)
             {
               result = read_stream (fh, buf, size, offset);
+
+              if (result == -ENOTSUP && offset < fh->pos)
+                {
+                  file_handle_close_stream (fh);
+                  result = setup_input_stream (file, fh);
+                  if (result == 0)
+                    result = read_stream (fh, buf, size, offset);
+                }
             }
           else
             {


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