parted/0005-gpt-fix-endianness-bug-in-gpt_get_max_supported_part.patch
Brian C. Lane a248769183 - Rebasing Fedora patches with upstream master since v3.1 release
- Summary of important changes from upstream:
  - add support for a new Linux-specific GPT partition type code
  - partprobe: remove partitions when there is no partition table
  - libparted: refactor device-mapper partition sync code
  - libparted: remove extraneous blkpg add partition ped exception
  - libparted: don't probe every dm device in probe_all
- New Fedora changes:
  - libparted: Add Intel Rapid Start Technology partition flag.
  - libparted: Add UEFI System Partition flag.
  - libparted: Add hfs_esp partition flag to GPT.
  - libparted: Recognize btrfs filesystem
  - tests: Add btrfs and xfs to the fs probe test
2013-08-28 13:55:15 -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/69] 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.3.1