- Correctly handle GPT labels on big endian machines
This commit is contained in:
parent
788f613dc1
commit
128ba94266
60
parted-1.9.0-gpt-big-endian.patch
Normal file
60
parted-1.9.0-gpt-big-endian.patch
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
From d6e9b3bbda5eb565b6031b5620e38cba871c6748 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Jim Meyering <meyering@redhat.com>
|
||||||
|
Date: Tue, 6 Oct 2009 20:10:00 +0200
|
||||||
|
Subject: [PATCH parted 1/3] gpt: don't malfunction on big-endian systems
|
||||||
|
|
||||||
|
Numerous GPT tests would fail when run on e.g., big-endian PPC.
|
||||||
|
* libparted/labels/gpt.c (gpt_read): Now that we use the
|
||||||
|
SizeOfPartitionEntry member, be sure to convert from GPT's
|
||||||
|
little-endian on-disk format to to CPU endianness.
|
||||||
|
This bug was introduced via commit 14cce9b2, 2009-06-10, "gpt:
|
||||||
|
fix gpt_read to read all of the partition entries correctly".
|
||||||
|
* libparted/labels/gpt.c (_header_is_valid): Also convert it here.
|
||||||
|
Add a test to ensure that the partition entry size is no larger
|
||||||
|
than the slightly arbitrary UINT32_MAX/16.
|
||||||
|
* NEWS (Bug fixes): Mention it.
|
||||||
|
---
|
||||||
|
NEWS | 3 +++
|
||||||
|
libparted/labels/gpt.c | 12 +++++++-----
|
||||||
|
2 files changed, 10 insertions(+), 5 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
|
||||||
|
index cc9bcdc..b4549ef 100644
|
||||||
|
--- a/libparted/labels/gpt.c
|
||||||
|
+++ b/libparted/labels/gpt.c
|
||||||
|
@@ -608,8 +608,10 @@ _header_is_valid (const PedDevice* dev, GuidPartitionTableHeader_t* gpt)
|
||||||
|
* the SizeOfPartitionEntry must be a multiple of 8 and
|
||||||
|
* no smaller than the size of the PartitionEntry structure.
|
||||||
|
*/
|
||||||
|
- uint32_t sope = gpt->SizeOfPartitionEntry;
|
||||||
|
- if (sope % 8 != 0 || sope < sizeof(GuidPartitionEntry_t) )
|
||||||
|
+ uint32_t sope = PED_LE32_TO_CPU (gpt->SizeOfPartitionEntry);
|
||||||
|
+ if (sope % 8 != 0
|
||||||
|
+ || sope < sizeof (GuidPartitionEntry_t)
|
||||||
|
+ || (UINT32_MAX >> 4) < sope)
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
origcrc = gpt->HeaderCRC32;
|
||||||
|
@@ -911,7 +913,8 @@ gpt_read (PedDisk * disk)
|
||||||
|
if (!_parse_header (disk, gpt, &write_back))
|
||||||
|
goto error_free_gpt;
|
||||||
|
|
||||||
|
- ptes_sectors = ped_div_round_up (gpt->SizeOfPartitionEntry
|
||||||
|
+ uint32_t p_ent_size = PED_LE32_TO_CPU (gpt->SizeOfPartitionEntry);
|
||||||
|
+ ptes_sectors = ped_div_round_up (p_ent_size
|
||||||
|
* gpt_disk_data->entry_count,
|
||||||
|
disk->dev->sector_size);
|
||||||
|
|
||||||
|
@@ -926,8 +929,7 @@ gpt_read (PedDisk * disk)
|
||||||
|
|
||||||
|
for (i = 0; i < gpt_disk_data->entry_count; i++) {
|
||||||
|
GuidPartitionEntry_t* pte
|
||||||
|
- = (GuidPartitionEntry_t*) ((char *)ptes + i
|
||||||
|
- * gpt->SizeOfPartitionEntry);
|
||||||
|
+ = (GuidPartitionEntry_t*) ((char *)ptes + i * p_ent_size);
|
||||||
|
PedPartition* part;
|
||||||
|
PedConstraint* constraint_exact;
|
||||||
|
|
||||||
|
--
|
||||||
|
1.6.5.rc2
|
||||||
|
|
@ -4,7 +4,7 @@
|
|||||||
Summary: The GNU disk partition manipulation program
|
Summary: The GNU disk partition manipulation program
|
||||||
Name: parted
|
Name: parted
|
||||||
Version: 1.9.0
|
Version: 1.9.0
|
||||||
Release: 15%{?dist}
|
Release: 16%{?dist}
|
||||||
License: GPLv3+
|
License: GPLv3+
|
||||||
Group: Applications/System
|
Group: Applications/System
|
||||||
URL: http://www.gnu.org/software/parted
|
URL: http://www.gnu.org/software/parted
|
||||||
@ -26,6 +26,7 @@ Patch13: %{name}-1.9.0-no-BLKPG.patch
|
|||||||
Patch14: %{name}-1.9.0-commit-without-close.patch
|
Patch14: %{name}-1.9.0-commit-without-close.patch
|
||||||
Patch15: %{name}-1.9.0-dont-touch-part-nodes.patch
|
Patch15: %{name}-1.9.0-dont-touch-part-nodes.patch
|
||||||
Patch16: %{name}-1.9.0-ped_partition_is_busy-no-exception.patch
|
Patch16: %{name}-1.9.0-ped_partition_is_busy-no-exception.patch
|
||||||
|
Patch17: %{name}-1.9.0-gpt-big-endian.patch
|
||||||
|
|
||||||
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
|
||||||
BuildRequires: e2fsprogs-devel
|
BuildRequires: e2fsprogs-devel
|
||||||
@ -79,6 +80,7 @@ Parted library, you need to install this package.
|
|||||||
%patch14 -p1 -b .commit-without-close
|
%patch14 -p1 -b .commit-without-close
|
||||||
%patch15 -p1 -b .dont-touch-part-nodes
|
%patch15 -p1 -b .dont-touch-part-nodes
|
||||||
%patch16 -p1 -b .ped_partition_is_busy
|
%patch16 -p1 -b .ped_partition_is_busy
|
||||||
|
%patch17 -p1 -b .gpt-big-endian
|
||||||
|
|
||||||
|
|
||||||
%build
|
%build
|
||||||
@ -140,6 +142,9 @@ fi
|
|||||||
%{_exec_prefix}/%{_lib}/pkgconfig/libparted.pc
|
%{_exec_prefix}/%{_lib}/pkgconfig/libparted.pc
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Tue Oct 6 2009 Hans de Goede <hdegoede@redhat.com> 1.9.0-16
|
||||||
|
- Correctly handle GPT labels on big endian machines
|
||||||
|
|
||||||
* Tue Oct 6 2009 Hans de Goede <hdegoede@redhat.com> 1.9.0-15
|
* Tue Oct 6 2009 Hans de Goede <hdegoede@redhat.com> 1.9.0-15
|
||||||
- ped_partition_is_busy() should not throw exceptions (#527035)
|
- ped_partition_is_busy() should not throw exceptions (#527035)
|
||||||
- msdos_partition_is_flag_available() should return 1 for swap flag (#513729)
|
- msdos_partition_is_flag_available() should return 1 for swap flag (#513729)
|
||||||
|
Loading…
Reference in New Issue
Block a user