]> Cypherpunks repositories - gostls13.git/commit
os: use FILE_FLAG_OPEN_REPARSE_POINT in SameFile
authorAlex Brainman <alex.brainman@gmail.com>
Sat, 8 Sep 2018 06:05:29 +0000 (16:05 +1000)
committerAlex Brainman <alex.brainman@gmail.com>
Sat, 29 Sep 2018 04:02:38 +0000 (04:02 +0000)
commit1c95d9728aa5c8638db1bbabfb6ae764c4613c68
treea33828fa474ac031fa37c706cb974f361bd4425b
parent7dda5123d8753cfd1f041e1d1537bb5493cd5e5d
os: use FILE_FLAG_OPEN_REPARSE_POINT in SameFile

SameFile opens file to discover identifier and volume serial
number that uniquely identify the file. SameFile uses Windows
CreateFile API to open the file, and that works well for files
and directories. But CreateFile always follows symlinks, so
SameFile always opens symlink target instead of symlink itself.

This CL uses FILE_FLAG_OPEN_REPARSE_POINT flag to adjust
CreateFile behavior when handling symlinks.

As per https://docs.microsoft.com/en-us/windows/desktop/FileIO/symbolic-link-effects-on-file-systems-functions#createfile-and-createfiletransacted

"... If FILE_FLAG_OPEN_REPARSE_POINT is specified and:

If an existing file is opened and it is a symbolic link, the handle
returned is a handle to the symbolic link. ...".

I also added new tests for both issue #21854 and #27225.
Issue #27225 is still to be fixed, so skipping the test on
windows for the moment.

Fixes #21854
Updates #27225

Change-Id: I8aaa13ad66ce3b4074991bb50994d2aeeeaa7c95
Reviewed-on: https://go-review.googlesource.com/134195
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
src/os/os_windows_test.go
src/os/stat_test.go [new file with mode: 0644]
src/os/types_windows.go