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