-
Notifications
You must be signed in to change notification settings - Fork 16
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: Add tmp-dir #54
base: main
Are you sure you want to change the base?
Conversation
Allow a temporary directory to be specified. This will prevent the panic from std::env::temp_dir(). https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/wasi/os.rs#L266-L268 https://bytecodealliance.zulipchat.com/#narrow/channel/219900-wasi/topic/tempfile.3A.3Atempdir.20panics
Use full name. Co-authored-by: Lann <[email protected]>
I completely understand the challenge you're facing and I can see why this change might seem like a straightforward improvement. That said, I do have some concerns about its broader implications.
The proposed function would effectively require all hosts to support the concept of "temporary directories," even if that doesn't align with their architecture. It also adds a new responsibility for hosts to manage file cleanup, which can be non-trivial—especially for non-POSIX environments like blob stores that don't natively support temp files. I see that the return type of the proposed function is an As already mentioned in chat, I believe tools like WASI-Virt should be able to handle temporary files quite effectively for most scenarios. I understand that an in-memory solution isn't viable for you due to file size constraints, but that raises the question: how portable is your specific use-case really? IIUC, it already has some pretty hefty requirements on its host. Does it make sense for WASI to accommodate this particular use case, and does that align with WASI's broader portability goals? Regarding Joel’s point in chat:
A subtle distinction here is that Another, more ideological concern I have with the design as proposed is the implicit assumption of capabilities via file paths. There has been some prior discussion on this at:
The world has shifted a bit in terms of link-time vs. runtime authority since its creation, but I think many of @sunfishcode's points in the wasi-libc issue still hold up today. One idea I like from that thread is to make the guest responsible for creating a temp folder and adding that to its internal preopens list. This turns the security model from "implicitly assumed" to "actively requested". |
wasi seems to lack the ability to clean up before exit, which hinders the practice of implementing temporary files by yourself. Ideally, when a But when a |
The way I see things, there are 3 different possibilities:
I'd strongly prefer 3, but I'd be happy with whatever is decided to that end. 1 is untenable. |
I agree; it would be nice to have something like this, so that tempfile and mkstemp and other things can work out of the box. I also agree with @badeend, that we should think about environments that don't necessarily want to expose this. We may want to include this in the cli world, but perhaps we could put it in its own interface, rather than putting it in One question is, how visible are these temporary directories to other programs, or other Wasm instances? Some programs that use temporary directories do so specifically for the ability to obtain a filesystem path string that they can pass to other applications to open. But then we have to ask, how shared should these temporary directories be? And do they require guests to see them with the same path strings, implying a level of namespace sharing? If that needs to be configured, how would that work? |
@badeend The way I think of
I guess I'm not seeing what new capabilities the guest would get, nor what additional requirements there would be on the implementation. An implementation can always return
That sounds cool, yes. Then |
so, C would create the temp folder when you ran |
Allow a temporary directory to be specified. This will prevent the panic from std::env::temp_dir().
https://github.com/rust-lang/rust/blob/master/library/std/src/sys/pal/wasi/os.rs#L266-L268
https://bytecodealliance.zulipchat.com/#narrow/channel/219900-wasi/topic/tempfile.3A.3Atempdir.20panics