[Samba] smbd reads entire directory when creating files?

Matt Mitchell mmitchell at virtualproperties.com
Thu Dec 9 16:17:18 GMT 2004

Jeremy Allison wrote:
> On Wed, Dec 08, 2004 at 01:37:23PM -0600, Matt Mitchell wrote:
>>Obviously such a special case would make the code ugly...but I might try 
>>patching it just for my own testing to see if it makes any difference. 
>>Any pointers you can offer?
> That's exactly the case I was intending to add :-). I'm have to work
> on the malloc issue at the moment - you seem to have quickly identified
> the neccessary optimization without my help :-) - well done !

Don't give me too much credit just yet :-)

So it appears that unix_convert behaves reasonably well if 
conn->case_sensitive is true (and mangling is not in effect, which I 
would guess is true in probably 95% of cases today).  There is already 
an escape in there which is triggered if the user is not so dumb as to 
assume that he is using the share he thinks he is (with case sensitive = 
yes) as opposed to one without.  filename.c:186 in my sources.

That takes care of one readdir.  The other is happening as a result of 
either xcopy or Windows checking to see if the file exists before 
copying it.  i.e. it's doing a call_trans2findfirst, which calls OpenDir 
eventually, reading in the whole directory before deciding that the file 
isn't already there.  This one is more subtle, and I don't know enough 
about the SMB semantics to really know what a valid approach would be. 
The same logic for optimization would seem to apply whenever 
conn->case_sensitive is in effect and we are not asked for a wildcard 
string, but I have no idea about implications for other areas of the 
protocol that might depend on that dirptr actually being populated.

As I have time today I will keep digging.

Any insight appreciated.  Should this be moved to samba-technical?


More information about the samba mailing list