forked from libuv/libuv
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
win: fs: fix
FILE_FLAG_NO_BUFFERING
for writes
On Windows, `fs__open()` maps `UV_FS_O_DIRECT` to `FILE_FLAG_NO_BUFFERING`. When `access` is only `FILE_GENERIC_READ` this succeeds, but when `access` is `FILE_GENERIC_WRITE` this returns an error: ``` 0x00000057, ERROR_INVALID_PARAMETER, The parameter is incorrect. ``` The reason is that `FILE_GENERIC_WRITE` includes `FILE_APPEND_DATA`, but `FILE_APPEND_DATA` and `FILE_FLAG_NO_BUFFERING` are mutually exclusive: ``` FILE_GENERIC_WRITE = STANDARD_RIGHTS_WRITE | FILE_WRITE_DATA | FILE_WRITE_ATTRIBUTES | FILE_WRITE_EA | FILE_APPEND_DATA | SYNCHRONIZE ``` This incompatibility between access and attribute flags does not appear to be documented by Microsoft for `FILE_FLAG_NO_BUFFERING` but it is indirectly documented under [NtCreateFile](https://bit.ly/2rm5wRT): ``` FILE_NO_INTERMEDIATE_BUFFERING The file cannot be cached or buffered in a driver's internal buffers. This flag is incompatible with the DesiredAccess FILE_APPEND_DATA flag. ``` The solution is to remove `FILE_APPEND_DATA` from the access flags when `FILE_FLAG_NO_BUFFERING` is set. Note that this does not prevent appends, since `FILE_GENERIC_WRITE` also includes `FILE_WRITE_DATA`, which in turn allows appends. PR-URL: libuv#2102 Reviewed-By: Bartosz Sosnowski <[email protected]> Reviewed-By: Ben Noordhuis <[email protected]>
- Loading branch information
1 parent
f4feea3
commit 7a2c889
Showing
3 changed files
with
76 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters