Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Mar 2004 10:12:31 +0100 (CET)
From:      Soeren Straarup <xride@x12.dk>
To:        freebsd-geom@freebsd.org
Subject:   A simple C program to read out info from geom
Message-ID:  <20040317100531.R68939-100000@x12.dk>

next in thread | raw e-mail | index | archive | help

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 =3D geom_stats_snapshot_get();
        gsp =3D geom_stats_snapshot_next(sp);
        gid =3D geom_lookupid(&gmp, gsp->id);
printf("XXX\n");
        if (gid =3D=3D NULL) {
                printf(" ??");
        } else if (gid->what =3D=3D ISPROVIDER) {
                pp =3D gid->ptr;
                printf(" %s", pp->name);
        } else if (gid->what =3D=3D ISCONSUMER) {
                cp =3D 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=F8ren.

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..



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20040317100531.R68939-100000>