From owner-freebsd-geom@FreeBSD.ORG Wed Mar 17 01:12:34 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 4928B16A4CE for ; Wed, 17 Mar 2004 01:12:34 -0800 (PST) Received: from pasmtp.tele.dk (pasmtp.tele.dk [193.162.159.95]) by mx1.FreeBSD.org (Postfix) with ESMTP id CCE0743D48 for ; Wed, 17 Mar 2004 01:12:33 -0800 (PST) (envelope-from xride@x12.dk) Received: from x12.dk (xforce.dk [80.164.11.218]) by pasmtp.tele.dk (Postfix) with ESMTP id 9B02F1EC322 for ; Wed, 17 Mar 2004 10:12:32 +0100 (CET) Received: by x12.dk (Postfix, from userid 666) id 1D74D4D; Wed, 17 Mar 2004 10:12:32 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by x12.dk (Postfix) with ESMTP id 0C0AD26 for ; Wed, 17 Mar 2004 10:12:32 +0100 (CET) Date: Wed, 17 Mar 2004 10:12:31 +0100 (CET) From: Soeren Straarup To: freebsd-geom@freebsd.org Message-ID: <20040317100531.R68939-100000@x12.dk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Subject: 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 09:12:34 -0000 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); 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; } 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.. 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. From owner-freebsd-geom@FreeBSD.ORG Sat Mar 20 02:13:23 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 B0C2016A4CE for ; Sat, 20 Mar 2004 02:13:23 -0800 (PST) Received: from pasmtp.tele.dk (pasmtp.tele.dk [193.162.159.95]) by mx1.FreeBSD.org (Postfix) with ESMTP id 4482043D2F for ; Sat, 20 Mar 2004 02:13:23 -0800 (PST) (envelope-from xride@x12.dk) Received: from x12.dk (xforce.dk [80.164.11.218]) by pasmtp.tele.dk (Postfix) with ESMTP id EBD771EC326 for ; Sat, 20 Mar 2004 11:13:21 +0100 (CET) Received: by x12.dk (Postfix, from userid 666) id 5EAAE4D; Sat, 20 Mar 2004 11:13:21 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by x12.dk (Postfix) with ESMTP id 48D7F26 for ; Sat, 20 Mar 2004 11:13:21 +0100 (CET) Date: Sat, 20 Mar 2004 11:13:21 +0100 (CET) From: Soeren Straarup To: freebsd-geom@freebsd.org Message-ID: <20040320101613.M86653-100000@x12.dk> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: QUOTED-PRINTABLE Subject: LIST_HEAD and LIST_ENTRY ? 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: Sat, 20 Mar 2004 10:13:23 -0000 How to access in fx struct gprovider provider and consumers ? I can't seem to get the picture of how they work. What i'm trying to get is a picture of what is connected to what. btw i'm using libgeom.h 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.. From owner-freebsd-geom@FreeBSD.ORG Sat Mar 20 03:01:52 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 CEB9816A4CF for ; Sat, 20 Mar 2004 03:01:52 -0800 (PST) Received: from darkness.comp.waw.pl (unknown [195.117.238.236]) by mx1.FreeBSD.org (Postfix) with ESMTP id 5868E43D45 for ; Sat, 20 Mar 2004 03:01:51 -0800 (PST) (envelope-from pjd@darkness.comp.waw.pl) Received: by darkness.comp.waw.pl (Postfix, from userid 1009) id 77391AC995; Sat, 20 Mar 2004 12:01:48 +0100 (CET) Date: Sat, 20 Mar 2004 12:01:48 +0100 From: Pawel Jakub Dawidek To: Soeren Straarup Message-ID: <20040320110148.GU8930@darkness.comp.waw.pl> References: <20040320101613.M86653-100000@x12.dk> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="KJvkvZqQCzHgjKcr" Content-Disposition: inline In-Reply-To: <20040320101613.M86653-100000@x12.dk> User-Agent: Mutt/1.4.2i X-PGP-Key-URL: http://people.freebsd.org/~pjd/pjd.asc X-OS: FreeBSD 5.2.1-RC2 i386 cc: freebsd-geom@freebsd.org Subject: Re: LIST_HEAD and LIST_ENTRY ? 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: Sat, 20 Mar 2004 11:01:53 -0000 --KJvkvZqQCzHgjKcr Content-Type: text/plain; charset=iso-8859-2 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Sat, Mar 20, 2004 at 11:13:21AM +0100, Soeren Straarup wrote: +>=20 +> How to access in fx struct gprovider provider and consumers ? +> I can't seem to get the picture of how they work. +>=20 +> What i'm trying to get is a picture of what is connected to what. +>=20 +> btw i'm using libgeom.h You can look at /usr/src/sbin/gconcat/gconcat.c concat_list() function for some examples. --=20 Pawel Jakub Dawidek http://www.FreeBSD.org pjd@FreeBSD.org http://garage.freebsd.pl FreeBSD committer Am I Evil? Yes, I Am! --KJvkvZqQCzHgjKcr Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.4 (FreeBSD) iD8DBQFAXCScForvXbEpPzQRAv16AKDlhjpN1mas8FCa7ZBd8jDxaOR2xgCfTKWs nmOFMGA+fqoKddekaYj1ysU= =Bb07 -----END PGP SIGNATURE----- --KJvkvZqQCzHgjKcr--