[v2: changed malloc failure from ignore to error; added support for
alloca; tested by copying to glibc and testing there]
The DT_* values returned by getdents (readdir) are only hints and
not required. In fact, some Linux filesystems return DT_UNKNOWN
for most entries, regardless of actual type
Thanks for looking into this; it's long been on my plate but I haven't
had time to work on the proper solution, which is basically to rewrite
glob from scratch (this should make it considerably faster).
As far as your patch goes:
Gnulib prefers spaces to tabs.
The code unnecessarily calls str
Paul Eggert writes:
> I don't see how the patch fixes the case where readdir_result_type (d)
> returns DT_LNK; this might be a symlink to a directory.
It was not part of the problem I was trying to solve. A DT_LNK was
already a known file type, and handled, so I left it alone.
> Proposed pair
On 3/22/22 21:34, DJ Delorie wrote:
Of course performance will suffer with all these correctness patches,
but that can wait until a rewrite.
Modern XFS and EXT filesystems should not hit these code paths at all,
except for symbolic links, and even then only with GLOB_ONLYDIR.
Right, though g
Paul Eggert writes:
>>> +# define dirfd(str) __dirfd (str)
>>
>> This needs an #undef before it, else it causes build errors as glibc
>> already has a definition for dirfd() and it conflicts with this one.
>> Prudence says they should *all* be protected as such, but I only mention
>> the new one.
Paul Eggert wrote on 2022-03-23:
> The 3rd patch tests for glibc bug 25659 ...
This patch produces a warning
../../gltests/test-glob.c: In function 'main':
../../gltests/test-glob.c:77:17: warning: implicit declaration of function
'creat' [-Wimplicit-function-declaration]
77 | && close