From owner-freebsd-geom@FreeBSD.ORG Wed Mar 17 02:01:49 2004 Return-Path: Delivered-To: freebsd-geom@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C992816A4CE for ; Wed, 17 Mar 2004 02:01:49 -0800 (PST) Received: from critter.freebsd.dk (critter.freebsd.dk [212.242.86.163]) by mx1.FreeBSD.org (Postfix) with ESMTP id 0CBEB43D46 for ; Wed, 17 Mar 2004 02:01:49 -0800 (PST) (envelope-from phk@phk.freebsd.dk) Received: from critter.freebsd.dk (localhost [127.0.0.1]) by critter.freebsd.dk (8.12.11/8.12.11) with ESMTP id i2HA1k95005674; Wed, 17 Mar 2004 11:01:46 +0100 (CET) (envelope-from phk@phk.freebsd.dk) To: Soeren Straarup From: "Poul-Henning Kamp" In-Reply-To: Your message of "Wed, 17 Mar 2004 10:12:31 +0100." <20040317100531.R68939-100000@x12.dk> Date: Wed, 17 Mar 2004 11:01:46 +0100 Message-ID: <5673.1079517706@critter.freebsd.dk> cc: freebsd-geom@freebsd.org Subject: Re: A simple C program to read out info from geom X-BeenThere: freebsd-geom@freebsd.org X-Mailman-Version: 2.1.1 Precedence: list List-Id: GEOM-specific discussions and implementations List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 17 Mar 2004 10:01:49 -0000 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. > >#include >#include >#include >#include >#include > > >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.