cdown / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

Blame SOURCES/0092-fdisk-print-header-UUID-for-GPT.patch

64664a
From 6f768ec049944ab39c79fcaa7bdf9622385b7672 Mon Sep 17 00:00:00 2001
64664a
From: Karel Zak <kzak@redhat.com>
64664a
Date: Thu, 16 Mar 2017 13:29:50 +0100
64664a
Subject: [PATCH 092/116] fdisk: print header UUID for GPT
64664a
64664a
Addresses: https://bugzilla.redhat.com/show_bug.cgi?id=1344726
64664a
Signed-off-by: Karel Zak <kzak@redhat.com>
64664a
---
64664a
 fdisks/fdisk.c        |  2 ++
64664a
 libfdisk/src/fdiskP.h |  1 +
64664a
 libfdisk/src/gpt.c    | 18 ++++++++++++++++++
64664a
 3 files changed, 21 insertions(+)
64664a
64664a
diff --git a/fdisks/fdisk.c b/fdisks/fdisk.c
64664a
index 0ec9909..974d735 100644
64664a
--- a/fdisks/fdisk.c
64664a
+++ b/fdisks/fdisk.c
64664a
@@ -657,6 +657,8 @@ list_disk_geometry(struct fdisk_context *cxt) {
64664a
 		printf(_("Disk label type: %s\n"), cxt->label->name);
64664a
 	if (fdisk_is_disklabel(cxt, DOS))
64664a
 		dos_print_mbr_id(cxt);
64664a
+	if (fdisk_is_disklabel(cxt, GPT))
64664a
+		gpt_print_header_id(cxt);
64664a
 	printf("\n");
64664a
 }
64664a
 
64664a
diff --git a/libfdisk/src/fdiskP.h b/libfdisk/src/fdiskP.h
64664a
index ce42860..6711ab8 100644
64664a
--- a/libfdisk/src/fdiskP.h
64664a
+++ b/libfdisk/src/fdiskP.h
64664a
@@ -315,6 +315,7 @@ extern void fdisk_deinit_label(struct fdisk_label *lb);
64664a
 
64664a
 /* gpt.c -- temporary bypass library API... */
64664a
 extern void gpt_list_table(struct fdisk_context *cxt, int xtra);
64664a
+extern void gpt_print_header_id(struct fdisk_context *cxt);
64664a
 
64664a
 /* ask.c */
64664a
 extern int fdisk_ask_partnum(struct fdisk_context *cxt, size_t *partnum, int wantnew);
64664a
diff --git a/libfdisk/src/gpt.c b/libfdisk/src/gpt.c
64664a
index d3bdc2d..899e1b2 100644
64664a
--- a/libfdisk/src/gpt.c
64664a
+++ b/libfdisk/src/gpt.c
64664a
@@ -341,6 +341,24 @@ static inline int partition_unused(const struct gpt_entry *e)
64664a
 			sizeof(struct gpt_guid));
64664a
 }
64664a
 
64664a
+void gpt_print_header_id(struct fdisk_context *cxt)
64664a
+{
64664a
+	char str[37];
64664a
+	struct gpt_header *header;
64664a
+	struct fdisk_gpt_label *gpt;
64664a
+
64664a
+	assert(cxt);
64664a
+	assert(cxt->label);
64664a
+	assert(fdisk_is_disklabel(cxt, GPT));
64664a
+
64664a
+	gpt = self_label(cxt);
64664a
+	header = gpt->pheader ? gpt->pheader : gpt->bheader;
64664a
+
64664a
+	guid_to_string(&header->disk_guid, str);
64664a
+
64664a
+	printf("Disk identifier: %s\n", str);
64664a
+}
64664a
+
64664a
 /*
64664a
  * Builds a clean new valid protective MBR - will wipe out any existing data.
64664a
  * Returns 0 on success, otherwise < 0 on error.
64664a
-- 
64664a
2.9.3
64664a