2017-06-07 12:41:52 +0200, Joerg Schilling: > Stephane Chazelas <stephane.chaze...@gmail.com> wrote: > > > Do you have an opinion on whether POSIX should allow the > > expansion of globs not to include "." and ".." by default? > > The fact that some filesystems include "." and ".." in the readdir() > output does not make these entries required by POSIX. > > In 1990, my "WOFS" did already make a directory a special zero byte sized file > with link count "1" and readdir() does not return "." or ".." with WOFS. > > The ZFS people decided to fake "." and "..", but this is not required. [...]
Yes, it's hard to tell what behaviour one can rely on with the current text. Is opendir(".") required to open the current directory even if there's no "." entry in the current directory (same for "..")? Is foo/./bar required to be the same as foo/bar? The readdir() spec seems to say that an entry for *both* "." and ".." should be returned if *either* "." or ".." is present in the directory, while "ls -a" should /only/ return the entries present in the directory (with no reference to readdir()). Is that to say that "ls" can't be implemented using "readdir()" (because if a directory contained "." and not "..", that would mean it would print ".." as readdir() would be returning it)? On Linux at least if you remove your current working directory, opendir(".") and stat(".") still work but readdir() returns an empty list. -- Stephane