Repository navigation
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
std.fs.create_diron the WASI target silently returnedOkwhen the path was already a regular file: the embedded platform treated every successfulstatas a directory component.__fs_mkdirnow rejects non-directory components, returning anIoErras the Node host does, while still succeeding for existing directories and newly created components.What changed
src/platform_wasi.pud- in__fs_mkdir, each existing component descriptor type is checked. A non-directory component returnsErr(__io_err(NotDirectory)), mapped toIoErr.Otherthrough the existing "CODE\0message" convention. Existing directories and newly created components are unchanged.tests/run.rs- addedcreate_dir_rejects_file_component, a temp-dir regression test that writes a regular file and asserts an error for that file and for a path with that file as a parent component, plus success for a new directory created twice.CHANGELOG.md- Unreleased/Fixed entry referencing Return an error whenfs.create_dirfinds a regular file #19.How verified
Reproduction program (temp
repro.pud: write filef, thenfs.create_dironf,f/sub, a fresh dir and an existing dir), run with the embedded WASI runtime viapud run repro.pud:Before (unmodified source):
After (fixed source):
Focused regression test:
Wider suite (debug profile; release with Wasmtime was prohibitively slow here):
Fixes #19