fuse_readdir() fails to set the eofflag correctly. The consequence of
this is, that callers of VOP_READDIR, that examine the value of the
eofflag after the call, might be mislead about the eof status, as the
flag hasn't been modified (and my even be uninitialized).

The manual page for VOP_READDIR() mentions, that the eofflag is set to a
non-zero value when the eof of the directory contents has (successfully)
been reached, but in the following diff I chose to also in addition set
the flag to 0 when eof has not been reached for uniformity with other
filesystem implementations.

Index: miscfs/fuse/fuse_vnops.c
===================================================================
RCS file: /cvs/src/sys/miscfs/fuse/fuse_vnops.c,v
retrieving revision 1.22
diff -u -r1.22 fuse_vnops.c
--- miscfs/fuse/fuse_vnops.c    10 Feb 2015 21:56:10 -0000      1.22
+++ miscfs/fuse/fuse_vnops.c    12 Feb 2015 20:48:06 -0000
@@ -686,7 +686,7 @@
        struct vnode *vp;
        struct proc *p;
        struct uio *uio;
-       int error = 0;
+       int error = 0, eofflag = 0;
 
        vp = ap->a_vp;
        uio = ap->a_uio;
@@ -720,8 +720,9 @@
                        break;
                }
 
-               /*ack end of readdir */
+               /* ack end of readdir */
                if (fbuf->fb_len == 0) {
+                       eofflag = 1;
                        fb_delete(fbuf);
                        break;
                }
@@ -733,6 +734,9 @@
 
                fb_delete(fbuf);
        }
+
+       if (!error && ap->a_eofflag != NULL)
+               *ap->a_eofflag = eofflag;
 
        return (error);
 }

cheers,
natano

Reply via email to