mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Stephane Chazelas <stephane.chazelas@gmail.com>
To: musl@lists.openwall.com
Subject: Re: Re: [PATCH] In glob(), do not require that the target of a symlink exists.
Date: Wed, 31 Jul 2019 21:35:54 +0100	[thread overview]
Message-ID: <20190731203554.4qivqivkx63xbckt@chaz.gmail.com> (raw)
In-Reply-To: <20190730161336.GA1506@brightrain.aerifal.cx>

2019-07-30 12:13:36 -0400, Rich Felker:
> On Tue, Jul 30, 2019 at 12:04:57PM -0400, James Y Knight wrote:
[...]
> > > Now, be consistent and allow broken symlinks in both cases, by using
> > > lstat to determine file existence.
[...]

Hello,

Note that there's a related discussion on the POSIX mailing list
where that unusual behaviour of musl libc (of using stat()
instead of lstat()) was noted:

https://www.mail-archive.com/austin-group-l@opengroup.org/msg04585.html

The discussion itself was about what is reported with GLOB_ERR
or when an errfunc is passed where the current POSIX spec is
unclear and implementations differ. The austin-group bug is
http://austingroupbugs.net/view.php?id=1273 where I argue
implementations shouldn't report ENOTDIR errors at least even
with GLOB_ERR.

musl is quite unique in that it does report the errors of
stat() in addition to those of opendir(). While POSIX currently
kind of implies it shouldn't, it seems to me it would make for a
more useful interface. That is still being discussed there.

musl's glob will still report errors for system calls failing
with ENOTDIR if it encounters them. At the moment, in globs like
*/*.c, and on systems and file systems where readdir() returns
the type of entries, it will generally not report ENOTDIR errors
because it wouldn't call opendir() on non-directory files in the
first place. But it would on systems where readdir() doesn't
return the type of entries or if there's a symlink to a
non-directory file in the current directory, which makes for a
not very consistent interface.

IMO, it should also ignore ENOTDIR errors (for both opendir()
and lstat()) as a backup even if that means that no error would
be reported for things like /etc/passwd/*

Most implementations ignore ENOTDIR errors, even dietlibc that
even tries harder than musl to avoid calling opendir() on
non-directory files.

-- 
Stephane


  reply	other threads:[~2019-07-31 20:35 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-07-23  0:37 James Y Knight
2019-07-30 16:04 ` James Y Knight
2019-07-30 16:13   ` Rich Felker
2019-07-31 20:35     ` Stephane Chazelas [this message]
2019-08-06  2:03 ` Rich Felker

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190731203554.4qivqivkx63xbckt@chaz.gmail.com \
    --to=stephane.chazelas@gmail.com \
    --cc=musl@lists.openwall.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).