cdown / rpms / util-linux

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