Implement fd_fdstat_set_flags for Windows.

This commit implements `fd_fdstat_set_flags` for Windows.

Additionally, it fixes a problem where `O_APPEND` was not working correctly
because `GENERIC_WRITE` was always being set; as a result, `FILE_WRITE_DATA`
could not be removed from the permission set to properly enable append-only
mode.

It also treats `O_TRUNC` with `O_APPEND` as an invalid argument error.  This is
because Windows cannot support these two flags together. To support `O_TRUNC`,
the `GENERIC_WRITE` bit must be set for the file access flags.  Setting this
bit will cause `FILE_WRITE_DATA` to be set, which will not properly treat the
file as append-only (it requires `FILE_APPEND_DATA` without `FILE_WRITE_DATA`).
This commit is contained in:
Peter Huene
2019-12-10 14:38:38 -08:00
committed by Dan Gohman
parent 4197cc562e
commit 8fdd776f81
6 changed files with 245 additions and 16 deletions

View File

@@ -67,7 +67,7 @@ hostcalls! {
) -> wasi::__wasi_errno_t;
pub unsafe fn fd_fdstat_set_flags(
wasi_ctx: &WasiCtx,
wasi_ctx: &mut WasiCtx,
memory: &mut [u8],
fd: wasi::__wasi_fd_t,
fdflags: wasi::__wasi_fdflags_t,