First, revert the handling of virtual drives as non-symlinks. This is no longer necessary. The new GetFinalPathNameW handling for native symlinks in inner path components is disabled if caller doesn't want to follow symlinks, or doesn't want to follow reparse points. Set flag to not follow reparse points in chdir, allowing native processes to see their cwd potentially including native symlinks, rather than dereferencing them. --- For v2, I realized the PC_SYM_NOFOLLOW_REP flag was supposed to do this, and that lack of PC_SYM_FOLLOW was not being respected either. With this, and patching `pwd -P` to `pwd` in makepkg, the long-named package builds successfully. I did not re-indent the code for the addition of the if due to having learned from my patch to rebase, but it looks kind of ugly. winsup/cygwin/path.cc | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index e62f8fe2b..2ce5aef81 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -722,9 +722,9 @@ path_conv::check (const char *src, unsigned opt, int symlen = 0; /* Make sure to check certain flags on last component only. */ - for (unsigned pc_flags = opt & (PC_NO_ACCESS_CHECK | PC_KEEP_HANDLE); + for (unsigned pc_flags = opt & (PC_NO_ACCESS_CHECK | PC_KEEP_HANDLE | PC_SYM_FOLLOW | PC_SYM_NOFOLLOW_REP); ; - pc_flags = 0) + pc_flags = opt & (PC_SYM_FOLLOW | PC_SYM_NOFOLLOW_REP)) { const suffix_info *suff; char *full_path; @@ -3452,6 +3452,8 @@ restart: break; } + if ((pc_flags & (PC_SYM_FOLLOW | PC_SYM_NOFOLLOW_REP)) == PC_SYM_FOLLOW) + { /* Check if the inner path components contain native symlinks or junctions, or if the drive is a virtual drive. Compare incoming path with path returned by GetFinalPathNameByHandleA. If they @@ -3522,6 +3524,7 @@ restart: } } } + } /* Normal file. */ file_not_symlink: @@ -3704,7 +3707,7 @@ chdir (const char *in_dir) /* Convert path. PC_NONULLEMPTY ensures that we don't check for NULL/empty/invalid again. */ - path_conv path (in_dir, PC_SYM_FOLLOW | PC_POSIX | PC_NONULLEMPTY); + path_conv path (in_dir, PC_SYM_FOLLOW | PC_POSIX | PC_NONULLEMPTY | PC_SYM_NOFOLLOW_REP); if (path.error) { set_errno (path.error); -- 2.31.1.windows.1