2019-07-30 14:29:23 +0100, Geoff Clare:
[...]
> > Do you have a better suggestion?
> 
> Unless one of the implementations changes to do something better
> before we get too far into work on Issue 8, I think the only
> choices we have are the Solaris behaviour, the GNU/BSD behaviour,
> the GNU/BSD "done right" (ELOOP/ENAMETOOLONG/ENOENT/ENOTDIR all
> treated the same), or allow some or all of these behaviours.
[...]

Great, thanks. I think we concur. My vote, as already stated
would be:

- ENOTDIR errors upon opendir() shall be ignored
- ENOENT/ENAMETOOLONG/ELOOP may be ignored.

That is Solaris (and other old BSDs and newer musl) not allowed
as */*.c returning a ENOTDIR error is definitely a bug IMO,
GNU/FreeBSD allowed.

Do we want to allow lstat() errors (other than ENOENT/ENOTDIR)
to be reported (I changed my mind on that and now think it would
not be that confusing).

I've now tested musl 1.1.21 and diet 0.34 on Linux which are
actually quite different from the GNU/Solaris/FreeBSD mentioned
above.

For musl, first, it seems that in */*.c, it actually uses the
entry-type information returns by readdir() and doesn't call
opendir() on entries that are neither directory nor symlink.

It still returns an error upon ENOTDIR if there are symlinks to
regular files in the current directory or if called with
regfile/*.c

It calls stat() instead of lstat() for the */file glob (again,
skipping the non-dir-non-symlink files), (so would not expand a
dir/file broken symlink) and reports the stat() errors other
than ENOENT (including ENOTDIR in */file when the current
directory contains a symlink to a regular file).

dietlibc seems to behave quite differently as well. In */*.c, it
does a stat() on each file in the current directory to determine
which are directories (and if there's no matching one calls
opendir("*") mostly likely causing a ENOENT error), so won't
report ENOTDIR errors there (except in race condition cases). In
*/file, it doesn't use stat/lstat but reads the content of the
directories looking for a "file" entry (so fails on unreadable
dirs instead of unsearchable ones). In any case, it ignores the
ENOTDIR errors on opendir(), even in the regfile/*.c case.

-- 
Stephane

Reply via email to