Re: fusefs_readdir() should set eofflag

2015-02-19 Thread Martin Natano
  @@ -733,6 +734,9 @@
   
  fb_delete(fbuf);
  }
  +
  +   if (!error  ap-a_eofflag != NULL)
  +   *ap-a_eofflag = eofflag;
 
 Is the null check here necessary? Other file systems don't do this, so I'm
 wondering if you encountered a null pointer here.
I didn't encounter a null pointer and none of the callers pass NULL as a
eofflag here, so I guess I included the check out of sheer paranoia. ;)

cheers,
natano



Re: fusefs_readdir() should set eofflag

2015-02-19 Thread Ted Unangst
Martin Natano wrote:
 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.

Thanks, fixed.

 @@ -733,6 +734,9 @@
  
   fb_delete(fbuf);
   }
 +
 + if (!error  ap-a_eofflag != NULL)
 + *ap-a_eofflag = eofflag;

Is the null check here necessary? Other file systems don't do this, so I'm
wondering if you encountered a null pointer here.



fusefs_readdir() should set eofflag

2015-02-18 Thread Martin Natano
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.c10 Feb 2015 21:56:10 -  1.22
+++ miscfs/fuse/fuse_vnops.c12 Feb 2015 20:48:06 -
@@ -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