Make passthrough_fh work under FreeBSD.
authorNikolaus Rath <Nikolaus@rath.org>
Tue, 22 Aug 2017 11:46:14 +0000 (13:46 +0200)
committerNikolaus Rath <Nikolaus@rath.org>
Tue, 22 Aug 2017 12:00:44 +0000 (14:00 +0200)
ChangeLog.rst
example/passthrough_fh.c

index a724709b6de4c4069fb48071ca7f9923b422a952..396b2d6909ab5739c53e0fb636b1b7885cddfa79 100644 (file)
@@ -4,6 +4,8 @@ Unreleased Changes
 * Documented the special meaning of the *zero* offset for the
   fuse_fill_dir_t function.
   
+* The `passthrough_fh` example now works under FreeBSD.
+  
 * libfuse can now be build without libiconv.
 
 * Fixed support for `FUSE_CAP_POSIX_ACL`: setting this capability
index 909422ab9e2cb6fa7ae9a5333210d5decb3d76c7..2b1ed1c492ba04454778ab3484d9d5be6015136a 100644 (file)
@@ -151,7 +151,13 @@ static int xmp_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
 
        (void) path;
        if (offset != d->offset) {
+#ifndef __FreeBSD__
                seekdir(d->dp, offset);
+#else
+               /* Subtract the one that we add when calling
+                  telldir() below */
+               seekdir(d->dp, offset-1);
+#endif
                d->entry = NULL;
                d->offset = offset;
        }
@@ -181,6 +187,13 @@ static int xmp_readdir(const char *path, void *buf, fuse_fill_dir_t filler,
                        st.st_mode = d->entry->d_type << 12;
                }
                nextoff = telldir(d->dp);
+#ifdef __FreeBSD__             
+               /* Under FreeBSD, telldir() may return 0 the first time
+                  it is called. But for libfuse, an offset of zero
+                  means that offsets are not supported, so we shift
+                  everything by one. */
+               nextoff++;
+#endif
                if (filler(buf, d->entry->d_name, &st, nextoff, fill_flags))
                        break;