Since POSIX was mentioned, "" is not a valid filename[1]. So
it isn't the case of a file does not exist (ENOENT), it is a case
of an invalid filename (EINVAL?).
--patrick
[1]
pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap03.html#tag_03_170
--- 8< -------------------------------------------------------------------------
3.170 Filename
A sequence of bytes consisting of 1 to {NAME_MAX} bytes used to name a
file. The bytes composing the name shall not contain the <NUL> or
<slash> characters. In the context of a pathname, each filename shall
be followed by a <slash> or a <NUL> character; elsewhere, a filename
followed by a <NUL> character forms a string (but not necessarily a
character string). The filenames dot and dot-dot have special meaning.
A filename is sometimes referred to as a "pathname component". See
also Pathname.
Note:
Pathname Resolution is defined in detail in Pathname Resolution .
------------------------------------------------------------------------- >8 ---
On 6/28/16, Philip Guenther <[email protected]> wrote:
> On Tue, 28 Jun 2016, Todd C. Miller wrote:
>> I think this needs to be fixed in fts(3) instead. The following diff
>> fixes it for me but has only been lightly tested.
>
> As I noted in icb, first chunk looks sufficient to me; the latter chunk is
> just optimizing the error case, as fstatat() will already fail the ""
> case.
>
> I think we should also include this check from FreeBSD:
>
> --- gen/fts.c 16 Jan 2015 16:48:51 -0000
> +++ gen/fts.c 5 Feb 2015 05:01:08 -0000
> @@ -83,6 +83,12 @@ fts_open(char * const *argv, int options
> return (NULL);
> }
>
> + /* fts_open() requires at least one path */
> + if (*argv == NULL) {
> + errno = EINVAL;
> + return (NULL);
> + }
> +
> /* Allocate/initialize the stream */
> if ((sp = calloc(1, sizeof(FTS))) == NULL)
> return (NULL);
>
>