]> sourceware.org Git - newlib-cygwin.git/commit
Cygwin: path_conv: Rework handling native symlinks as inner path components
authorCorinna Vinschen <corinna@vinschen.de>
Fri, 7 May 2021 14:07:03 +0000 (16:07 +0200)
committerCorinna Vinschen <corinna@vinschen.de>
Fri, 7 May 2021 20:52:16 +0000 (22:52 +0200)
commit19d59ce75d5301ae167b421111d77615eb307aa7
tree443d093a672f7e2ef9e3c8e6118d43cea3c77701
parent9ea0f3766744082836a154981dc8f099192614f9
Cygwin: path_conv: Rework handling native symlinks as inner path components

commit 456c3a46386f was only going half-way.  It handled symlinks and
junction points as inner path components and made realpath return the
correct path, but it ignored drive letter substitution, i. e., virtual
drives created with, e. g.

  subst X: C:\foo\bar

It was also too simple.  Just returning an error code from
symlink_info::check puts an unnecessary onus on the symlink evaluation
loop in path_conv::check.

Rework the code to use GetFinalPathNameByHandle, and only do this after
checking the current file for being a symlink failed.

If the final path returned by GetFinalPathNameByHandle is not the same
as the incoming path, replace the incoming path with the POSIXified
final path.  This also short-circuits path evaluation, because
path_conv::check doesn't have to recurse over the inner path components
multiple times if all symlinks are of a native type, while still getting
the final path as end result.

Virtual drives are now handled like symlinks.  This is a necessary change
from before to make sure virtual drives are handled identically across
different access methods.  An example is realpath(1) from coreutils.  It
doesn't call readlink(2), but iterates over all path components using
lstat/readlink calls.  Both methods should result in the same real path.

Fixes: 456c3a46386f ("path_conv: Try to handle native symlinks more sanely")
Signed-off-by: Corinna Vinschen <corinna@vinschen.de>
winsup/cygwin/path.cc
This page took 0.03116 seconds and 5 git commands to generate.