Sync wasi-filesystem with wit definitions in standards repo#6791
Merged
Sync wasi-filesystem with wit definitions in standards repo#6791
Conversation
added 4 commits
July 31, 2023 16:57
…h/metadata_hash_fixes upstream main changes the interface to be named `types`, and has changes to descriptor-stat, directory-entry, adds the metadata hash methods. pch/blocking_is_a_stream_concern upstreams the deletion of non-blocking from descriptor flags. pch/metadata_hash_fixes adds missing this: descriptor arguments to the metadata-hash and metadata-hash-at methods.
…ete wasi-cli-base/preopens.wit
added 13 commits
July 31, 2023 21:00
…hole thing to a vec this isnt great but i dont have the time or energy to do this better right now
elliottt
reviewed
Aug 3, 2023
Member
elliottt
left a comment
There was a problem hiding this comment.
I think this looks great! Just had a question about the hasher choice before merging.
crates/wasi/src/preview2/mod.rs
Outdated
Comment on lines
+56
to
+57
| "streams"::"stream-error": Error, | ||
| "filesystem"::"error-code": Error, | ||
| "types"::"error-code": Error, |
wiggle takes care of endianness translation. The to_le in fd_readdir entries is because that implementation is writing structs directly to memory (very cursed) s390x CI caught this bug
154b82a to
9ae2212
Compare
…failure on s390x prtest:full
…emory fd_readdir will write its results to a buffer, and needs to be careful with endianness as a result. However, fd_filestat_get returns the value directly, and as such does not need to call `to_le`.
eduardomourar
pushed a commit
to eduardomourar/wasmtime
that referenced
this pull request
Aug 18, 2023
…alliance#6791) * filesystem.wit: upstream main + pch/blocking_is_a_stream_concern + pch/metadata_hash_fixes upstream main changes the interface to be named `types`, and has changes to descriptor-stat, directory-entry, adds the metadata hash methods. pch/blocking_is_a_stream_concern upstreams the deletion of non-blocking from descriptor flags. pch/metadata_hash_fixes adds missing this: descriptor arguments to the metadata-hash and metadata-hash-at methods. * copy in preopens.wit and world.wit from wasi-filesystem repo, and delete wasi-cli-base/preopens.wit * other wits: fix names of filesystem/{types, preopens} * fix bindgen invocations and import paths for filesystem changes * component adapter: fix bindings paths for preopens and filesystem * wip * wippp * fill in a reasonable-ish metadata hash impl * preview 1 adapter: we need async in the dir entries, so collect the whole thing to a vec this isnt great but i dont have the time or energy to do this better right now * component adapter: use metadata hash to fake ino * wasi-tests: fix warnings * reactor-tests: fix filesystem paths * only create a BuildHasher impl once * consistiency * component adapter: use descriptor to call filesystem funcs, not the fd * reactor test: fix filesystem types paths * metadata hash: use DefaultHasher * fix missed trappable-error-type merge conflicts * preview1-in-preview2: dont use to_le in Filestat assignment of ino wiggle takes care of endianness translation. The to_le in fd_readdir entries is because that implementation is writing structs directly to memory (very cursed) s390x CI caught this bug * debugging: forward stdio for fd_readdir test so we can figure out CI failure on s390x prtest:full * Don't convert filestat ino to little-endian, as it's not written to memory fd_readdir will write its results to a buffer, and needs to be careful with endianness as a result. However, fd_filestat_get returns the value directly, and as such does not need to call `to_le`. --------- Co-authored-by: Trevor Elliott <telliott@fastly.com>
1 task
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.
This PR pulls in the latest wit files from the wasi-filesystem repo, with the addition of just one pending upstream change to remove the nonblocking descriptor-flag.
The changes look like:
wasi:filesystem/filesysteminterface has been renamedwasi:filesystem/types. This resulted in lots of renaming across the repo. For the main filesystem impl I use the newtypes::module prefix but in most other places I followeduse ...::filesystem::types as filesystem;to make it clearer to read.deviceandinodefrom the descriptor-stat struct, and provides newmetadata-hashfamily functions to replace this concept.std::hash::Hasherto hash the device and inode of the file.deviceandinodein some places (fd_filestat_getandfd_readdir). I elected to fill in1for thedevice(because the stdio stream "files" use0) and use the lower 64 bits of the metadata hash to fill in theinode.asyncmethod to calculate eachinodeinfd_readdir, so I had to move some calculation out of the iterator map and into a for loop, done eagerly for each entry in the directory. Ideally this would be lazy for only entries in the directory that are being serialized as part of the adapter, or cache it between entries, but I didn't consider this worthwhile to invest in right now.See also:
WebAssembly/wasi-filesystem#125: remove nonblocking descriptor flag. still open.
WebAssembly/wasi-filesystem#126: fix parameters to metadata functions. merged.