Conversation
a5a3acf to
967f281
Compare
There was a problem hiding this comment.
Pull request overview
Implements POSIX/WASI-like open_at behavior in the in-memory VFS so guests can open existing nodes and create/truncate files (a prerequisite for enabling host-side FS writes), and updates unit/integration tests to reflect the new semantics.
Changes:
- Refactors VFS path resolution and expands
VfsCtxView::open_atto handleCREATE,EXCLUSIVE,DIRECTORY, andTRUNCATE. - Adds extensive unit tests around
open_atbehavior and updates integration test expectations/snapshots. - Makes
Limiter::growtake&self(internally synchronized), simplifying ownership/mutability in component setup.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| host/src/vfs/mod.rs | Implements new open_at semantics, factors path traversal helper, and adds unit tests. |
| host/src/limiter.rs | Changes grow to &self to allow shared use behind a mutex. |
| host/src/component.rs | Adjusts limiter initialization to match the new Limiter::grow signature/usage. |
| host/tests/integration_tests/python/runtime/fs.rs | Updates Python FS integration test to exercise create-on-open behavior. |
| host/tests/integration_tests/evil/fs.rs | Updates large snapshot expectations for new VFS/open behavior. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
d7bd5c4 to
adb81f9
Compare
c06aaab to
eca54f2
Compare
|
This is a massive PR but most of the diffs are in the tests; the actual implementation is fairly minimal. |
162426f to
2a96695
Compare
| let existing = self.get_node_from_start(&path, Arc::clone(&base_node)); | ||
|
|
||
| let node = match (existing, create, directory, exclusive, truncate) { | ||
| (Ok(node), true, _, false, _) => node, // Per POSIX: "If the file exists, O_CREAT has no effect except as noted under O_EXCL below. |
There was a problem hiding this comment.
what about truncate? I think you may only wanna take this branch of it is false and use the other truncation path down if it is true
| (Ok(node), true, _, false, _) => node, // Per POSIX: "If the file exists, O_CREAT has no effect except as noted under O_EXCL below. | |
| (Ok(node), true, _, false, false) => node, // Per POSIX: "If the file exists, O_CREAT has no effect except as noted under O_EXCL below. |
| | | /tmp | ERR: Read-only file system (os error 69) | | ||
| | | /usr | ERR: Read-only file system (os error 69) | | ||
| | | /var | ERR: Read-only file system (os error 69) | | ||
| | | | ERR: Bad file descriptor (os error 8) | |
There was a problem hiding this comment.
why do we have bad file descriptor messages out of the sudden? IMHO this should just fail with not found because the source file doesn't exist.
| | /bin | /var | ERR: No such file or directory (os error 44) | | ||
| | /bin | \0 | ERR: No such file or directory (os error 44) | | ||
| | / | /x/.. | ERR: No such file or directory (os error 44) | | ||
| | /bin | | OK: 0 | |
There was a problem hiding this comment.
/bin doesn't exist, so why can you copy it?
There was a problem hiding this comment.
One thing just occurred to me: the tests kinda assume that the file system is immutable, i.e. that one copy call or open call for example doesn't pollute the FS for the next test. This isn't really true anymore. Hence I think we gonna need to rewire this a bit. I can do that (PR incoming).
| | . | ERR: Invalid argument (os error 28) | | ||
| | .. | ERR: Invalid argument (os error 28) | | ||
| | / | ERR: Invalid argument (os error 28) | | ||
| | | OK: created | |
There was a problem hiding this comment.
I don't think an empty string is a valid path. Hence this should fail.
| | | OK: opened | | ||
| | . | OK: opened | | ||
| | .. | OK: opened | | ||
| | / | OK: opened | |
There was a problem hiding this comment.
Can you open a directory with an O_APPEND flag in POSIX?
| | /tmp | ERR: Read-only file system (os error 69) | | ||
| | /usr | ERR: Read-only file system (os error 69) | | ||
| | /var | ERR: Read-only file system (os error 69) | | ||
| | | OK: opened | |
There was a problem hiding this comment.
Similar question: is that flag valid for directories?
| | /tmp | ERR: Read-only file system (os error 69) | | ||
| | /usr | ERR: Read-only file system (os error 69) | | ||
| | /var | ERR: Read-only file system (os error 69) | | ||
| | | OK: opened | |
There was a problem hiding this comment.
Is O_WRITE valid for directories under POSIX?
Closes #336
I followed the specification described here. Given that we will eventually need to test this against the wasi test-suite, any differences between the aforementioned spec and the test-suite will favor the test-suite; so significant changes may need to be made in the future.
Describe your proposed changes here.