Find -maxdepth

Robert Dahlem Robert.Dahlem at
Thu Dec 14 17:31:21 GMT 2000


On Thu, 14 Dec 2000 12:56:13 +0000, The DJ wrote:

>I'm working on a port of Samba to macos X.
>As far as I can tell, most is working except one thing.
>When you upload a directory to another server with smbclient, 
>smbclient calls find -maxdepth to look at the dir you want to upload.
>The OSX version of find (which is basicly the FreeBSD version) does 
>not know the -maxdepth option and therefore I cannot upload 
>Can I edit the source, so that it doesn't need the -maxdepth option?
>What would I change to let it work with BSD like systems?

Calling find from a program is bad practice in my eyes, especially 
when using options not available on all systems. Looks a little like a 
Q&D hack. :-)

There is a library function ftw() ("file tree walk") doing the inner 
part of what find does. I think the best way would be to rewrite 
client/client.c:cmd_mput() to use ftw() for recursive and getdents() 
for non-recursive runs. Note that this may be a bad choice if ftw() is 
not available on all systems ... this could be detected by configure 
and handled with

#ifdef HAVE_FTW
  sprintf(cmd, "find ...", ...);

Expect your own pizza voucher if you recode the stuff and push it back 
to the team. :-)


Robert.Dahlem at           Fax +49-69-432647

Sent using PMMail ( - fast, decent, email
software; far better than Outlook. Try it sometime.

More information about the samba-technical mailing list