Stephane Chazelas <[email protected]> wrote, on 29 Jul 2019: > > 2019-07-29 12:12:28 +0100, Geoff Clare: > [...] > > > in */*.c, Solaris returns with an error if the current directory > > > contains a non-directory file (and calls errfunc() with ENOTDIR > > > and that file), which is not wanted. > > > > True, but there's no way round that because GLOB_ERR can't distinguish > > these cases. It's "all or nothing". > > > > > IMO, GLOB_ERR should be about failure to expand the glob. > > > The ENOTDIR error when expanding /etc/passwd/*.c is not > > > preventing the glob from expanding (to nothing). If passwd was a > > > symlink to some inaccessible area, then it would. > > > > To me the point of having GLOB_ERR and errfunc as two different > > error reporting mechanisms is that GLOB_ERR is "all or nothing" > > and errfunc lets you be more selective. You said yourself in the bug > > that the Solaris behaviour is "more flexible in that the caller can > > use a errfunc that ignores ENOENT/ENOTDIR to emulate the GNU/FreeBSD > > behaviour". > [...] > > Yes, but to me that sounds more like the Solaris behaviour is > bogus and there's a way to work around it. > > From https://reviews.freebsd.org/rS304284 > https://reviews.freebsd.org/rS304284#C38376190OL661 > FreeBSD implementated that ignoring of ENOENT/ENOTDIR for POSIX > compliance in 2016. > > For the ENOTDIR ignoring in GNU libc, that was in 1999 following > a bug report (libc/1032 which I coudn't find). See > https://sourceware.org/git/?p=glibc.git;a=commit;h=647361287ddb2d52ffe9dbbfe2bd27ed76dc2c56 > > NetBSD has this comment in the code: > > /* > * Posix/XOpen: glob should return when it encounters a > * directory that it cannot open or read > * XXX: Should we ignore ENOTDIR and ENOENT though? > * I think that Posix had in mind EPERM... > */ > > (ITTM EACCESS).
The odd thing about all these implementations that ignore ENOTDIR and ENOENT (or don't but think they should), is that they are not following either of the possible interpretations of the current text. If they want to interpret it literally and only report an error when they encounter an existing directory that they can't open, then they should not just ignore ENOTDIR and ENOENT from opendir(), they should also ignore ELOOP and ENAMETOOLONG. -- Geoff Clare <[email protected]> The Open Group, Apex Plaza, Forbury Road, Reading, RG1 1AX, England
