Subject: [ [Fwd: RE: rsync: readdir(.): Bad file descriptor (9)]]
To: None <>
From: Ignatios Souvatzis <>
List: tech-kern
Date: 08/28/2006 13:45:41
This needs to be discussed here. Who's our smbfs guru?

(I applied the fix to current, and it compiles. But
 I have no windows server around to test.)

----- Forwarded message from Nathan Arthur <> -----

Date: Mon, 28 Aug 2006 00:36:24 -0400
From: Nathan Arthur <>
Subject: [Fwd: RE: rsync: readdir(.): Bad file descriptor (9)]

I'm using rsnapshot (from pkgsrc) to do rsync backups (to a netbsd 
machine) of files on a Windows XP box, mounted on the netbsd machine via 
smbfs.  When I first started doing this, I kept getting "Bad file 
descriptor" errors for certain directories, and eventually tracked down 
I contacted the person who posted that message (as shown below) and they 
replied with a patch to smbfs_smb.c that fixes the problem, and a link 
to: which 
describes the problem (and the fix) in detail. 

I've applied the patch to my machine and it fixes my problem.  My 
question is: how do I get this patch integrated into NetBSD? 



-------- Original Message --------
Subject: 	RE: rsync: readdir(.): Bad file descriptor (9)
Date: 	Fri, 11 Aug 2006 09:25:57 -0400
From: 	Jim Carroll <>
Organization: 	Carroll-Net, Inc.
To: 	'Nathan Arthur' <>

Hi Nathan,

Yes, I was able to finally trace the problem down and posted a path (plus
full description of the problem) to the FreeBSD PR system

Bottom line, apply this patch against smbfs_smb.c

--- smbfs_smb.c	Wed Jan 28 01:21:01 2004
+++ smbfs_smb.c.fix	Tue Nov 15 07:05:56 2005
@@ -1224,8 +1224,10 @@ smbfs_smb_trans2find2(struct smbfs_fctx 
 		return error;
 	if ((error = md_get_uint16le(mdp, &tw)) != 0)
 		return error;
-	if (ctx->f_ecnt == 0)
+	if (ctx->f_ecnt == 0) {
+		ctx->f_flags |= SMBFS_RDD_EOF | SMBFS_RDD_NOCLOSE;
 		return ENOENT;
+		}
 	ctx->f_rnameofs = tw;
 	mdp = &t2p->t2_rdata;
 	if (mdp->md_top == NULL) {

I hope this helps.

Jim C.          | Carroll-Net, Inc.
201-488-4092    | | Application Service Provider
>-----Original Message-----
>From: Nathan Arthur []
>Sent: Friday, August 11, 2006 2:49 AM
>Subject: rsync: readdir(.): Bad file descriptor (9)
>I ran into the email thread archived at
>and I seem to be having the same problem you described/debugged, on
>NetBSD 3.0.0.  (I'm not sure how to tell which version of smbfs I
>have.)  Did you ever find a good resolution to your problem?  Is there
>any chance that smbfs is being fixed?

----- End forwarded message -----