Skip to content
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

Missing bindings of sys/syscall.h #662

Closed
marmistrz opened this issue Jul 12, 2017 · 5 comments
Closed

Missing bindings of sys/syscall.h #662

marmistrz opened this issue Jul 12, 2017 · 5 comments

Comments

@marmistrz
Copy link
Contributor

marmistrz commented Jul 12, 2017

At least on glibc 2.25 there's a header sys/syscall.h which defines all the syscall numbers by name. It effectively includes asm/unistd_64.h (on x86_64) which is structured like this:

#define __NR_read 0
#define __NR_write 1
#define __NR_open 2

and bits/syscall.h, which does something like this:

#define SYS_write __NR_write

I don't insist on 1-1 binding but I believe we should have a syscall registry in Rust. Currently, every Rust application that uses seccomp or ptrace has to hardcode the syscall numbers.

Btw. do you think that such thing should be a part of the libc crate or rather an external crate such as https://github.com/nix-rust/nix ?

@alexcrichton
Copy link
Member

PRs are of course always welcome! There's no reason these haven't been added other than no one's gotten around to doing it yet.

@marmistrz
Copy link
Contributor Author

So let's find a cute name for that... :)
What about libc::syscall_num::write for getting the number of write syscall?

@alexcrichton
Copy link
Member

Oh we should just stick to the libc names, not invent new names.

@marmistrz
Copy link
Contributor Author

Ok, so which of two names: SYS_write or __NR_write? Both of them are available, as mentioned in the first post.

@marmistrz
Copy link
Contributor Author

marmistrz commented Jul 23, 2017

Fixed by #672

danielverkamp pushed a commit to danielverkamp/libc that referenced this issue Apr 28, 2020
* Attempt to fix tests on master

* Make all doctests use items from the real `std` rather than this
  crate, it's just easier
* Handle debuginfo weirdness by flagging functions as `no_mangle` that
  we're looking for instructions within.

* Handle double undescores in symbol names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants