]> Cypherpunks repositories - gostls13.git/commit
os: make Readlink work with symlinks with target like \??\Volume{ABCD}\
authorAlex Brainman <alex.brainman@gmail.com>
Thu, 28 Feb 2019 09:21:32 +0000 (20:21 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Fri, 1 Mar 2019 07:44:37 +0000 (07:44 +0000)
commit2edd559223f3b3fd54e354c9a9703248a935c91a
treee7c1dcccd4faebbc6fb6a358a793176ebc26858d
parente27402aee03b9232b7042ca6cba8b42b15727ef7
os: make Readlink work with symlinks with target like \??\Volume{ABCD}\

windows-arm TMP directory live inside such link (see
https://github.com/golang/go/issues/29746#issuecomment-456526811 for
details), so symlinks like that will be common at least on windows-arm.

This CL builds on current syscall.Readlink implementation. Main
difference between the two is how new code handles symlink targets,
like \??\Volume{ABCD}\.

New implementation uses Windows CreateFile API with
FILE_FLAG_OPEN_REPARSE_POINT flag to get \??\Volume{ABCD}\ file handle.
And then it uses Windows GetFinalPathNameByHandle with VOLUME_NAME_DOS
flag to convert that handle into standard Windows path.
FILE_FLAG_OPEN_REPARSE_POINT flag ensures that symlink is not followed
when CreateFile opens the file.

Fixes #30463

Change-Id: I33b18227ce36144caed694169ef2e429fd995fb4
Reviewed-on: https://go-review.googlesource.com/c/164201
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/internal/syscall/windows/reparse_windows.go
src/os/file_posix.go
src/os/file_unix.go
src/os/file_windows.go
src/os/os_windows_test.go