]> Cypherpunks repositories - gostls13.git/commit
os: use WIN32_FIND_DATA.Reserved0 to identify symlinks
authorAlex Brainman <alex.brainman@gmail.com>
Sun, 7 Jan 2018 01:12:25 +0000 (12:12 +1100)
committerAlex Brainman <alex.brainman@gmail.com>
Wed, 7 Mar 2018 08:51:04 +0000 (08:51 +0000)
commite83601b4356f92f2f4d05f302d5654754ff05a6d
tree26144e3532812d88225160a2222d7f34f63f5d7b
parentd7eb4901f18b25aa35de648dacb6bc04528bab6e
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>
src/os/dir_windows.go
src/os/os_windows_test.go
src/os/stat_windows.go
src/os/types_windows.go