# fmd-adm-sys
Raw Rust FFI bindings to illumos
[libfmd_adm](https://illumos.org/man/3LIB/libfmd_adm), the Fault
Management Daemon administrative library.
## How bindings are generated
The bindings in `src/lib.rs` are pre-generated by
[bindgen](https://github.com/rust-lang/rust-bindgen) and checked into
source control. Bindgen is **not** run at build time - `build.rs` only
contains linker directives (`cargo:rustc-link-lib=fmd_adm` and the
library search path).
To regenerate, run `generate.sh` on an illumos machine with `bindgen`
installed (`cargo install bindgen-cli`):
```
./generate.sh
```
The script runs bindgen with the following flags:
- `--allowlist-function 'fmd_adm_.*'` - emit only libfmd_adm functions,
not the entire transitive header tree
- `--allowlist-var 'FMD_ADM_.*'` and `--allowlist-var 'FMD_TYPE_.*'` -
capture constants like `FMD_ADM_VERSION` and `FMD_TYPE_STRING`
- `--raw-line '#![allow(...)]'` - prepend an attribute to suppress
warnings on the naming conventions that bindgen produces for C
typedefs
## Keyword renaming
The `fmd_stat_t` union in the C header contains fields named `bool`,
`i32`, `i64`, and `str`, which are reserved keywords in Rust. Bindgen
automatically renames these by appending an underscore: `bool_`, `i32_`,
`i64_`, `str_`.
## Linking
The library is at `/usr/lib/fm/amd64/libfmd_adm.so` on illumos. The
`.cargo/config.toml` at the workspace root sets the runtime library
search path via `-R/usr/lib/fm/amd64`.