Subject: Re: lib/222: stat(2) returns 0 for path=""
To: None <netbsd-bugs@sun-lamp.cs.berkeley.edu>
From: Dan Riley <dsr@lns598.lns.cornell.edu>
List: netbsd-bugs
Date: 04/12/1994 12:34:32
Jarle.F.Greipsland@idt.unit.no writes:
>>> The behavior you described is correct.  The null string is considered
>>> the same as `.', and thus `stat("", ...)' is the same as `stat(".",
>>> ...)'.  This is not a bug.
>
>ULTRIX lise8 4.2 0 RISC
>stat "" returned 0

From the Ultrix man page:

     [ENOENT]       The named file does not exist or path points to an empty
                    string and the environment defined is POSIX or
                    SYSTEM_FIVE.

which should tell us something...

>As the BSD derived systems seem to exhibit this, a bit counter-intuitive,
>behaviour, maybe we should declare it "a good thing"?  As long as
>the behaviour is documented I have no problems with either behaviour.
>Maybe your acquaintance, Ms. POSIX, has? :-)

ISO/IEC 9945-1: 1990 (aka IEEE Std 1003.1, 1990-12-07), sec. 5.6.2.4
sez:

  If any of the following conditions occur, the stat() function call
  shall return -1 and set errno to the corresponding value

[...]
	[ENOENT]  The named file does not exist, or the path argument
		  points to an empty string.

where an "empty string" is "a character array whose first element is a
null character".  The use of "shall" seems to indicate that POSIX.1
requires that stat("", ...) be an error.
--
Dan Riley                          Internet:  dsr@lns598.lns.cornell.edu
Wilson Lab, Cornell University     HEPNET/SPAN: lns598::dsr (44630::dsr)
	 "Maybe, leastways is the best way of all" -Caterwaul

------------------------------------------------------------------------------