Blame SOURCES/0013-Always-refer-to-MBR-and-GPT-fixed-values-as-magic-no.patch

4e0e09
From 62d5bb056e8f9ed4517c460d4d7ea5d51bc8125c Mon Sep 17 00:00:00 2001
4e0e09
From: Peter Jones <pjones@redhat.com>
4e0e09
Date: Wed, 13 Mar 2019 11:01:34 -0400
4e0e09
Subject: [PATCH 13/63] Always refer to MBR and GPT fixed values as 'magic' not
4e0e09
 'signature'
4e0e09
4e0e09
Signed-off-by: Peter Jones <pjones@redhat.com>
4e0e09
---
4e0e09
 src/disk.c |  5 +++--
4e0e09
 src/gpt.c  | 22 +++++++++++-----------
4e0e09
 src/gpt.h  |  8 ++++----
4e0e09
 3 files changed, 18 insertions(+), 17 deletions(-)
4e0e09
4e0e09
diff --git a/src/disk.c b/src/disk.c
4e0e09
index 3efee03b804..519c2a19325 100644
4e0e09
--- a/src/disk.c
4e0e09
+++ b/src/disk.c
4e0e09
@@ -52,10 +52,11 @@ is_mbr_valid(legacy_mbr *mbr)
4e0e09
 	int ret;
4e0e09
 	if (!mbr)
4e0e09
 		return 0;
4e0e09
-	ret = (mbr->signature == MSDOS_MBR_SIGNATURE);
4e0e09
+	ret = (mbr->magic == MSDOS_MBR_MAGIC);
4e0e09
 	if (!ret) {
4e0e09
 		errno = ENOTTY;
4e0e09
-		efi_error("mbr signature is not MSDOS_MBR_SIGNATURE");
4e0e09
+		efi_error("mbr magic is 0x%04hx not MSDOS_MBR_MAGIC (0x%04hx)",
4e0e09
+			  mbr->magic, MSDOS_MBR_MAGIC);
4e0e09
 	}
4e0e09
 	return ret;
4e0e09
 }
4e0e09
diff --git a/src/gpt.c b/src/gpt.c
4e0e09
index ce8e638ab83..7bdb8ad1575 100644
4e0e09
--- a/src/gpt.c
4e0e09
+++ b/src/gpt.c
4e0e09
@@ -72,24 +72,24 @@ efi_crc32(const void *buf, unsigned long len)
4e0e09
  *
4e0e09
  * Description: Returns 1 if PMBR is valid, 0 otherwise.
4e0e09
  * Validity depends on two things:
4e0e09
- *  1) MSDOS signature is in the last two bytes of the MBR
4e0e09
+ *  1) MSDOS magic is in the last two bytes of the MBR
4e0e09
  *  2) One partition of type 0xEE is found
4e0e09
  */
4e0e09
 static int
4e0e09
 is_pmbr_valid(legacy_mbr *mbr)
4e0e09
 {
4e0e09
-	int i, found = 0, signature = 0;
4e0e09
+	int i, found = 0, magic = 0;
4e0e09
 	if (!mbr)
4e0e09
 		return 0;
4e0e09
-	signature = (le16_to_cpu(mbr->signature) == MSDOS_MBR_SIGNATURE);
4e0e09
-	for (i = 0; signature && i < 4; i++) {
4e0e09
+	magic = (le16_to_cpu(mbr->magic) == MSDOS_MBR_MAGIC);
4e0e09
+	for (i = 0; magic && i < 4; i++) {
4e0e09
 		if (mbr->partition[i].os_type ==
4e0e09
 		    EFI_PMBR_OSTYPE_EFI_GPT) {
4e0e09
 			found = 1;
4e0e09
 			break;
4e0e09
 		}
4e0e09
 	}
4e0e09
-	return (signature && found);
4e0e09
+	return (magic && found);
4e0e09
 }
4e0e09
 
4e0e09
 /**
4e0e09
@@ -389,11 +389,11 @@ is_gpt_valid(int fd, uint64_t lba,
4e0e09
 	if (!(*gpt = alloc_read_gpt_header(fd, lba)))
4e0e09
 		return 0;
4e0e09
 
4e0e09
-	/* Check the GUID Partition Table signature */
4e0e09
-	if (le64_to_cpu((*gpt)->signature) != GPT_HEADER_SIGNATURE) {
4e0e09
-		efi_error("GUID Partition Table Header signature is wrong: %"PRIx64" != %"PRIx64,
4e0e09
-			  (uint64_t)le64_to_cpu((*gpt)->signature),
4e0e09
-			  GPT_HEADER_SIGNATURE);
4e0e09
+	/* Check the GUID Partition Table magic */
4e0e09
+	if (le64_to_cpu((*gpt)->magic) != GPT_HEADER_MAGIC) {
4e0e09
+		efi_error("GUID Partition Table Header magic is wrong: %"PRIx64" != %"PRIx64,
4e0e09
+			  (uint64_t)le64_to_cpu((*gpt)->magic),
4e0e09
+			  GPT_HEADER_MAGIC);
4e0e09
 		free(*gpt);
4e0e09
 		*gpt = NULL;
4e0e09
 		return rc;
4e0e09
@@ -673,7 +673,7 @@ find_valid_gpt(int fd, gpt_header ** gpt, gpt_entry ** ptes,
4e0e09
 
4e0e09
 	/* Would fail due to bad PMBR, but force GPT anyhow */
4e0e09
 	if ((good_pgpt || good_agpt) && !good_pmbr && ignore_pmbr_err) {
4e0e09
-		efi_error("  Warning: Disk has a valid GPT signature but invalid PMBR.\n"
4e0e09
+		efi_error("  Warning: Disk has a valid GPT magic but invalid PMBR.\n"
4e0e09
 			  "  Use GNU Parted to correct disk.\n"
4e0e09
 			  "  gpt option taken, disk treated as GPT.");
4e0e09
 	}
4e0e09
diff --git a/src/gpt.h b/src/gpt.h
4e0e09
index 5eb5d1a732c..0d7d5e8a649 100644
4e0e09
--- a/src/gpt.h
4e0e09
+++ b/src/gpt.h
4e0e09
@@ -29,10 +29,10 @@
4e0e09
 
4e0e09
 #define EFI_PMBR_OSTYPE_EFI 0xEF
4e0e09
 #define EFI_PMBR_OSTYPE_EFI_GPT 0xEE
4e0e09
-#define MSDOS_MBR_SIGNATURE 0xaa55
4e0e09
+#define MSDOS_MBR_MAGIC 0xaa55
4e0e09
 #define GPT_BLOCK_SIZE 512
4e0e09
 
4e0e09
-#define GPT_HEADER_SIGNATURE ((uint64_t)(0x5452415020494645ULL))
4e0e09
+#define GPT_HEADER_MAGIC ((uint64_t)(0x5452415020494645ULL))
4e0e09
 #define GPT_HEADER_REVISION_V1_02 0x00010200
4e0e09
 #define GPT_HEADER_REVISION_V1_00 0x00010000
4e0e09
 #define GPT_HEADER_REVISION_V0_99 0x00009900
4e0e09
@@ -61,7 +61,7 @@
4e0e09
                  0x23, 0x8f, 0x2a, 0x3d, 0xf9, 0x28)
4e0e09
 
4e0e09
 typedef struct _gpt_header {
4e0e09
-	uint64_t signature;
4e0e09
+	uint64_t magic;
4e0e09
 	uint32_t revision;
4e0e09
 	uint32_t header_size;
4e0e09
 	uint32_t header_crc32;
4e0e09
@@ -133,7 +133,7 @@ typedef struct _legacy_mbr {
4e0e09
 	uint32_t unique_mbr_signature;
4e0e09
 	uint16_t unknown;
4e0e09
 	partition_record partition[4];
4e0e09
-	uint16_t signature;
4e0e09
+	uint16_t magic;
4e0e09
 } PACKED legacy_mbr;
4e0e09
 
4e0e09
 #define EFI_GPT_PRIMARY_PARTITION_TABLE_LBA 1
4e0e09
-- 
4e0e09
2.26.2
4e0e09