Skip to content
This repository has been archived by the owner on Jan 28, 2023. It is now read-only.

Support pre-opened files #1

Closed
sunfishcode opened this issue Sep 17, 2019 · 3 comments
Closed

Support pre-opened files #1

sunfishcode opened this issue Sep 17, 2019 · 3 comments

Comments

@sunfishcode
Copy link
Member

Currently WASI only supports pre-opened directories. It'd be useful to have a preopen type indicating a file rather than just a directory.

@sbc100
Copy link
Member

sbc100 commented Sep 17, 2019

This seems like it could be consistent. NaCl sel_ldr has command line flags [-h d:D] [-r d:D] [-w d:D] for mapping host file descriptors into the sandbox:

 -h
 -r
 -w associate a host POSIX descriptor D with app desc d
    that was opened in O_RDWR, O_RDONLY, and O_WRONLY modes
    respectively

Perhaps we could remove the existing special case for FDs 0, 1, and 2. IIRC these are currently kind of magically pre-opened?

Would libpreopen need to be involved at all? I mean would __wasilibc_register_preopened_fd need to be called or could we just start using these fds in syscall right away lib fd 0,1, 2?

@MarkMcCaskey
Copy link

This could be used to solve a major ergonomic issue with CLI WASI applications too! It'd be simple for a runtime to detect if arguments going to the WASI program are paths and then automatically preopen them.

@sunfishcode sunfishcode transferred this issue from WebAssembly/WASI May 20, 2020
@sunfishcode
Copy link
Member Author

This would be a useful feature. We unfortunately didn't get to it for preview1, but we should do it for preview2: WebAssembly/WASI#509.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants