[PATCH] Do tasting for UFS's id and volume only for freebsd-ufs partitions

Andrey V. Elsukov bu7cher at yandex.ru
Sat Jan 22 12:58:47 UTC 2011


Hi All.

I saw several strangest problem reports where UFS labels were
successfully tasted for an inappropriate provider.
So, what you thing about proposed patch?

It add new handled attribute to geom PART class - "PART::type".
It does return partition type for given consumer.
Also it does limit tasting for UFS labels only for "freebsd-ufs"
providers.

-- 
WBR, Andrey V. Elsukov
-------------- next part --------------
Index: head/sys/geom/label/g_label_ufs.c
===================================================================
--- head/sys/geom/label/g_label_ufs.c	(revision 217714)
+++ head/sys/geom/label/g_label_ufs.c	(working copy)
@@ -53,6 +53,7 @@ g_label_ufs_taste_common(struct g_consumer *cp, ch
 	struct g_provider *pp;
 	int sb, superblock;
 	struct fs *fs;
+	char type[64];
 
 	g_topology_assert_not();
 	pp = cp->provider;
@@ -60,6 +61,10 @@ g_label_ufs_taste_common(struct g_consumer *cp, ch
 
 	if (SBLOCKSIZE % cp->provider->sectorsize != 0)
 		return;
+	if (g_getattr("PART::type", cp, &type) != 0)
+		return;
+	if (strcmp(type, "freebsd-ufs") != 0)
+		return;
 
 	/*
 	 * Walk through the standard places that superblocks hide and look
Index: head/sys/geom/part/g_part.c
===================================================================
--- head/sys/geom/part/g_part.c	(revision 217714)
+++ head/sys/geom/part/g_part.c	(working copy)
@@ -1912,6 +1912,7 @@ g_part_start(struct bio *bp)
 	struct g_part_table *table;
 	struct g_kerneldump *gkd;
 	struct g_provider *pp;
+	char buf[64];
 
 	pp = bp->bio_to;
 	gp = pp->geom;
@@ -1960,6 +1961,9 @@ g_part_start(struct bio *bp)
 		if (g_handleattr_str(bp, "PART::scheme",
 		    table->gpt_scheme->name))
 			return;
+		if (g_handleattr_str(bp, "PART::type",
+		    G_PART_TYPE(table, entry, buf, sizeof(buf))))
+			return;
 		if (!strcmp("GEOM::kerneldump", bp->bio_attribute)) {
 			/*
 			 * Check that the partition is suitable for kernel


More information about the freebsd-geom mailing list