Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 17 Mar 2004 11:01:46 +0100
From:      "Poul-Henning Kamp" <phk@phk.freebsd.dk>
To:        Soeren Straarup <xride@x12.dk>
Cc:        freebsd-geom@freebsd.org
Subject:   Re: A simple C program to read out info from geom 
Message-ID:  <5673.1079517706@critter.freebsd.dk>
In-Reply-To: Your message of "Wed, 17 Mar 2004 10:12:31 %2B0100." <20040317100531.R68939-100000@x12.dk> 

next in thread | previous in thread | raw e-mail | index | archive | help
In message <20040317100531.R68939-100000@x12.dk>, Soeren Straarup writes:
>
>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);

You lack a geom_stats_open() here.

>        sp = geom_stats_snapshot_get();
>        gsp = geom_stats_snapshot_next(sp);

gsp is returned as NULL here to tell you about the problem.

>        gid = geom_lookupid(&gmp, gsp->id);

Here you dereference a NULL pointer, and get a core dump.


-- 
Poul-Henning Kamp       | UNIX since Zilog Zeus 3.20
phk@FreeBSD.ORG         | TCP/IP since RFC 956
FreeBSD committer       | BSD since 4.3-tahoe    
Never attribute to malice what can adequately be explained by incompetence.



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