1
0
mirror of https://github.com/golang/go synced 2024-11-18 22:55:23 -07:00
go/src/os
Alex Brainman e83601b435 os: use WIN32_FIND_DATA.Reserved0 to identify symlinks
os.Stat implementation uses instructions described at
https://blogs.msdn.microsoft.com/oldnewthing/20100212-00/?p=14963/
to distinguish symlinks. In particular, it calls
GetFileAttributesEx or FindFirstFile and checks
either WIN32_FILE_ATTRIBUTE_DATA.dwFileAttributes
or WIN32_FIND_DATA.dwFileAttributes to see if
FILE_ATTRIBUTES_REPARSE_POINT flag is set.
And that seems to worked fine so far.

But now we discovered that OneDrive root folder
is determined as directory:

c:\>dir C:\Users\Alex | grep OneDrive
30/11/2017  07:25 PM    <DIR>          OneDrive
c:\>

while Go identified it as symlink.

But we did not follow Microsoft's advice to the letter - we never
checked WIN32_FIND_DATA.Reserved0. And adding that extra check
makes Go treat OneDrive as symlink. So use FindFirstFile and
WIN32_FIND_DATA.Reserved0 to determine symlinks.

Fixes #22579

Change-Id: I0cb88929eb8b47b1d24efaf1907ad5a0e20de83f
Reviewed-on: https://go-review.googlesource.com/86556
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-03-07 08:51:04 +00:00
..
exec all: drop support for Windows Vista or below (Windows XP) 2018-02-15 17:24:42 +00:00
signal os/signal: disable loading of history during test 2018-03-05 21:03:33 +00:00
user os/user: clean up grammar in comments 2018-02-26 16:57:47 +00:00
dir_plan9.go
dir_unix.go
dir_windows.go os: use WIN32_FIND_DATA.Reserved0 to identify symlinks 2018-03-07 08:51:04 +00:00
dir.go
env_test.go
env_unix_test.go
env.go
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
exec_plan9.go
exec_posix.go
exec_unix.go
exec_windows.go
exec.go os/exec: document Process.Kill behaviour 2018-03-05 23:47:41 +00:00
executable_darwin.go
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
file_plan9.go
file_posix.go
file_unix.go os: respect umask in Mkdir and OpenFile on BSD systems when perm has ModeSticky set 2018-02-23 22:37:55 +00:00
file_windows.go all: drop support for Windows Vista or below (Windows XP) 2018-02-15 17:24:42 +00:00
file.go os: respect umask in Mkdir and OpenFile on BSD systems when perm has ModeSticky set 2018-02-23 22:37:55 +00:00
getwd_darwin.go
getwd.go
os_test.go os: do not forget to set ModeDevice when using ModeCharDevice 2018-02-26 17:02:29 +00:00
os_unix_test.go os: respect umask in Mkdir and OpenFile on BSD systems when perm has ModeSticky set 2018-02-23 22:37:55 +00:00
os_windows_test.go os: use WIN32_FIND_DATA.Reserved0 to identify symlinks 2018-03-07 08:51:04 +00:00
path_plan9.go path: use OS-specific function in MkdirAll, don't always keep trailing slash 2018-02-23 18:37:09 +00:00
path_test.go
path_unix.go path: use OS-specific function in MkdirAll, don't always keep trailing slash 2018-02-23 18:37:09 +00:00
path_windows_test.go os: make MkdirAll support path in extended-length form 2018-02-18 03:44:53 +00:00
path_windows.go path: use OS-specific function in MkdirAll, don't always keep trailing slash 2018-02-23 18:37:09 +00:00
path.go path: use OS-specific function in MkdirAll, don't always keep trailing slash 2018-02-23 18:37:09 +00:00
pipe2_bsd.go os, syscall: use pipe2 instead of pipe syscall on OpenBSD 2018-02-27 18:37:36 +00:00
pipe_bsd.go os, syscall: use pipe2 instead of pipe syscall on OpenBSD 2018-02-27 18:37:36 +00:00
pipe_linux.go
pipe_test.go
proc.go
stat_darwin.go
stat_dragonfly.go
stat_freebsd.go
stat_linux.go
stat_nacl.go
stat_netbsd.go
stat_openbsd.go
stat_plan9.go syscall: ensure Mkdir(path) on Plan 9 fails if path exists 2018-02-20 13:21:12 +00:00
stat_solaris.go
stat_unix.go
stat_windows.go os: use WIN32_FIND_DATA.Reserved0 to identify symlinks 2018-03-07 08:51:04 +00:00
stat.go
sticky_bsd.go
sticky_notbsd.go
str.go
sys_bsd.go
sys_linux.go
sys_nacl.go
sys_plan9.go
sys_solaris.go
sys_unix.go os: unify supportsCloseOnExec definition 2018-02-26 17:10:24 +00:00
sys_windows.go
sys.go
timeout_test.go internal/poll: if poller init fails, assume blocking mode 2018-03-06 23:21:25 +00:00
types_plan9.go
types_unix.go
types_windows.go os: use WIN32_FIND_DATA.Reserved0 to identify symlinks 2018-03-07 08:51:04 +00:00
types.go
wait_unimp.go
wait_wait6.go
wait_waitid.go