posish

Safe Rust bindings to POSIX-ish libc APIs and syscalls

A Bytecode Alliance project

Github Actions CI Status crates.io page docs.rs docs

posish provides efficient memory-safe and I/O-safe wrappers to POSIX-ish libc APIs and syscalls.

posish is relatively low-level and does not support Windows; for higher-level and portable APIs to this functionality, see the [system-interface], [cap-std], and [fs-set-times] crates.

Linux raw syscall support

On Linux, posish can optionally be configured to target the raw Linux syscall ABI directly instead of calling through libc. To enable this, add --cfg linux_raw to the RUSTFLAGS environment variable, or otherwise pass --cfg linux_raw to rustc. This mode is new, and so far only tested on x86-64, but a fair amount of code has been successfully adapted to use it, and ports to other architectures should be straightforward.

This feature has two fun properties: - By being implemented in Rust, avoiding libc, errno, and std::io::Error, most functions compile down to very simple code and can even be fully inlined into user code. - Memory buffers are kept in Rust slices, and file descriptors are kept in [io-lifetimes] types, so most functions preserve memory safety and [I/O safety] all the way down to the syscall.