]> Cypherpunks repositories - gostls13.git/commit
syscall: preserve Windows file permissions for O_CREAT|O_TRUNC
authorIan Lance Taylor <iant@golang.org>
Wed, 20 May 2020 03:23:58 +0000 (20:23 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 20 May 2020 21:52:34 +0000 (21:52 +0000)
commit567556d78657326c99b8fa84ec2a5ee511a0941b
tree9c93d363daf422261e2caae9319a58a90654d31a
parentaeab40317415468323ef45095f2090ff90c3ecd2
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.

Fixes #38225

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: Alex Brainman <alex.brainman@gmail.com>
src/os/os_test.go
src/syscall/syscall_windows.go