05ad79
diff -up util-linux-2.23.2/libblkid/src/partitions/gpt.c.kzak util-linux-2.23.2/libblkid/src/partitions/gpt.c
05ad79
--- util-linux-2.23.2/libblkid/src/partitions/gpt.c.kzak	2013-07-30 10:39:26.206738239 +0200
05ad79
+++ util-linux-2.23.2/libblkid/src/partitions/gpt.c	2014-01-23 11:06:17.364011293 +0100
05ad79
@@ -156,13 +156,15 @@ static int last_lba(blkid_probe pr, uint
05ad79
  * Note that the PMBR detection is optional (enabled by default) and could be
05ad79
  * disabled by BLKID_PARTS_FOPCE_GPT flag (see also blkid_paertitions_set_flags()).
05ad79
  */
05ad79
-static int is_pmbr_valid(blkid_probe pr)
05ad79
+static int is_pmbr_valid(blkid_probe pr, int *has)
05ad79
 {
05ad79
 	int flags = blkid_partitions_get_flags(pr);
05ad79
 	unsigned char *data;
05ad79
 	struct dos_partition *p;
05ad79
 	int i;
05ad79
 
05ad79
+	if (has)
05ad79
+		*has = 0;
05ad79
 	if (flags & BLKID_PARTS_FORCE_GPT)
05ad79
 		goto ok;			/* skip PMBR check */
05ad79
 
05ad79
@@ -182,6 +184,8 @@ static int is_pmbr_valid(blkid_probe pr)
05ad79
 failed:
05ad79
 	return 0;
05ad79
 ok:
05ad79
+	if (has)
05ad79
+		*has = 1;
05ad79
 	return 1;
05ad79
 }
05ad79
 
05ad79
@@ -305,7 +309,7 @@ static int probe_gpt_pt(blkid_probe pr,
05ad79
 	if (last_lba(pr, &lastlba))
05ad79
 		goto nothing;
05ad79
 
05ad79
-	if (!is_pmbr_valid(pr))
05ad79
+	if (!is_pmbr_valid(pr, NULL))
05ad79
 		goto nothing;
05ad79
 
05ad79
 	h = get_gpt_header(pr, &hdr, &e, (lba = GPT_PRIMARY_LBA), lastlba);
05ad79
@@ -410,3 +414,39 @@ const struct blkid_idinfo gpt_pt_idinfo
05ad79
 	.magics		= BLKID_NONE_MAGIC
05ad79
 };
05ad79
 
05ad79
+
05ad79
+
05ad79
+/* probe for *alone* protective MBR */
05ad79
+static int probe_pmbr_pt(blkid_probe pr,
05ad79
+		const struct blkid_idmag *mag __attribute__((__unused__)))
05ad79
+{
05ad79
+	int has = 0;
05ad79
+	struct gpt_entry *e;
05ad79
+	uint64_t lastlba = 0;
05ad79
+	struct gpt_header hdr;
05ad79
+
05ad79
+	if (last_lba(pr, &lastlba))
05ad79
+		goto nothing;
05ad79
+
05ad79
+	is_pmbr_valid(pr, &has;;
05ad79
+	if (!has)
05ad79
+		goto nothing;
05ad79
+
05ad79
+	if (!get_gpt_header(pr, &hdr, &e, GPT_PRIMARY_LBA, lastlba) &&
05ad79
+	    !get_gpt_header(pr, &hdr, &e, lastlba, lastlba))
05ad79
+		return 0;
05ad79
+nothing:
05ad79
+	return 1;
05ad79
+}
05ad79
+
05ad79
+const struct blkid_idinfo pmbr_pt_idinfo =
05ad79
+{
05ad79
+	.name		= "PMBR",
05ad79
+	.probefunc	= probe_pmbr_pt,
05ad79
+	.magics		=
05ad79
+	{
05ad79
+		{ .magic = "\x55\xAA", .len = 2, .sboff = 510 },
05ad79
+		{ NULL }
05ad79
+	}
05ad79
+};
05ad79
+
05ad79
diff -up util-linux-2.23.2/libblkid/src/partitions/partitions.c.kzak util-linux-2.23.2/libblkid/src/partitions/partitions.c
05ad79
--- util-linux-2.23.2/libblkid/src/partitions/partitions.c.kzak	2013-07-30 10:39:26.207738249 +0200
05ad79
+++ util-linux-2.23.2/libblkid/src/partitions/partitions.c	2014-01-23 11:06:17.364011293 +0100
05ad79
@@ -125,6 +125,7 @@ static const struct blkid_idinfo *idinfo
05ad79
 	&sun_pt_idinfo,
05ad79
 	&dos_pt_idinfo,
05ad79
 	&gpt_pt_idinfo,
05ad79
+	&pmbr_pt_idinfo,	/* always after GPT */
05ad79
 	&mac_pt_idinfo,
05ad79
 	&ultrix_pt_idinfo,
05ad79
 	&bsd_pt_idinfo,
05ad79
diff -up util-linux-2.23.2/libblkid/src/partitions/partitions.h.kzak util-linux-2.23.2/libblkid/src/partitions/partitions.h
05ad79
--- util-linux-2.23.2/libblkid/src/partitions/partitions.h.kzak	2013-07-30 10:39:26.208738259 +0200
05ad79
+++ util-linux-2.23.2/libblkid/src/partitions/partitions.h	2014-01-23 11:06:17.364011293 +0100
05ad79
@@ -59,6 +59,7 @@ extern const struct blkid_idinfo mac_pt_
05ad79
 extern const struct blkid_idinfo dos_pt_idinfo;
05ad79
 extern const struct blkid_idinfo minix_pt_idinfo;
05ad79
 extern const struct blkid_idinfo gpt_pt_idinfo;
05ad79
+extern const struct blkid_idinfo pmbr_pt_idinfo;
05ad79
 extern const struct blkid_idinfo ultrix_pt_idinfo;
05ad79
 
05ad79
 #endif /* BLKID_PARTITIONS_H */