Commit f758dabf authored by Ian Lance Taylor's avatar Ian Lance Taylor
Browse files

[release-branch.go1.14] syscall: preserve Windows file permissions for O_CREAT|O_TRUNC

On Windows, calling syscall.Open(file, O_CREAT|O_TRUNC, 0) for a file
that already exists would change the file to be read-only.
That is not how the Unix syscall.Open behaves, so avoid it on
Windows by calling CreateFile twice if necessary.

For #38225
Fixes #39158

Change-Id: I70097fca8863df427cc8a97b9376a9ffc69c6318
Reviewed-on: https://go-review.googlesource.com/c/go/+/234534


Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarAlex Brainman <alex.brainman@gmail.com>
(cherry picked from commit 567556d7)
Reviewed-on: https://go-review.googlesource.com/c/go/+/234686


Reviewed-by: default avatarEmmanuel Odeke <emm.odeke@gmail.com>
parent f296b7a6
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment