Only attach to a GPT partition if it has the GPT_ENT_TYPE_FREEBSD type.

XXX: This only works currently with GEOM_GPT which only exists in 6.x.
XXX: I didn't add 'mbroffset' support for a GPT partition holding a BSD
label as I'm not sure if they use relative or absolute offsets.

MFC after:	3 days
This commit is contained in:
John Baldwin 2007-12-06 09:20:27 +00:00
parent b850a685ce
commit f97a705a99

View File

@ -55,6 +55,8 @@ __FBSDID("$FreeBSD$");
#include <sys/md5.h>
#include <sys/errno.h>
#include <sys/disklabel.h>
#include <sys/gpt.h>
#include <sys/uuid.h>
#include <geom/geom.h>
#include <geom/geom_slice.h>
@ -461,6 +463,8 @@ g_bsd_dumpconf(struct sbuf *sb, const char *indent, struct g_geom *gp, struct g_
* not implemented here.
*/
static struct uuid freebsd_slice = GPT_ENT_TYPE_FREEBSD;
static struct g_geom *
g_bsd_taste(struct g_class *mp, struct g_provider *pp, int flags)
{
@ -472,6 +476,7 @@ g_bsd_taste(struct g_class *mp, struct g_provider *pp, int flags)
struct g_slicer *gsp;
u_char hash[16];
MD5_CTX md5sum;
struct uuid uuid;
g_trace(G_T_TOPOLOGY, "bsd_taste(%s,%s)", mp->name, pp->name);
g_topology_assert();
@ -527,6 +532,14 @@ g_bsd_taste(struct g_class *mp, struct g_provider *pp, int flags)
break;
}
/* Same thing if we are inside a GPT */
error = g_getattr("GPT::type", cp, &uuid);
if (!error) {
if (memcmp(&uuid, &freebsd_slice, sizeof(uuid)) != 0 &&
flags == G_TF_NORMAL)
break;
}
/* Get sector size, we need it to read data. */
secsize = cp->provider->sectorsize;
if (secsize < 512)