Edgar Fuß
unread,Aug 4, 2016, 3:14:18 PM8/4/16You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to
What's the point of glob(3), when called with GLOB_ERR, to fail with ENOTDIR
in case it stumbles over an entry that's not a directory? E.g., glob(3)'ing
/etc/*/network will try /etc/passwd/network and fail. I would expect
/etc/passwd/net* to fail, but not /etc/*/network.
It looks like glibc behaves more than I would have expected, so there may be
many programs out there (I hit this when porting Icinga2) that expect a
different behaviour.
Of course, it's relatively easy to circumvent the problem by passing an
error handler to glob() that ignores ENOTDIR.
While NetBSD's behaviour is explicitly documented in glob(3), POSIX says
``If, during the search, a directory is encountered that cannot be opened or
read''. /etc/passwd is not a directory, so there's no directory encountered
that cannot be opened or read.
Also, NetBSD's implentations looks highly inefficient to me. If you ktrace
the glob(3)'ing of /etc/*/network you see lstat()'s on /etc/foo/network for
every regular file /etc/foo, which strikes me as nonsense.
But perhaps there's some point in the behaviour I don't see.