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