-
Notifications
You must be signed in to change notification settings - Fork 824
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
feat(vfs) Try to unify file descriptor #2528
Conversation
I believe a strategy using
|
Actually we cannot do that. In our case, we cannot have multiple file descriptor implementations. Why? Because the entry point is This patch contains a little bit more clean up, but everything compiles gently, even with Calling about I've also tried but cancelled, to “connect”/“link” a |
Unfortunately, this patch contains multiple features. First off, it renames the types from `host_fs` and `mem_fs` so that they use the same names. Apart from the module name, the types owned by the module are the same, which simplifies the usage greatly. Second, the code has been cleaned up a little bit. The more important clean up is probably the renaming of `MemKind` to `Node`. It's OK to do that here, because the code is not released yet. Third, a new `FileDescriptor` type is introduced. It represents a “generic” file descriptor, that a `VirtualFile` can hold. It contains a value with the size of the larger size a file descriptor on any platform, namely on Windows where a file descriptor is the size of a pointer (compared to Unix where it's a `i32`). Then a bunch of `TryInto` implementations are written to convert it to `RawFd` (on Unix) or `RawHandle` (on Windows). I'm not confident it's the best design for the moment, but it's better than before where Windows file descriptors were impossible to represent. Note that we cannot make `FileDescriptor` generic over the system for 2 reasons 1. We can activate multiple file systems at the same time, so the representation of a file descriptor can change between file system, 2. If we make `FileDescriptor` generic, then the size of `dyn VirtualFile` is unknown at compile-time, which makes impossible to use in `wasmer-wasi`, hence this design decision of taking the larger possible size for a file descriptor so that it fits all scenarios.
f117fec
to
ab83efe
Compare
When rebasing, Git losts some of the commit. Here is a bunch of them in a single commit… To learn more, see wasmerio@f211130.
Unfortunately, this patch contains multiple features.
First off, it renames the types from
host_fs
andmem_fs
so thatthey use the same names. Apart from the module name, the types owned
by the module are the same, which simplifies the usage greatly.
Second, the code has been cleaned up a little bit. The more important
clean up is probably the renaming of
MemKind
toNode
. It's OK todo that here, because the code is not released yet.
Third, a new
FileDescriptor
type is introduced. It represents a“generic” file descriptor, that a
VirtualFile
can hold. It containsa value with the size of the larger size a file descriptor on any
platform, namely on Windows where a file descriptor is the size of a
pointer (compared to Unix where it's a
i32
). Then a bunch ofTryInto
implementations are written to convert it toRawFd
(onUnix) or
RawHandle
(on Windows). I'm not confident it's the bestdesign for the moment, but it's better than before where Windows file
descriptors were impossible to represent. Note that we cannot make
FileDescriptor
generic over the system for 2 reasonsWe can activate multiple file systems at the same time, so the
representation of a file descriptor can change between file system,
If we make
FileDescriptor
generic, then the size ofdyn VirtualFile
is unknown at compile-time, which makes impossible touse in
wasmer-wasi
, hence this design decision of taking thelarger possible size for a file descriptor so that it fits all
scenarios.