libnvme-sys 0.9.0

Raw FFI bindings to the Linux libnvme C library (use `libnvme` for the safe wrapper)
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
use libnvme_sys::{nvme_free_tree, nvme_scan};

fn main() {
    // SAFETY: nvme_scan(NULL) is the documented "use defaults" calling
    // convention; it returns either NULL or an nvme_root we own.
    let root = unsafe { nvme_scan(std::ptr::null()) };
    if root.is_null() {
        eprintln!("nvme_scan returned NULL");
        std::process::exit(1);
    }
    println!("nvme_scan returned root={root:p}");
    // SAFETY: root is non-null (checked above) and was returned by
    // nvme_scan; we own it and this is the only free path.
    unsafe { nvme_free_tree(root) };
}