parted/0005-gpt-fix-endianness-bug-in-gpt_get_max_supported_part.patch
Brian C. Lane 0b7af917e2 - Rebase on new upstream master commit cc382c3
- Drop patches incorporated into upstream
- Still adds the various DASD patches
2014-04-08 11:46:37 -07:00

52 lines
1.7 KiB
Diff

From 4ac1c02b590668c93afdb48900e0858de58cda3a Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Fri, 8 Jun 2012 13:19:25 +0100
Subject: [PATCH 05/89] gpt: fix endianness bug in
gpt_get_max_supported_partition_count
* libparted/labels/gpt.c (gpt_get_max_supported_partition_count):
Take endianness of pth->FirstUsableLBA into account (64-bit,
little endian) when calculating the maximum number of partitions.
* NEWS (Bug fixes): Mention it.
---
NEWS | 3 +++
libparted/labels/gpt.c | 4 ++--
2 files changed, 5 insertions(+), 2 deletions(-)
diff --git a/NEWS b/NEWS
index 3969c44..f929b99 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ GNU parted NEWS -*- outline -*-
** Bug Fixes
+ libparted: gpt: fix gpt_get_max_supported_partition_count to work
+ also on little-endian systems.
+
libparted: treat a disk with no pMBR as an msdos-labeled disk
even when it has valid GPT headers.
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 91ad71a..6032e3f 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1785,12 +1785,12 @@ gpt_get_max_supported_partition_count (const PedDisk *disk, int *max_n)
if (!_header_is_valid (disk, pth, 1))
{
- pth->FirstUsableLBA = 34;
+ pth->FirstUsableLBA = PED_CPU_TO_LE64 (34);
pth->SizeOfPartitionEntry
= PED_CPU_TO_LE32 (sizeof (GuidPartitionEntry_t));
}
- *max_n = (disk->dev->sector_size * (pth->FirstUsableLBA - 2)
+ *max_n = (disk->dev->sector_size * (PED_LE64_TO_CPU (pth->FirstUsableLBA) - 2)
/ PED_LE32_TO_CPU (pth->SizeOfPartitionEntry));
pth_free (pth);
return true;
--
1.8.5.3