[Samba] How to do a simple directory listing

Jeremy Allison jra at samba.org
Mon Aug 25 20:33:59 GMT 2008


On Mon, Aug 25, 2008 at 07:47:10AM -0400, Jeremy M wrote:
> 
> I'm working on an embedded system that will communicate with a Samba server, and I'm wondering if there's a way to do a simple directory listing.  I used Wireshark to see what my Win2K computer does, and I see it's using FIND_FIRST2.  This is fine, probably acceptable, but Samba returns a lot of information I do not need, such as file creation/access times.  I just need filenames, and will only be reading from Samba.  It ends up being more data to store in limited RAM and parse.  

Chose the right info level to ask for. To get just the name ask for
SMB_FIND_FILE_NAMES_INFO (0x103).

> Can NT_CREATE_ANDX be used to obtain a directory listing?  The CIFS Technical Reference states "This command is used to create or open a file or directory".  I thought I could specify a directory then use READ_ANDX, but I'm not surprised that didn't do what I had hoped.  

No, for the same reason you can't do this (open() then read() on a UNIX
directory).

Jeremy.


More information about the samba mailing list