Skip to content
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

Backport "Allow WASI to open directories without O_DIRECTORY" (#6163) #6283

Merged
merged 2 commits into from
Apr 25, 2023

Conversation

jameysharp
Copy link
Contributor

The O_DIRECTORY flag is a request that open should fail if the named path is not a directory. Opening a path which turns out to be a directory is not supposed to fail if this flag is not specified. However, wasi-common required callers to use it when opening directories.

With this PR, we always open the path the same way whether or not the O_DIRECTORY flag is specified. However, after opening it, we stat it to check whether it turned out to be a directory, and determine which operations the file descriptor should support accordingly. In addition, we explicitly check whether the precondition defined by O_DIRECTORY is satisfied.

On Windows, when opening a path which might be a directory using CreateFile, cap-primitives also removes the FILE_SHARE_DELETE mode. That means that if we implement WASI's path_open such that it always uses CreateFile on Windows, for both files and directories, then holding an open file handle prevents deletion of that file.

…dealliance#6163)

The `O_DIRECTORY` flag is a request that open should fail if the named
path is not a directory. Opening a path which turns out to be a
directory is not supposed to fail if this flag is not specified.
However, wasi-common required callers to use it when opening
directories.

With this PR, we always open the path the same way whether or not the
`O_DIRECTORY` flag is specified. However, after opening it, we `stat` it
to check whether it turned out to be a directory, and determine which
operations the file descriptor should support accordingly. In addition,
we explicitly check whether the precondition defined by `O_DIRECTORY` is
satisfied.

On Windows, when opening a path which might be a directory using
`CreateFile`, cap-primitives also removes the `FILE_SHARE_DELETE` mode.
That means that if we implement WASI's `path_open` such that it always
uses `CreateFile` on Windows, for both files and directories, then
holding an open file handle prevents deletion of that file.
@jameysharp jameysharp requested a review from a team as a code owner April 25, 2023 16:32
@jameysharp jameysharp requested review from alexcrichton and removed request for a team April 25, 2023 16:32
Copy link
Member

@alexcrichton alexcrichton left a comment

Choose a reason for hiding this comment

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

Thanks! Mind adding an entry to RELEASES.md as well?

@jameysharp jameysharp requested a review from a team as a code owner April 25, 2023 17:43
@jameysharp
Copy link
Contributor Author

Sure thing. Would you review the release notes I just wrote for this too?

@github-actions github-actions bot added wasi Issues pertaining to WASI wasmtime:docs Issues related to Wasmtime's documentation labels Apr 25, 2023
@github-actions
Copy link

Subscribe to Label Action

cc @kubkon

This issue or pull request has been labeled: "wasi", "wasmtime:docs"

Thus the following users have been cc'd because of the following labels:

  • kubkon: wasi

To subscribe or unsubscribe from this label, edit the .github/subscribe-to-label.json configuration file.

Learn more.

@jameysharp jameysharp merged commit b4bbef2 into bytecodealliance:release-8.0.0 Apr 25, 2023
@jameysharp jameysharp deleted the backport-6163 branch April 25, 2023 21:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
wasi Issues pertaining to WASI wasmtime:docs Issues related to Wasmtime's documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants