go/src/os
Ian Lance Taylor f758dabf52 [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: Alex Brainman <alex.brainman@gmail.com>
(cherry picked from commit 567556d786)
Reviewed-on: https://go-review.googlesource.com/c/go/+/234686
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-05-23 21:08:37 +00:00
..
exec [release-branch.go1.14] os/exec: use environment variables for user token when present 2020-03-29 17:15:56 +00:00
signal os/signal: don't ignore SIGINT in TestAtomicStop child process 2019-11-14 01:57:00 +00:00
user all: fix most of the remaining windows -d=checkptr violations 2019-12-06 05:10:34 +00:00
dir.go os: change Readdirnames doc to follow that of Readdir 2019-08-02 21:52:01 +00:00
dir_darwin.go os: reset dirinfo when seeking on Darwin 2019-12-05 20:40:38 +00:00
dir_plan9.go
dir_unix.go os: reset dirinfo when seeking on Darwin 2019-12-05 20:40:38 +00:00
dir_windows.go
env.go
env_test.go
env_unix_test.go
error.go os: fix reference to nonexistent errors.Wrapper 2019-11-07 02:14:17 +00:00
error_errno.go os: don't consult Is methods on non-syscall error types 2019-08-02 21:09:50 +00:00
error_plan9.go os: don't consult Is methods on non-syscall error types 2019-08-02 21:09:50 +00:00
error_posix.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
error_test.go os: don't consult Is methods on non-syscall error types 2019-08-02 21:09:50 +00:00
error_unix_test.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
error_windows_test.go
example_test.go os: don't leak file in ExampleOpenFile_append failure path 2019-04-11 21:47:52 +00:00
exec.go
exec_plan9.go os/exec: less allocs in the common case 2019-03-04 09:45:46 +00:00
exec_posix.go [release-branch.go1.14] os/exec: use environment variables for user token when present 2020-03-29 17:15:56 +00:00
exec_unix.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
exec_windows.go all: fix most of the remaining windows -d=checkptr violations 2019-12-06 05:10:34 +00:00
executable.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
executable_darwin.go
executable_freebsd.go
executable_path.go
executable_plan9.go
executable_procfs.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
executable_solaris.go
executable_test.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
executable_windows.go
export_test.go os: use an actual RemoveAll failure in TestRemoveAllWithMoreErrorThanReqSize 2019-10-26 01:46:02 +00:00
export_unix_test.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
export_windows_test.go
fifo_test.go
file.go os: document that File.Seek works on directories, but not portably 2020-01-06 19:03:05 +00:00
file_plan9.go cmd/go/internal/lockedfile, os: fix O_CREATE flag on Plan 9 2019-11-09 22:14:01 +00:00
file_posix.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
file_unix.go os: reset dirinfo when seeking on Darwin 2019-12-05 20:40:38 +00:00
file_windows.go os: handle backslash and slash both in the path on Windows 2019-11-14 00:58:33 +00:00
getwd.go
getwd_darwin.go
os_test.go [release-branch.go1.14] syscall: preserve Windows file permissions for O_CREAT|O_TRUNC 2020-05-23 21:08:37 +00:00
os_unix_test.go os: deflake TestNewFileNonBlock 2019-05-30 22:39:04 +00:00
os_windows_test.go all: fix most of the remaining windows -d=checkptr violations 2019-12-06 05:10:34 +00:00
path.go os: return from TestRemoveAllWithMoreErrorThanReqSize when RemoveAll succeeds on Windows 2019-10-29 18:24:40 +00:00
path_plan9.go
path_test.go
path_unix.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
path_windows.go
path_windows_test.go os: handle backslash and slash both in the path on Windows 2019-11-14 00:58:33 +00:00
pipe2_bsd.go
pipe_bsd.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
pipe_linux.go
pipe_test.go os: deflake TestFdReadRace by increasing timeout 2019-10-11 19:58:27 +00:00
proc.go os: document exit status range value 2019-03-27 04:37:34 +00:00
rawconn.go
rawconn_test.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
removeall_at.go os: use an actual RemoveAll failure in TestRemoveAllWithMoreErrorThanReqSize 2019-10-26 01:46:02 +00:00
removeall_noat.go Revert "os: handle long path in RemoveAll for windows" 2020-01-13 23:35:18 +00:00
removeall_test.go Revert "os: handle long path in RemoveAll for windows" 2020-01-13 23:35:18 +00:00
stat.go
stat_aix.go
stat_darwin.go
stat_dragonfly.go
stat_freebsd.go
stat_js.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
stat_linux.go
stat_netbsd.go
stat_openbsd.go
stat_plan9.go
stat_solaris.go
stat_test.go
stat_unix.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
stat_windows.go os: return an error when the argument of Mkdir on Windows is os.DevNull 2019-08-29 09:53:56 +00:00
sticky_bsd.go os,syscall: implement functions related to uid, gid and pid on js/wasm 2019-03-22 15:40:37 +00:00
sticky_notbsd.go os,syscall: implement functions related to uid, gid and pid on js/wasm 2019-03-22 15:40:37 +00:00
str.go
sys.go
sys_aix.go
sys_bsd.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
sys_js.go
sys_linux.go
sys_plan9.go
sys_solaris.go
sys_unix.go
sys_windows.go
timeout_test.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
types.go
types_plan9.go
types_unix.go
types_windows.go os: fix windows Lstat missing name for some files 2019-03-20 08:35:29 +00:00
wait_unimp.go all: remove the nacl port (part 1) 2019-10-09 06:14:44 +00:00
wait_wait6.go
wait_waitid.go