Skip to content

Implement fd_fdstat_set_flags for Windows.#711

Merged
sunfishcode merged 3 commits intobytecodealliance:masterfrom
peterhuene:implement-fdstat-set-flags
Jan 10, 2020
Merged

Implement fd_fdstat_set_flags for Windows.#711
sunfishcode merged 3 commits intobytecodealliance:masterfrom
peterhuene:implement-fdstat-set-flags

Conversation

@peterhuene
Copy link
Copy Markdown
Member

@peterhuene peterhuene commented Dec 13, 2019

This PR 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).

@peterhuene
Copy link
Copy Markdown
Member Author

@marmistrz for review too please :)

@peterhuene peterhuene added the wasi:impl Issues pertaining to WASI implementation in Wasmtime label Dec 13, 2019
@peterhuene peterhuene force-pushed the implement-fdstat-set-flags branch from 75e8130 to 9fdc356 Compare December 13, 2019 06:00
Copy link
Copy Markdown
Member

@kubkon kubkon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@peterhuene peterhuene force-pushed the implement-fdstat-set-flags branch 2 times, most recently from 96592d3 to 5614c43 Compare January 9, 2020 22:37
@peterhuene peterhuene requested a review from kubkon January 9, 2020 22:39
Peter Huene added 3 commits January 9, 2020 14:52
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`).
* Add more comments.
* Use `contains` from bitflags.
* Format wasi-test source.
* Remove permission check from Windows `path_open` impl.
@peterhuene peterhuene force-pushed the implement-fdstat-set-flags branch from 5614c43 to 995c32c Compare January 9, 2020 22:52
@sunfishcode sunfishcode merged commit 4b7677e into bytecodealliance:master Jan 10, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

wasi:impl Issues pertaining to WASI implementation in Wasmtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants