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

Sven Barth pascaldragon at googlemail.com
Fri Mar 1 12:52:16 CET 2013


On 01.03.2013 12:31, Marco van de Voort wrote:
> In our previous episode, Ludo Brands said:
>>>
>>> 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.
>>
>
> Maybe even wrong. I checked the FreeBSD implementation for the buffersize
> (1kb btw), and there is the following comment (probably based on some
> comment from FreeBSD sources):
>
> "Getdents requires the buffer to be larger than the blocksize.
> This usually the sectorsize =512 bytes, but maybe tapedrives and harddisks
> with blockmode have this higher?"
>
> Maybe Linux has a similar requirement.

It seems that at least in 2001 there was an entry in the man page about 
this, but in current man pages about getdents(64) there is nothing about 
it. Maybe we should check whether the following would work (in 
rtl/linux/ossysc.inc, fpreaddir):

Currently FPC allocates only one pdirent in fpopendir 
(rtl/linux/ossysc.inc). Maybe it should first stat the directory and 
then decide based on st_blksize how much pdirent entries to allocate 
(but it should also provide a sane default, as there is the possiblity 
that st_blksize is 0 for a directory).

Regards,
Sven



More information about the fpc-pascal mailing list