bnd-linux
Rust FFI bindings for POSIX and Linux system APIs, generated from C headers through the production direct-Clang pipeline:
system headers -> bnd-clang -> defining-header RDL -> flat libc WinMD
-> temporary package remap -> bnd-bindgen -> Rust
The checked-in canonical metadata is
winmd/bnd-linux.winmd. It contains one flat libc namespace. The
temporary remap is used only while generating Rust modules and is not
checked in.
Supported target
The checked-in bindings are generated and validated for
x86_64-unknown-linux-gnu from Ubuntu 26.04 system headers (glibc 2.43).
Other operating systems, architectures, and C library environments are
rejected because their native ABI layouts may differ.
Features
Each defining header owns a Rust module directly below bnd_linux::libc.
The Cargo feature has the same sanitized name and enables its generated
dependencies. For example:
| Defining header | Feature | Rust module |
|---|---|---|
sys/epoll.h |
epoll |
bnd_linux::libc::epoll |
bits/types/struct_tm.h |
struct_tm |
bnd_linux::libc::struct_tm |
bits/pthreadtypes.h |
pthreadtypes |
bnd_linux::libc::pthreadtypes |
sys/types.h |
types |
bnd_linux::libc::types |
All generated features are enabled by default. Disable default features to select a smaller surface; dependent defining-header features are added automatically.
Usage
Add to Cargo.toml with the features you need:
[]
= { = "0.0.7", = false, = ["epoll", "signal"] }
Then use the bindings:
use ;
// All FFI functions are unsafe
let epfd = unsafe ;
assert!;
unsafe ;
Safety
All function bindings are unsafe — they call directly into C code via
libc. The caller is responsible for upholding the preconditions documented
in the corresponding POSIX/Linux man pages.
Regenerating
The bindings are checked in and generated by bnd-linux-gen:
From the repository root, just generate-linux runs the same command and
just generate regenerates Linux before OpenSSL. Generation refreshes
src/libc/, Cargo.toml generated features, and the canonical
winmd/bnd-linux.winmd. Do not edit generated files manually.
License
MIT