-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implement __wasi_fd_fdstat_get
for Windows.
#557
Implement __wasi_fd_fdstat_get
for Windows.
#557
Conversation
Primarily the Apparently |
I'm also working on The idea will be to utilize these changes along with ReOpenFile to reopen the file from the existing descriptor, but with the new access / flags while preserving the current file pointer. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! Amazing work, thanks so much! :-)
Go Windows... |
Oh, and while we're here, if you could rebase to the latest |
Will do! |
8d38e2e
to
3bc87c5
Compare
I'm expecting CI to fail on Windows until there's clarification on how we expect the |
b39a182
to
62c08b9
Compare
62c08b9
to
d2be013
Compare
This is ready for a review as it should now pass CI.
|
d2be013
to
0a98681
Compare
This commit fully implements `__wasi_fd_fdstat_get` on Windows so that the descriptor flags can be determined. It does this by calling into `NtQueryInformationFile` (safe to call from user mode) to get the open mode and access of the underlying OS handle. `NtQueryInformationFile` isn't included in the `winapi` crate, so it is manually being linked against. This commit also fixes several bugs on Windows: * Ignore `__WASI_FDFLAG_NONBLOCK` by not setting `FILE_FLAG_OVERLAPPED` on file handles (the POSIX behavior for `O_NONBLOCK` on files). * Use `FILE_FLAG_WRITE_THROUGH` for the `__WASI_FDFLAG_?SYNC` flags. * `__WASI_FDFLAG_APPEND` should disallow `FILE_WRITE_DATA` access to force append-only on write operations. * Use `GENERIC_READ` and `GENERIC_WRITE` access flags. The latter is required when opening a file for truncation.
0a98681
to
45f71e5
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM! I'm gonna go ahead and merge this in so that we can progress with other work, leaving the problem of truncation rights for a subsequent PR. Please feel free to file an issue if you find anything amiss though!
I think it was a very good decision to just leave |
This PR fully implements
__wasi_fd_fdstat_get
on Windows so thatthe descriptor flags can be determined.
It does this by calling into
NtQueryInformationFile
(safe to call fromuser mode) to get the open mode and access of the underlying OS handle.
NtQueryInformationFile
isn't included in thewinapi
crate, so it ismanually being linked against.
This PR also fixes several bugs on Windows:
__WASI_FDFLAG_NONBLOCK
by not settingFILE_FLAG_OVERLAPPED
on file handles (the POSIX behavior for
O_NONBLOCK
on files).FILE_FLAG_WRITE_THROUGH
for the__WASI_FDFLAG_?SYNC
flags.__WASI_FDFLAG_APPEND
should disallowFILE_WRITE_DATA
access toforce append-only on write operations.
GENERIC_READ
andGENERIC_WRITE
access flags. Thelatter is required when opening a file for truncation.