Subject: bug#13447: ln "" foo gives misleading error message

From: Bernhard Voelker <[email-masked]>
Date: Tue, 15 Jan 2013 10:55:00 +0100

On 01/15/2013 10:44 AM, Bob Proulx wrote:
> Jim Meyering wrote:
>> Pádraig Brady wrote:
>>> Interestingly I notice that solaris for example allows a NULL old_path.
>>
>> That Solaris behavior is contrary to POSIX 2008
>> http://pubs.opengroup.org/onlinepubs/9699919799/functions/symlink.html
> 
> Where does it say this?  I read it through in detail but I didn't see
> that it required a diagnostic to be emitted in the case that value is
> am empty string.  What did I miss?

Right, the only 3 statements about path1 are:

 * The string pointed to by path1 shall be treated only as a
   character string and shall not be validated as a pathname.

 * [ENAMETOOLONG]
   [...] or the length of the path1 argument is longer than {SYMLINK_MAX}.

 * [...] in fact, the file named by the path1 argument need not exist
   when the link is created.

I'd read this as:
a) there can be any character in the string but a NULL (obviously).
b) the maximum length is limited to SYMLINK_MAX.
Nothing more.

BUT:
Some CU tools already catch zero-length file names (du and wc),
and a comment in the code states that FTS has problems with it
[src/du.c:1043]:

     /* Report and skip any empty file names before invoking fts.
         This works around a glitch in fts, which fails immediately
         (without looking at the other file names) when given an empty
         file name.  */

Have a nice day,
Berny