forked from pool/parted
This commit is contained in:
parent
ba434769ac
commit
1a965977aa
@ -2,48 +2,19 @@ Index: libparted/labels/gpt.c
|
|||||||
===================================================================
|
===================================================================
|
||||||
--- libparted/labels/gpt.c.orig
|
--- libparted/labels/gpt.c.orig
|
||||||
+++ libparted/labels/gpt.c
|
+++ libparted/labels/gpt.c
|
||||||
@@ -46,6 +46,8 @@
|
@@ -46,6 +46,11 @@
|
||||||
# define _(String) (String)
|
# define _(String) (String)
|
||||||
#endif /* ENABLE_NLS */
|
#endif /* ENABLE_NLS */
|
||||||
|
|
||||||
|
+/* IA64 always has a properly working EFI implementation */
|
||||||
|
+#ifndef __ia64__
|
||||||
+#define GPT_SYNC_MBR
|
+#define GPT_SYNC_MBR
|
||||||
|
+#endif
|
||||||
+
|
+
|
||||||
#define EFI_PMBR_OSTYPE_EFI 0xEE
|
#define EFI_PMBR_OSTYPE_EFI 0xEE
|
||||||
#define MSDOS_MBR_SIGNATURE 0xaa55
|
#define MSDOS_MBR_SIGNATURE 0xaa55
|
||||||
|
|
||||||
@@ -402,6 +404,7 @@ guid_cmp (efi_guid_t left, efi_guid_t ri
|
@@ -928,15 +933,66 @@ error:
|
||||||
return memcmp(&left, &right, sizeof(efi_guid_t));
|
|
||||||
}
|
|
||||||
|
|
||||||
+#ifndef GPT_SYNC_MBR
|
|
||||||
/* checks if 'mbr' is a protective MBR partition table */
|
|
||||||
static inline int
|
|
||||||
_pmbr_is_valid (const LegacyMBR_t* mbr)
|
|
||||||
@@ -418,6 +421,7 @@ _pmbr_is_valid (const LegacyMBR_t* mbr)
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
+#endif
|
|
||||||
|
|
||||||
static int
|
|
||||||
gpt_probe (const PedDevice * dev)
|
|
||||||
@@ -445,6 +449,7 @@ gpt_probe (const PedDevice * dev)
|
|
||||||
if (!gpt_sig_found)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
+#ifndef GPT_SYNC_MBR
|
|
||||||
if (ped_device_read(dev, &legacy_mbr, 0, GPT_HEADER_SECTORS)) {
|
|
||||||
if (!_pmbr_is_valid (&legacy_mbr)) {
|
|
||||||
int ex_status = ped_exception_throw (
|
|
||||||
@@ -463,6 +468,7 @@ gpt_probe (const PedDevice * dev)
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
+#endif
|
|
||||||
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
@@ -928,15 +934,51 @@ error:
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,6 +32,21 @@ Index: libparted/labels/gpt.c
|
|||||||
+ return 0x83; // Everything else is Linux
|
+ return 0x83; // Everything else is Linux
|
||||||
+}
|
+}
|
||||||
+
|
+
|
||||||
|
+static inline PedPartition*
|
||||||
|
+_find_first_part (PedDisk* disk)
|
||||||
|
+{
|
||||||
|
+ PedPartition *retval = NULL, *part;
|
||||||
|
+ uint64_t lowest_end = 0xffffffffffffffff;
|
||||||
|
+ while (part = ped_disk_next_partition (disk, part)) {
|
||||||
|
+ if (part->geom.start == 0 || part->type == PED_PARTITION_METADATA
|
||||||
|
+ || part->type == PED_PARTITION_FREESPACE)
|
||||||
|
+ continue;
|
||||||
|
+ if (part->geom.end < lowest_end)
|
||||||
|
+ retval = part;
|
||||||
|
+ }
|
||||||
|
+ return retval;
|
||||||
|
+}
|
||||||
|
+
|
||||||
+static inline uint32_t
|
+static inline uint32_t
|
||||||
+_part_32bitmax (uint64_t in)
|
+_part_32bitmax (uint64_t in)
|
||||||
+{
|
+{
|
||||||
@ -80,8 +66,8 @@ Index: libparted/labels/gpt.c
|
|||||||
+ PedDevice * dev = disk->dev;
|
+ PedDevice * dev = disk->dev;
|
||||||
LegacyMBR_t pmbr;
|
LegacyMBR_t pmbr;
|
||||||
+#ifdef GPT_SYNC_MBR
|
+#ifdef GPT_SYNC_MBR
|
||||||
+ int i;
|
+ int i,pmbr_id;
|
||||||
+ PedPartition* part = NULL;
|
+ PedPartition *part = NULL, *esp;
|
||||||
+#endif
|
+#endif
|
||||||
|
|
||||||
+#ifdef GPT_SYNC_MBR
|
+#ifdef GPT_SYNC_MBR
|
||||||
@ -96,18 +82,38 @@ Index: libparted/labels/gpt.c
|
|||||||
pmbr.PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
|
pmbr.PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
|
||||||
pmbr.PartitionRecord[0].StartSector = 1;
|
pmbr.PartitionRecord[0].StartSector = 1;
|
||||||
pmbr.PartitionRecord[0].EndHead = 0xFE;
|
pmbr.PartitionRecord[0].EndHead = 0xFE;
|
||||||
@@ -947,6 +989,31 @@ _write_pmbr (PedDevice * dev)
|
@@ -947,6 +1003,51 @@ _write_pmbr (PedDevice * dev)
|
||||||
pmbr.PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32(0xFFFFFFFF);
|
pmbr.PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32(0xFFFFFFFF);
|
||||||
else
|
else
|
||||||
pmbr.PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32(dev->length - 1UL);
|
pmbr.PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32(dev->length - 1UL);
|
||||||
+#else
|
+#else
|
||||||
+ /* sync the first 4 GPT entries to MBR primary partitions */
|
+ /* Search for an EFI System Partition */
|
||||||
+ for (i=0; i < 4; i++) {
|
+ esp = _find_first_part(disk);
|
||||||
|
+ if (esp && strncmp (esp->fs_type->name, "fat", 3) != 0)
|
||||||
|
+ esp = NULL;
|
||||||
|
+
|
||||||
|
+ pmbr_id = 3;
|
||||||
|
+ if (esp)
|
||||||
|
+ pmbr_id = 0;
|
||||||
|
+
|
||||||
|
+ /* Write a pseudo-PMBR so Linux is happy */
|
||||||
|
+ pmbr.PartitionRecord[pmbr_id].OSType = EFI_PMBR_OSTYPE_EFI;
|
||||||
|
+ pmbr.PartitionRecord[pmbr_id].StartSector = 1;
|
||||||
|
+ pmbr.PartitionRecord[pmbr_id].EndHead = 0xFE;
|
||||||
|
+ pmbr.PartitionRecord[pmbr_id].EndSector = 0xFF;
|
||||||
|
+ pmbr.PartitionRecord[pmbr_id].EndTrack = 0xFF;
|
||||||
|
+ pmbr.PartitionRecord[pmbr_id].StartingLBA = PED_CPU_TO_LE32(1);
|
||||||
|
+ pmbr.PartitionRecord[pmbr_id].SizeInLBA = 1;
|
||||||
|
+ if (esp)
|
||||||
|
+ pmbr.PartitionRecord[pmbr_id].SizeInLBA = esp->geom.end - 1;
|
||||||
|
+
|
||||||
|
+ /* sync the first 3 GPT entries to MBR primary partitions */
|
||||||
|
+ for (i=0; i < 3; i++) {
|
||||||
+ part = ped_disk_next_partition (disk, part);
|
+ part = ped_disk_next_partition (disk, part);
|
||||||
+ if (part == NULL)
|
+ if (part == NULL)
|
||||||
+ break;
|
+ break;
|
||||||
+ /* we might get a starting garbage partition */
|
+ /* we might get a starting garbage partition */
|
||||||
+ if (part->geom.start == 0 || part->type == PED_PARTITION_METADATA || part->type == PED_PARTITION_FREESPACE) {
|
+ if (part->geom.start == 0 || part->type == PED_PARTITION_METADATA || part->type == PED_PARTITION_FREESPACE || part == esp) {
|
||||||
+ i--;
|
+ i--;
|
||||||
+ continue;
|
+ continue;
|
||||||
+ }
|
+ }
|
||||||
@ -128,7 +134,7 @@ Index: libparted/labels/gpt.c
|
|||||||
|
|
||||||
return ped_device_write (dev, &pmbr, GPT_PMBR_LBA, GPT_PMBR_SECTORS);
|
return ped_device_write (dev, &pmbr, GPT_PMBR_LBA, GPT_PMBR_SECTORS);
|
||||||
}
|
}
|
||||||
@@ -1050,7 +1117,7 @@ gpt_write(const PedDisk * disk)
|
@@ -1050,7 +1151,7 @@ gpt_write(const PedDisk * disk)
|
||||||
ptes_crc = efi_crc32 (ptes, ptes_size);
|
ptes_crc = efi_crc32 (ptes, ptes_size);
|
||||||
|
|
||||||
/* Write protective MBR */
|
/* Write protective MBR */
|
||||||
|
@ -1,3 +1,11 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Mon Aug 11 16:27:24 CEST 2008 - agraf@suse.de
|
||||||
|
|
||||||
|
- make GPT sync more compatible:
|
||||||
|
- don't sync on IA64
|
||||||
|
- always add a partition with partition type 0xee, so Linux is happy
|
||||||
|
- protect the EFI System Partition if available
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Jul 22 13:27:27 CEST 2008 - hare@suse.de
|
Tue Jul 22 13:27:27 CEST 2008 - hare@suse.de
|
||||||
|
|
||||||
|
18
parted.spec
18
parted.spec
@ -2,9 +2,16 @@
|
|||||||
# spec file for package parted (Version 1.8.8)
|
# spec file for package parted (Version 1.8.8)
|
||||||
#
|
#
|
||||||
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
# Copyright (c) 2008 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
||||||
# This file and all modifications and additions to the pristine
|
|
||||||
# package are under the same license as the package itself.
|
|
||||||
#
|
#
|
||||||
|
# All modifications and additions to the file contributed by third parties
|
||||||
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
|
# upon. The license for this file, and modifications and additions to the
|
||||||
|
# file, is the same license as for the pristine package itself (unless the
|
||||||
|
# license for the pristine package is not an Open Source License, in which
|
||||||
|
# case the license is the MIT License). An "Open Source License" is a
|
||||||
|
# license that conforms to the Open Source Definition (Version 1.9)
|
||||||
|
# published by the Open Source Initiative.
|
||||||
|
|
||||||
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
# Please submit bugfixes or comments via http://bugs.opensuse.org/
|
||||||
#
|
#
|
||||||
|
|
||||||
@ -18,7 +25,7 @@ License: GPL v2 or later
|
|||||||
Group: System/Filesystems
|
Group: System/Filesystems
|
||||||
Summary: GNU partitioner
|
Summary: GNU partitioner
|
||||||
Version: 1.8.8
|
Version: 1.8.8
|
||||||
Release: 56
|
Release: 65
|
||||||
Source0: %{name}-%{version}.tar.bz2
|
Source0: %{name}-%{version}.tar.bz2
|
||||||
Patch: always-resize-part.dif
|
Patch: always-resize-part.dif
|
||||||
Patch1: parted-type.patch
|
Patch1: parted-type.patch
|
||||||
@ -136,6 +143,11 @@ rm -rf "$RPM_BUILD_ROOT"
|
|||||||
%{_libdir}/*.so
|
%{_libdir}/*.so
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Aug 11 2008 agraf@suse.de
|
||||||
|
- make GPT sync more compatible:
|
||||||
|
- don't sync on IA64
|
||||||
|
- always add a partition with partition type 0xee, so Linux is happy
|
||||||
|
- protect the EFI System Partition if available
|
||||||
* Tue Jul 22 2008 hare@suse.de
|
* Tue Jul 22 2008 hare@suse.de
|
||||||
- Fix fdasd.c compilation
|
- Fix fdasd.c compilation
|
||||||
- Don't include broken inttypes.h
|
- Don't include broken inttypes.h
|
||||||
|
Loading…
x
Reference in New Issue
Block a user