1
0
mirror of https://github.com/golang/go synced 2024-11-17 12:24:51 -07:00
go/src/os
Alex Brainman 1c95d9728a 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>
2018-09-29 04:02:38 +00:00
..
exec os/exec: document how to do special args quoting on Windows 2018-09-01 04:45:46 +00:00
signal
user os/user: note in doc that user.Current is being cached 2018-09-25 17:10:46 +00:00
dir_plan9.go
dir_unix.go os: increase directory reading block size on Unix systems 2018-07-06 22:39:14 +00:00
dir_windows.go
dir.go
env_test.go os: treat "${}" in Expand like in Go 1.10 2018-06-29 21:07:28 +00:00
env_unix_test.go
env.go os: treat "${}" in Expand like in Go 1.10 2018-06-29 21:07:28 +00:00
error_plan9.go
error_posix.go
error_test.go
error_unix_test.go
error_unix.go
error_windows_test.go
error_windows.go
error.go
example_test.go os: use Println instead of Printf in example 2018-08-24 07:11:38 +00:00
exec_plan9.go os: add ExitCode method to ProcessState 2018-08-28 01:46:11 +00:00
exec_posix.go os: add ExitCode method to ProcessState 2018-08-28 01:46:11 +00:00
exec_unix.go
exec_windows.go
exec.go
executable_darwin.go os: add check for empty executable path on darwin 2018-08-02 20:31:25 +00:00
executable_freebsd.go
executable_path.go
executable_plan9.go
executable_procfs.go
executable_solaris.go
executable_test.go
executable_windows.go
executable.go
export_test.go
export_windows_test.go
fifo_test.go os: skip TestFifoEOF on android 2018-06-14 13:41:57 +00:00
file_plan9.go os: handle TMPDIR in TempDir on Plan 9 2018-08-17 23:12:06 +00:00
file_posix.go
file_unix.go os: document that Remove removes only empty directories 2018-08-03 23:09:31 +00:00
file_windows.go os: clarify that Close cancels pending I/O 2018-07-11 00:06:19 +00:00
file.go os: have UserCacheDir return an error on failure 2018-06-25 18:59:39 +00:00
getwd_darwin.go
getwd.go
os_test.go
os_unix_test.go all: remove repeated "the" from comments 2018-09-28 08:46:55 +00:00
os_windows_test.go os: use FILE_FLAG_OPEN_REPARSE_POINT in SameFile 2018-09-29 04:02:38 +00:00
path_plan9.go
path_test.go
path_unix.go
path_windows_test.go all: use strings.ReplaceAll and bytes.ReplaceAll where applicable 2018-09-26 22:14:25 +00:00
path_windows.go
path.go os: when looping in RemoveAll, close and re-open directory 2018-06-27 22:05:25 +00:00
pipe2_bsd.go Revert "syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe" 2018-08-26 21:30:35 +00:00
pipe_bsd.go Revert "syscall, os: use pipe2 syscall on DragonflyBSD instead of pipe" 2018-08-26 21:30:35 +00:00
pipe_linux.go
pipe_test.go internal/poll: don't take read lock in SetBlocking 2018-07-11 00:34:18 +00:00
proc.go
stat_darwin.go
stat_dragonfly.go
stat_freebsd.go
stat_linux.go
stat_nacljs.go
stat_netbsd.go
stat_openbsd.go
stat_plan9.go
stat_solaris.go
stat_test.go os: use FILE_FLAG_OPEN_REPARSE_POINT in SameFile 2018-09-29 04:02:38 +00:00
stat_unix.go
stat_windows.go
stat.go
sticky_bsd.go
sticky_notbsd.go
str.go
sys_bsd.go
sys_js.go
sys_linux.go
sys_nacl.go
sys_plan9.go
sys_solaris.go
sys_unix.go
sys_windows.go
sys.go
timeout_test.go
types_plan9.go
types_unix.go
types_windows.go os: use FILE_FLAG_OPEN_REPARSE_POINT in SameFile 2018-09-29 04:02:38 +00:00
types.go os: add ModeCharDevice to ModeType 2018-09-13 09:52:57 +00:00
wait_unimp.go
wait_wait6.go
wait_waitid.go