aboutsummaryrefslogtreecommitdiff
path: root/src/syscall
diff options
context:
space:
mode:
authorJes Cok <xigua67damn@gmail.com>2023-11-15 13:08:23 +0000
committerQuim Muntal <quimmuntal@gmail.com>2023-11-20 16:08:51 +0000
commitd33ad2d8f357d83dfdc14c3358e3956aac76a9b0 (patch)
treed1c32ebdc9b0b80b98064061f7ba5ac2698ba99e /src/syscall
parent1d187fd0be9cb7b79e5a4d4f389685856fe8e065 (diff)
downloadgo-d33ad2d8f357d83dfdc14c3358e3956aac76a9b0.tar.xz
syscall: support O_SYNC flag for os.OpenFile on windows
os.OpenFile on windows did not use the O_SYNC flag. This meant that even if the user set O_SYNC, os.OpenFile would ignore it. This change adds a new flag FILE_FLAG_WRITE_THROUGH, which is the equivalent of O_SYNC flag on Linux and is documented in https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea Fixes #35358 Change-Id: Ib338caed5bb2f215723bfe30a2551a83998d92c9 GitHub-Last-Rev: 82c6275cb49602d7903b2bff7d60b7c772a5d91a GitHub-Pull-Request: golang/go#64027 Reviewed-on: https://go-review.googlesource.com/c/go/+/541015 Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com> Run-TryBot: Jes Cok <xigua67damn@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Diffstat (limited to 'src/syscall')
-rw-r--r--src/syscall/syscall_windows.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/syscall/syscall_windows.go b/src/syscall/syscall_windows.go
index 33876c7fe0..d13acc5c44 100644
--- a/src/syscall/syscall_windows.go
+++ b/src/syscall/syscall_windows.go
@@ -409,6 +409,10 @@ func Open(path string, mode int, perm uint32) (fd Handle, err error) {
// Necessary for opening directory handles.
attrs |= FILE_FLAG_BACKUP_SEMANTICS
}
+ if mode&O_SYNC != 0 {
+ const _FILE_FLAG_WRITE_THROUGH = 0x80000000
+ attrs |= _FILE_FLAG_WRITE_THROUGH
+ }
return CreateFile(pathp, access, sharemode, sa, createmode, attrs, 0)
}