-
Notifications
You must be signed in to change notification settings - Fork 18.3k
Closed
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.OS-Windowshelp wanted
Milestone
Description
While Linux systems are able to pass their low level flags directly into os.OpenFile on Windows os.OpenFile takes "invented values"
go/src/syscall/types_windows.go
Lines 34 to 48 in 5d1a951
| const ( | |
| // Invented values to support what package os expects. | |
| O_RDONLY = 0x00000 | |
| O_WRONLY = 0x00001 | |
| O_RDWR = 0x00002 | |
| O_CREAT = 0x00040 | |
| O_EXCL = 0x00080 | |
| O_NOCTTY = 0x00100 | |
| O_TRUNC = 0x00200 | |
| O_NONBLOCK = 0x00800 | |
| O_APPEND = 0x00400 | |
| O_SYNC = 0x01000 | |
| O_ASYNC = 0x02000 | |
| O_CLOEXEC = 0x80000 | |
| ) |
These invented values are then checked against a subset of the features that Windows actually supports in syscall.Open
go/src/syscall/syscall_windows.go
Line 273 in 03aca99
| func Open(path string, mode int, perm uint32) (fd Handle, err error) { |
Despite Windows supporting FILE_FLAG_WRITE_THROUGH (very close to O_SYNC on Linux) the Open function does not check for O_SYNC. This is unexpected behavior as developers would expect the O_SYNC flag on Windows to work since it can perform synchronous writes.
Some ways to resolve this unexpected behavior include:
- Adding a check for O_SYNC in syscall.Open in syscall_windows.go
- Having syscall.Open perform on Windows the same way it does on Linux, by passing in file flags directly
- Note: This solution would also help with proposal: syscall: define Windows O_ALLOW_DELETE for use in os.OpenFile #34681
Metadata
Metadata
Assignees
Labels
FrozenDueToAgeNeedsFixThe path to resolution is known, but the work has not been done.The path to resolution is known, but the work has not been done.OS-Windowshelp wanted