-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Add nix
support for missing host function calls.
#521
Comments
Hi .. I was hoping to be able to help on the wasi-common request and this might be a good place to start. I have an initial patch here for unlinkat: https://github.com/nix-rust/nix/compare/master...jlb6740:implement_unlinkat?expand=1. I am new to rust so could use some pointers on testing this. Once this initial one is tested I'll submit a pull request and see about implementing some of the others. |
Hi! Thanks for starting this! The patch looks good. For testing Also, sorry, I accidentally hit the wrong button while looking at the link above and opened a PR. I've now closed it. We can open a new PR once the testcase is ready. |
Hi .. I revisited this patch and I think it is ready. Please have a look when you have time .. I do have a couple of questions more related to how github works. The pull request ID still needs updating but not sure the workflow here. I'll begin work on some others assuming this will be ready soon. jlb6740/nix@890de05 |
This looks good to go! I commented on the commit -- I think you can just submit the PR with "TBD" and fix it up once the PR number is assigned. |
Hi! Was interested in helping out with WASI and figured this would be a good place to start. I gave |
Hey, that's awesome, thanks! It'd be great if we could get all missing host function calls added to Feel free to ask any questions, and I'll be happy to help out as much as I can, and @sunfishcode can mentor and straighten me out in case I'm saying something stupid ;-) |
Definitely up to help out however I can...I remember confirming that the list @sunfishcode had at the top of this issue covered everything but I will double-check that tomorrow. Regardless, I'll try to pick off things bit by bit. |
1084: sys/stat: implement mkdirat r=asomers a=kevinwern See: https://github.com/CraneStation/wasi-common/issues/16 https://linux.die.net/man/2/mkdirat My first contribution to this repo. Tests were probably overkill... Also, out of curiosity, is there any reason why `mkdir` is located in `unistd`? The documentation I read mentioned the function definition also being located in `sys/stat.h`. Co-authored-by: Kevin Wern <kevin.m.wern@gmail.com>
Continuing to chip away at this, also did a bit of grepping here for direct references to libc functions. I ended up with:
I need to look more into whether or not Any input @sunfishcode @kubkon ? I'll keep track of things here to the best of knowledge. |
|
@kevinwern That list looks good! As a minor update, |
That's a good catch. One caveat here though. It is currently quite unfortunate that |
It might also be useful to explore #519 a little bit more, i.e., see whether a fix is needed on our side or |
1089: implement posix_fadvise r=asomers a=kevinwern See: https://github.com/CraneStation/wasi-common/issues/16 http://man7.org/linux/man-pages/man2/posix_fadvise.2.html Conditional compilation derived from corresponding libc conditions: Fuchsia: https://github.com/rust-lang/libc/blob/0b02c4060a750983cebcccdf1f35a5ec4cdcf516/src/fuchsia/mod.rs#L3807 https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/lib.rs#L104-L109 uClibc: https://github.com/rust-lang/libc/blob/11c762c535cb43dda3d9d87a0845c55201a905fb/src/unix/uclibc/mod.rs#L1676 https://github.com/rust-lang/libc/blob/ce7e3a7e866dd7109a971b694a2bf58bd08f101a/src/unix/mod.rs#L1141-L1143 https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/lib.rs#L116-L121 Linux, android, emscripten: https://github.com/rust-lang/libc/blob/11c762c535cb43dda3d9d87a0845c55201a905fb/src/unix/linux_like/mod.rs#L1303 https://github.com/rust-lang/libc/blob/ce7e3a7e866dd7109a971b694a2bf58bd08f101a/src/unix/mod.rs#L1147-L1151 https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/lib.rs#L116-L121 FreeBSD: https://github.com/rust-lang/libc/blob/e0ff1e68b9e34173e9c4c3217d1b0fc81a7d352d/src/unix/bsd/freebsdlike/freebsd/mod.rs#L1223 https://github.com/rust-lang/libc/blob/ce7e3a7e866dd7109a971b694a2bf58bd08f101a/src/unix/bsd/freebsdlike/mod.rs#L1307-L1309 https://github.com/rust-lang/libc/blob/ce7e3a7e866dd7109a971b694a2bf58bd08f101a/src/unix/bsd/mod.rs#L683-L685 https://github.com/rust-lang/libc/blob/ce7e3a7e866dd7109a971b694a2bf58bd08f101a/src/unix/mod.rs#L1152-L1159 https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/lib.rs#L116-L121 WASI: https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/wasi.rs#L1001 https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/lib.rs#L134-L139 Co-authored-by: Kevin Wern <kevin.m.wern@gmail.com>
1089: implement posix_fadvise r=asomers a=kevinwern See: https://github.com/CraneStation/wasi-common/issues/16 http://man7.org/linux/man-pages/man2/posix_fadvise.2.html Conditional compilation derived from corresponding libc conditions: Fuchsia: https://github.com/rust-lang/libc/blob/0b02c4060a750983cebcccdf1f35a5ec4cdcf516/src/fuchsia/mod.rs#L3807 https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/lib.rs#L104-L109 uClibc: https://github.com/rust-lang/libc/blob/11c762c535cb43dda3d9d87a0845c55201a905fb/src/unix/uclibc/mod.rs#L1676 https://github.com/rust-lang/libc/blob/ce7e3a7e866dd7109a971b694a2bf58bd08f101a/src/unix/mod.rs#L1141-L1143 https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/lib.rs#L116-L121 Linux, android, emscripten: https://github.com/rust-lang/libc/blob/11c762c535cb43dda3d9d87a0845c55201a905fb/src/unix/linux_like/mod.rs#L1303 https://github.com/rust-lang/libc/blob/ce7e3a7e866dd7109a971b694a2bf58bd08f101a/src/unix/mod.rs#L1147-L1151 https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/lib.rs#L116-L121 FreeBSD: https://github.com/rust-lang/libc/blob/e0ff1e68b9e34173e9c4c3217d1b0fc81a7d352d/src/unix/bsd/freebsdlike/freebsd/mod.rs#L1223 https://github.com/rust-lang/libc/blob/ce7e3a7e866dd7109a971b694a2bf58bd08f101a/src/unix/bsd/freebsdlike/mod.rs#L1307-L1309 https://github.com/rust-lang/libc/blob/ce7e3a7e866dd7109a971b694a2bf58bd08f101a/src/unix/bsd/mod.rs#L683-L685 https://github.com/rust-lang/libc/blob/ce7e3a7e866dd7109a971b694a2bf58bd08f101a/src/unix/mod.rs#L1152-L1159 https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/lib.rs#L116-L121 WASI: https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/wasi.rs#L1001 https://github.com/rust-lang/libc/blob/0e702c1b4e2e56788e8b67d3efd9c242807c3d4b/src/lib.rs#L134-L139 Co-authored-by: Kevin Wern <kevin.m.wern@gmail.com>
I think unlinkat is close to merging. I will give linkat and symlinkat a go if no one else has started these. |
@jlb6740 noted that on the list. Go ahead! |
Looks like symlinkat was done (correct me if there was more here?) unlinkat is in review, though likely needs another update or two. Will start on fdopendir and probably fdreaddir if not taken.
|
Not sure how we are going to use |
Sorry was away for a bit...updated the list to reflect updates from @jlb6740 and @dingxiangfei2009 . |
@dingxiangfei2009 |
I was trying to build |
Hey @nomeata, thanks for your comment! Hmm, that's interesting. I assume that by |
Actually @nomeata, would you mind submitting a new issue for the problem you've experienced? I have an idea for a fix, and would love to have it properly tracked. Also, would you mind working through it with me? |
Given that we've effectively decided to abandon using |
At a quick glance, the following functions are not yet provided by
nix
, but would be useful to have innix
for use by wasi-common:mkdirat
,unlinkat
,renameat
,linkat
,clock_getres
,clock_gettime
,posix_fallocate
,posix_fadvise
.Currently code in wasi-common and lucet-wasi is calling libc interfaces for these functions directly, which requires unsafe code. Having
nix
provide these will mean the unsafe code is shifted tonix
instead. This may not seem like a win on a theoretical level, but the more we can pushunsafe
code into dedicated utilities that do simple unsafe things with safe, testable, interfaces, the easier it is to audit everything.I've marked this as "help wanted" -- this is not an urgent project, but it is a nicely scoped, straightforward, and subdividable project, and it's a good chance to see some of the low-level parts of the software stack that wasi-common is built on. And mentoring is available :-).
Additional resources:
nix
, though the functions above are more complex and will need testcases :-).The text was updated successfully, but these errors were encountered: