3:01 PM - Quick and Dirty GEOM print program
While debugging a GEOM related problem with a program, I ended up needing a way to print out data from what libgeom gets from the kernel. Below is a quick and dirty dump program for just such a situation. Compile it with
gcc -std=c99 -lgeom prog.c -o prog
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <libgeom.h>
#include <stdint.h>
void read_geom_mesh(struct gmesh *mesh);
void
read_geom_mesh(struct gmesh *mesh)
{
struct gclass *classp;
struct ggeom *gp;
struct gprovider *provider;
/*
* Build the device table. First add all disks (and CDs).
*/
LIST_FOREACH(classp, &mesh->lg_class, lg_class) {
puts(classp->lg_name);
LIST_FOREACH(gp, &classp->lg_geom, lg_geom) {
printf(" %ud %s ", gp->lg_id, gp->lg_name);
LIST_FOREACH(provider, &gp->lg_provider, lg_provider) {
printf(" provider: %u %s %s ", provider->lg_id, provider->lg_name, provider->lg_mode);
}
}
}
}
int main(int argc, char *argv[]) {
int error;
struct gmesh mesh;
error = geom_gettree(&mesh);
if (error == 0)
read_geom_mesh(&mesh);
return 0;
}