A simple C program to read out info from geom
Soeren Straarup
xride at x12.dk
Wed Mar 17 01:12:34 PST 2004
Hi
I'm trying to get into the geom some more by writting and testing,
but i'm stuck here, i'm trying to look at the first item in the snap
shot, using libgeom.h from userland.
<program>
#include <libgeom.h>
#include <stdio.h>
#include <sys/resource.h>
#include <devstat.h>
#include <sys/devicestat.h>
int main ( void )
{
char *p;
struct gmesh gmp;
struct devstat *gsp;
struct gprovider *pp;
struct gconsumer *cp;
struct gident *gid;
void *sp;
geom_gettree(&gmp);
sp = geom_stats_snapshot_get();
gsp = geom_stats_snapshot_next(sp);
gid = geom_lookupid(&gmp, gsp->id);
printf("XXX\n");
if (gid == NULL) {
printf(" ??");
} else if (gid->what == ISPROVIDER) {
pp = gid->ptr;
printf(" %s", pp->name);
} else if (gid->what == ISCONSUMER) {
cp = gid->ptr;
printf(" %s/%s/%s",
cp->geom->class->name,
cp->geom->name,
cp->provider->name);
}
printf("\n");
return 0;
}
</program>
What is i don't get is why it never makes it to print XXX.
My understanding is like this
get the tree assign it to gmp
get the snapshot assign it to sp
get the first item in the snap shot assign it to gsq
get the id of the item in the snap shot
Feedback is more than welcome.
Best regards Søren.
Soeren Straarup | aka OZ2DAK aka Xride
FreeBSD wannabe | FreeBSD since 2.2.6-R
If you see the light at the end of the tunnel,
then make sure it is not a train..
More information about the freebsd-geom
mailing list