Expand description
A no_std
interface to the userspace Linux ABI designed to have no overhead, but still be safe
when possible by leveraging Rust’s type system.
Result overhead
Although types like Result<(), i32>
are sometimes used in place of the smaller i32
which
can both represent errors and values on success, it doesn’t add memory overhead or register
pressure in practice because functions are inlined.
To verify this, try to look at the assembler generated by this code when optimizations are enabled:
extern "C" {
fn fallible() -> i32;
fn test_succeeded();
fn test_failed(err: i32);
}
fn fallible_safe() -> Result<(), i32> {
let ret = unsafe { fallible() };
if ret < 0 { return Err(ret); }
Ok(())
}
pub fn test() {
if let Err(e) = fallible_safe() {
unsafe { test_failed(e) };
return;
}
unsafe { test_succeeded() };
}
Modules
Macros
Structs
- An ELF auxiliary table entry.
- An ELF auxiliary table. See the
AT_*
constants for entries that can be found inside. - Environment variable iterator.
- A memory mapping that was mapped application using
mmap
.munmap
is automatically called when the object is dropped. - An
Allocator
that usesmmap
andmremap
to allocate memory. - rtnetlink Network interface address description.
- rtnetlink Network interface description.
- rtnetlink Network interface route description.
Enums
Constants
Traits
- A socket address type.
Functions
- Accepts a connection on a socket.
- dup2⚠Duplicates the file descriptor
old_fd
to the new onenew_fd
. - Executes a program.
- Exits the program.
- Tell the kernel about new pending submission entries, and/or wait for new completion entries.
- Registers a resource on the io_uring instance so that it can be used in submition entries.
- mmap⚠Maps a chunk of memory.
- Creates an anonymous memory mapping.
- Creates a file-backed memory mapping.
- Modifies a memory mapping’s protection flags.
- Grows, shrinks or moves a memory mapping.
- Unmaps a memory mapping.
- Creates a Netfilter message type from the subsystem and a subsystem specific message type.
- Powers off the machine.
- Sends a message on a socket.