freebsd-geom-rs
A Rust library for inspecting the GEOM(4) graph
Example
use freebsd_geom as geom;
// Pull the current GEOM graph out of the kernel and parse it into a graph structure.
let mygraph = get_graph?;
// Print the name of the root of each independent object tree (i.e., DISK devices).
for in mygraph.roots_iter
That might print something like:
Root: ada0 (type DISK)
Root: nvd0 (type DISK)
We can recursively iterate all descendents of a node:
for in mygraph.roots_iter
That might print something like:
Root ada0 descendents:
Name: ada0 Class: DEV
Name: ada0 Class: PART
Name: ada0p1 Class: DEV
Name: ada0p1 Class: LABEL
Name: gpt/foobar Class: DEV
Name: ffs.gpt/foobar Class: VFS
We can look for all partition tables (type PART) and print out their partitions:
for in mygraph.roots_iter
This might print something like:
Partitions of nvd1 (scheme: GPT):
nvd1p2 (type: freebsd-ufs label: 'my-fs-label' uuid: abcdef01-79e7-11e9-b158-7085c25400ea
nvd1p1 (type: freebsd-swap label: 'my-swap-label' uuid: 23456789-79e7-11e9-b158-7085c25400ea
...