> Date: Wed, 18 Mar 2015 17:27:23 -0600 > From: Eric Blake <ebl...@redhat.com> > CC: bug-gnulib@gnu.org > > I think POSIX 2001 allowed that, but with the openat() and friends added > in POSIX 2008, I think that POSIX now prohibits this implementation, and > requires that dirfd work rather than giving up with ENOTSUP. At any > rate, gnulib should try and strive for returning a non-negative value, > even if POSIX has a loophole that would allow -1.
In any case, the bug that triggered this thread clearly shows that dirfd should not fail, if it is part of the solution, because the file descriptor with which the directory was open must remain open after fdopendir returns. It clearly is what Grep assumes.