MFC: Only attach to a GPT partition if it has the GPT_ENT_TYPE_FREEBSD
type.
This commit is contained in:
parent
db94b9c1b5
commit
439521b27c
@ -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>
|
||||
|
||||
@ -463,6 +465,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)
|
||||
{
|
||||
@ -474,6 +478,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();
|
||||
@ -529,6 +534,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)
|
||||
|
@ -101,7 +101,23 @@ is_pmbr(char *mbr)
|
||||
static int
|
||||
g_gpt_start(struct bio *bp)
|
||||
{
|
||||
struct g_provider *pp;
|
||||
struct g_geom *gp;
|
||||
struct g_gpt_softc *gs;
|
||||
struct g_slicer *gsp;
|
||||
struct uuid uuid;
|
||||
|
||||
pp = bp->bio_to;
|
||||
gp = pp->geom;
|
||||
gsp = gp->softc;
|
||||
gs = gsp->softc;
|
||||
|
||||
if (bp->bio_cmd == BIO_GETATTR) {
|
||||
le_uuid_dec(&gs->part[pp->index]->ent_type, &uuid);
|
||||
if (g_handleattr(bp, "GPT::type", &uuid, sizeof(uuid)))
|
||||
return (1);
|
||||
}
|
||||
|
||||
return (0);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user