Re: geom bsd strangeness in extended partition

From: Valentin Nechayev <netch_at_netch.kiev.ua>
Date: Wed, 31 Dec 2003 17:32:49 +0200
 Tue, Dec 30, 2003 at 00:52:33, phk (Poul-Henning Kamp) wrote about "Re: geom bsd strangeness in extended partition": 

>>GEOM issues warnings during scanning bsdlabels in extended partition:
PHK> This is a bug and I know what it is.  I'll get back to you with
PHK> a patch sometimes in january.

Well, the attached patch is seems to be dirty, but fixed it for me.
I don't understand why multiple customers are allowed for g_geom, so get
one of them which leads to parent MBR.
Some variables may be unused because I omit debug print from final patch.


-netch-

--- geom/geom_mbr.c	Mon Sep  1 23:45:32 2003
+++ geom.1/geom_mbr.c	Wed Dec 31 17:22:10 2003
_at__at_ -299,6 +299,29 _at__at_
 	mp = gsp->softc;
 	if (bp->bio_cmd == BIO_GETATTR) {
 		if (g_handleattr_int(bp, "MBR::type", mp->type[idx]))
+			return (1);
+		off_t ro, off2;
+		struct g_consumer *pcons;
+		struct g_provider *pp2;
+		struct g_geom *gp2;
+		struct g_slicer *gsp2;
+		//struct g_mbr_softc *mp2;
+		/* Add MBR::offset of MBR in parent geom */
+		ro = gsp->slices[idx].offset;
+		LIST_FOREACH(pcons, &gp->consumer, consumer) {
+			if (!(pp2 = pcons->provider) ||
+			    !(gp2 = pp2->geom) ||
+			    !gp2->class ||
+			    strcmp(gp2->class->name, MBR_CLASS_NAME))
+				continue;
+			gsp2 = gp2->softc;
+			off2 = gsp2->slices[pp2->index].offset;
+			ro += off2;
+			break;
+		}
+		if (g_handleattr_off_t(bp, "MBR::offset", ro))
+			return (1);
+		if (g_handleattr_off_t(bp, "MBR::offset", ro))
 			return (1);
 	}
 	return (0);
Received on Wed Dec 31 2003 - 06:35:55 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:37:36 UTC