diff options
author | Joran Dirk Greef <joran@ronomon.com> | 2018-11-30 16:35:31 +0200 |
---|---|---|
committer | Ben Noordhuis <info@bnoordhuis.nl> | 2018-12-11 13:42:32 +0100 |
commit | 7a2c889fa8bf45587ee3efdeccf48ec22781b84b (patch) | |
tree | 634260eea653620796748278ebeaf1af31e627eb /docs/src | |
parent | f4feea331a54e2b1a1cd432e04ea83d32cfd6c5c (diff) | |
download | libuv-7a2c889fa8bf45587ee3efdeccf48ec22781b84b.tar.gz libuv-7a2c889fa8bf45587ee3efdeccf48ec22781b84b.zip |
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: https://github.com/libuv/libuv/pull/2102
Reviewed-By: Bartosz Sosnowski <bartosz@janeasystems.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Diffstat (limited to 'docs/src')
0 files changed, 0 insertions, 0 deletions