-
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
Sync wasi-filesystem with wit definitions in standards repo #6791
Conversation
…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
…hole thing to a vec this isnt great but i dont have the time or energy to do this better right now
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.
I think this looks great! Just had a question about the hasher choice before merging.
crates/wasi/src/preview2/mod.rs
Outdated
"streams"::"stream-error": Error, | ||
"filesystem"::"error-code": Error, | ||
"types"::"error-code": Error, |
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.
These will need to be updated after #6795 merges.
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.
🚀
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`.
…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 <[email protected]>
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/filesystem
interface 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.device
andinode
from the descriptor-stat struct, and provides newmetadata-hash
family functions to replace this concept.std::hash::Hasher
to hash the device and inode of the file.device
andinode
in some places (fd_filestat_get
andfd_readdir
). I elected to fill in1
for thedevice
(because the stdio stream "files" use0
) and use the lower 64 bits of the metadata hash to fill in theinode
.async
method to calculate eachinode
infd_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.