3 stable releases
| 1.2.0 | May 6, 2025 |
|---|---|
| 1.1.0 | Mar 11, 2025 |
| 1.0.0 | Sep 10, 2022 |
#263 in Unix APIs
2,025 downloads per month
145KB
3.5K
SLoC
This library defines syscall numbers and a syscall! macro for directly
invoking Linux system calls.
The arch modules document available syscall numbers for all supported
architectures, and the top-level module re-exports syscall numbers for the
current target platform.
Syscall results may be inspected with the Result* traits.
Example
let stdout: i32 = 1;
let hello = "Hello, world!\n\0";
let rc = unsafe {
syscall!(SYS_write, stdout, hello.as_ptr(), hello.len())
};
rc.check()?;
Safety
Very unsafe.
Linux syscalls are low-level primitives that operate without any notion of borrow checking or type safety. It is the caller's responsibility to ensure parameters have types, values, and lifetimes appropriate to the syscall being invoked.
- The kernel cannot distinguish
*const Tand*mut T. - Many syscalls accept complex parameters as pointers to a
struct. The caller must ensure such parameters have appropriate layout and alignment. - Syscalls vary between architectures. The same syscall name may have
a completely different signature even on similar targets, for example
SYS_mmaponx86andx86_64.
Linux syscall macros for Rust
This library defines syscall numbers and a syscall! macro for directly
invoking Linux system calls.
The arch modules document available syscall numbers for all supported
architectures, and the top-level module re-exports syscall numbers for the
current target platform.
Supported architectures:
aarch64armloongarch64riscv64s390xx86x86_64
To be supported by this library, an architecture must:
- Have a
*-linux-*target supported by the Rust toolchain at Tier 2 or better (https://doc.rust-lang.org/rustc/platform-support.html), and - Have a stabilised
asm!macro (https://github.com/rust-lang/rust/issues/93335).