-
Notifications
You must be signed in to change notification settings - Fork 19
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
Drop explicit preopens #128
Comments
I'm up for exploring this idea more sometime in the future, but for the preview2 timeframe I have advocated that we keep interfaces and concepts that existed in preview 1 as similar as we can possibly get away with. |
I think this is a good idea. This would solve WebAssembly/wasi-libc#414 |
Yeah, that's totally fine! The main reason why I am asking this is because I'm trying to get a grip on where WASI wants to end up regarding "preopens", so I can take that into account for wasi-sockets. |
As the person who initially brought preopens to WASI, based on similar ideas in CloudABI and Capsicum, I agree. I've also come to believe that migrating wasi-filesystem to have a rooted filesystem view would be beneficial to WASI. This would be from many people's perspective a much more "normal" filesystem API. We could have an This new namespace could still be expected to be sandboxed, but the sandbox could look more like a simple VFS with things mounted in it. Many use cases could just use that directly, rather than using preopens. I expect the VFS could even be populated by the existing Why the change in stance? Preopens were added in the Preview 1 era, at a time when there wasn't even a component model proposal, and we had a lot of questions with no answers. But today:
(But what if you want an Everything Is A File experience? We can provide it, by teaching WASI-Virt how to implement features in terms of wasi-filesystem APIs!) So, should we start moving in this direction? I don't see any objections to this overall issue so far, but I'll do some more asking around. |
i concern the "simple VFS" is likely a bit more expensive than preopens, which is just a list. |
Dan published a blog post about this today: Capabilities and Filesystems. In it he says the following about
To me this seems like something worth experimenting with now that we've shipped Preview 2. |
I've created a proof-of-concept of this over at: bytecodealliance/wasmtime@main...badeend:root-directory
I went with a simpler design, similar to the one outlined in the initial post. Instead of duplicating the entire path-based API-surface into non- package wasi:[email protected];
interface preopens {
+ @deprecated
get-directories: func() -> list<tuple<descriptor, string>>;
+ /// Get the root directory of the file system.
+ /// In POSIX filesystems this is located at: `/`
+ @unstable
+ root-directory: func() -> descriptor;
} This feels like a sweet spot to me:
To test it all out I disabled the preview1-style preopens and every unit test still passes, except let preopens = wasi::filesystem::preopens::get_directories();
let (dir, _) = &preopens[0]; // <--- panics here All other tests continue work because they go through the preview1-to-preview2 adapters, which I also modified: On initialization, the adapter calls This was enough to make the preview1 test suite pass without modification. Note: eagerly preopening Some notes about the POC implementation:
|
The POC also fixes WebAssembly/wasi-libc#414, btw |
@badeend thanks for doing this work! - Would you be up for presenting these changes at either the WASI sub-group or the component implementers meeting? It doesn't have to be anything big - but more to get all implementers on the same page about this.
Oh also, I was curious about this: for 0.3, do you think we should keep the |
Even for 0.3+, I think there's still merit in keeping them. Two reasons I can think of right now:
|
A subtlety here is that the current |
That's correct. The current WASI To get POSIX |
In a POSIX sense, prepending the path isn't sufficient, because according to POSIX, the main purpose of
|
Ah right. The devil is always in the details. |
Do we actually need to support |
That's a good question. I've been thinking part of the goal here is to have as "normal" a filesystem API as we can get, which would include having an |
Given WASI's CloudABI heritage I understand why preopens currently are the way that they are.
But they feel like something that should be just an host implementation detail. Ie. could the following also work?:
Remove
in exchange for:
which returns a single directory that represents the "default filesystem". In similar vein to:
By default this is an empty directory. But the host can "mount" specific external directories/files into it. Exactly how the contents of this "filesystem" are populated (preopened or not), would be of concern only to the host, not the client application / libc.
The text was updated successfully, but these errors were encountered: