Currently, opening a symlink with O_NOFOLLOW fails with ELOOP. Following Linux, the first patch in this series allows the call to succeed if O_PATH is also specified.
According to the Linux man page for 'open', the file descriptor returned by the call should be usable as the dirfd argument in calls to fstatat and readlinkat with an empty pathname, to have the calls operate on the symbolic link. The second and third patches achieve this. For fstatat, we do this by adding support for the AT_EMPTY_PATH flag. Note: The man page mentions fchownat and linkat also. linkat already supports the AT_EMPTY_PATH flag, so nothing needs to be done. But I don't understand how this could work for fchownat, because fchown fails with EBADF if its fd argument was opened with O_PATH. So I haven't touched fchownat. Am I missing something? Ken Brown (3): Cygwin: allow opening a symlink with O_PATH | O_NOFOLLOW Cygwin: readlinkat: allow pathname to be empty Cygwin: fstatat: support the AT_EMPTY_PATH flag winsup/cygwin/syscalls.cc | 40 +++++++++++++++++++++++++++++++++------ 1 file changed, 34 insertions(+), 6 deletions(-) -- 2.21.0