Comments (12)
I started sketching out a minimal version of my idea above, but many of the changes are relatively mechanical and I ended up with a complete, though still rough, draft: #54.
from wasi-libc.
This is now fixed, in #230.
from wasi-libc.
So WASI has no working directory. https://github.com/musec/libpreopen emulates it instead. https://github.com/musec/libpreopen probably need to wrap even *at
functions so that AT_FDCWD
can work.
from wasi-libc.
That's right. The WASI API layer has no concept of AT_FDCWD
, which would imply an ambient authority to access the current directory, but it would be possible to emulate with more libpreopen-like wrappers.
from wasi-libc.
Issue already exists musec/libpreopen#11 .
from wasi-libc.
Ah I see the libraries are vendored in. @sunfishcode if git submodule
is too much of a pain, would you be open to git subtree
? Insofar that there is an upstream issue it would be nice to land the feature both places.
from wasi-libc.
We do have numerous local changes to libpreopen, so it's not trivial to do. At a high level, libpreopen is architected to work in a Capsicum-like environment where it's a library on top of libc. However in WASI libc, we're using it as part of the libc, which changes how some things work.
If anyone wants to implement this in upstream libpreopen, I'm happy to update WASI's vendored copy. That said, this feature seems like it will be a little tricky to do as a library on top of libc. It would want to intercept openat
so that it can handle AT_FDCWD
, but it still needs to be able to call the underlying openat
in libc. This is something we could more easily do with libpreopen being part of libc.
For example, we could do this:
- Rename the existing
openat
to__wasilibc_nocwd_openat
(or something) in libc-bottom-half/cloudlibc/src/libc/fcntl/openat.c - Define a new
openat
which just does this:- if the dirfd is
AT_FDCWD
, callopen
- otherwise call
__wasilibc_nocwd_openat
- if the dirfd is
from wasi-libc.
Yeah fair point about this interposition being such a pain with C having no namespacing.
from wasi-libc.
I almost want to go rewrite with https://gitlab.redox-os.org/redox-os/relibc, haha.
from wasi-libc.
It's straightforward (if a bit ugly) to intercept *at and conditionally pass through to the real function, using dlsym
and RTLD_NEXT
. I might have a look at implementing this during a FreeBSD hackathon in two weeks.
from wasi-libc.
That's a clever idea. WASI libc doesn't support dynamic linking yet though, so for our purposes here, we'll still need some other approach.
from wasi-libc.
@emaste it would also be interesting to use CPP / configure script to prefix the function names. that would work for static linking too to some extent.
from wasi-libc.
Related Issues (20)
- wasi-libc fails to build HOT 8
- Memory leak when calling guest functions with env-vars HOT 4
- Enable C11 threads on top of pthreads? HOT 4
- dlmalloc locks seems to be not enabled in pthread builds HOT 7
- libc.a is not built reproducibility/deterministically HOT 2
- Deadlock in pthread_barrier_wait HOT 3
- Data race or race condition during exiting/joining a thread HOT 4
- C++, no exceptions, and OOM in `operator new` HOT 3
- Make errno a macro like on other platforms HOT 5
- pthread should use atomic load/store for access of contended fields HOT 14
- Directory listings should include preopens HOT 4
- `fopen`/`openat` does not seem to preserve access flags HOT 11
- Please tag wasi-sdk-20 HOT 2
- memory fault in emmalloc prev_region HOT 16
- Should we merge `wasi-libc` into `wasi-sdk`? HOT 3
- A way to redirect stdout/stderr to another file _and then back_ would be nice HOT 2
- Is there any plan about supporting WASI preview2? HOT 6
- Is it possible to not use preopen? HOT 1
- compiling cpp module with --target=wasm32-wasi results in fatal error: 'setjmp.h' file not found HOT 9
- clock_nanosleep doesn't work as expected HOT 9
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from wasi-libc.