Subject: Re: [truist@truist.com: [Fwd: RE: rsync: readdir(.): Bad file descriptor (9)]]
To: Ignatios Souvatzis <ignatios@cs.uni-bonn.de>
From: Martin Husemann <martin@duskware.de>
List: tech-kern
Date: 08/28/2006 15:52:58
On Mon, Aug 28, 2006 at 01:45:41PM +0200, Ignatios Souvatzis wrote:
> This needs to be discussed here. Who's our smbfs guru?

The response as seen from the server in this case (0 directory entries
returned, EndOfSearch not set and no error code) is not explained in the
SMB specification. The change does just treat "0 entries returned" exactly
as "end of search". I would, stylistically, do it this way:

Index: smbfs_smb.c
===================================================================
RCS file: /cvsroot/src/sys/fs/smbfs/smbfs_smb.c,v
retrieving revision 1.30
diff -u -p -r1.30 smbfs_smb.c
--- smbfs_smb.c	7 Jun 2006 22:33:38 -0000	1.30
+++ smbfs_smb.c	28 Aug 2006 13:50:28 -0000
@@ -1048,7 +1048,7 @@ smbfs_smb_trans2find2(struct smbfs_fctx 
 	ctx->f_ecnt = tw;
 	if ((error = md_get_uint16le(mdp, &tw)) != 0)
 		return error;
-	if (tw)
+	if (tw != 0 || ctx->f_ecnt == 0)
 		ctx->f_flags |= SMBFS_RDD_EOF | SMBFS_RDD_NOCLOSE;
 	if ((error = md_get_uint16le(mdp, &tw)) != 0)
 		return error;

(which, as far as I can tell, should be semantically equivalent to the FreeBSD
patch).

Other opinions?

Martin