]> Cypherpunks repositories - gostls13.git/commit
os: treat non-symlink reparse points as irregular files
authorBryan C. Mills <bcmills@google.com>
Wed, 4 Jan 2023 22:23:46 +0000 (17:23 -0500)
committerGopher Robot <gobot@golang.org>
Mon, 23 Jan 2023 22:46:55 +0000 (22:46 +0000)
commit3e44b7d07a7b3c6233eb1bf4cf3cb00a0b85adec
tree7d404b995c7cba691854cd313f993e0e38987c50
parent2423370136d4b1915d06bb1aaacbedaa900bc5c7
os: treat non-symlink reparse points as irregular files

Prior to this change (as of CL 143578), our stat function attempted to
resolve all reparse points as if they were symlinks.

This results in an additional call to CreateFile when statting a
symlink file: we use CreateFile once to obtain the reparse tag and
check whether the file is actually a symlink, and if it is we call
CreateFile again without FILE_FLAG_OPEN_REPARSE_POINT to stat the link
target. Fortunately, since symlinks are rare on Windows that overhead
shouldn't be a big deal in practice.

Fixes #42919.

Change-Id: If453930c6e98040cd6525ac4aea60a84498c9579
Reviewed-on: https://go-review.googlesource.com/c/go/+/460595
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
src/os/os_windows_test.go
src/os/stat_test.go
src/os/stat_windows.go
src/os/types_windows.go