[fpc-pascal] Findfirst/findnext with a samba share

Ludo Brands ludo.brands at free.fr
Fri Mar 1 09:32:18 CET 2013


On 03/01/2013 09:14 AM, Max Vlasov wrote:
> Hi,
> 
> Working with lazarus on Linux Mint I noticed that when I mount a windows
> shared with "Connect to server", everything works fine (Nautilus,
> Midnight Commander, Lazarus file operations). But meeting that .gvfs
> folder is hidden, I tried to mount "mount -t cifs" directly  in the shell.
> 
> After such mapping Nautilus and mc worked the same, but Lazarus stopped
> seeing some of files (for example 3 from the folder containing 76).
> 
> I tried to run lazarus in the debugger and narrowed it to findFirst/Next
> that calls fpReadDir and this one calls linux' getdents64 to list
> directoty entries (since it's fpc rtl, I'm posting here). Querying for
> mentioning this at the web, I found that there were reports in the
> bugtracker that attributed this to a samba bug
> (https://bugzilla.samba.org/show_bug.cgi?id=8044 ).
> 
> The question is what is different in nautilus and midnight commander
> comparing to fpc directoy-listing functions that allows them to list
> directories correctly in the bug's case?
> 

The difference with other tools is that FPC gives a very small buffer to
getdents64. The strace for ls in the bug report
http://bugs.freepascal.org/view.php?id=23732 shows that only one
getdents is needed to get the full dir because the buffer size is much
bigger.
I don't know why getdents64 gets a buffer of only 280 bytes from FPC.
This seems to me ridiculously low in modern systems and it has also an
impact on the speed of findFirst/findNext.

Ludo




More information about the fpc-pascal mailing list