OBS User unknown 2008-08-21 23:42:38 +00:00 committed by Git OBS Bridge
parent 1a965977aa
commit 14c45bae00
3 changed files with 22 additions and 10 deletions

View File

@ -14,7 +14,7 @@ Index: libparted/labels/gpt.c
#define EFI_PMBR_OSTYPE_EFI 0xEE
#define MSDOS_MBR_SIGNATURE 0xaa55
@@ -928,15 +933,66 @@ error:
@@ -928,15 +933,68 @@ error:
return 0;
}
@ -35,14 +35,16 @@ Index: libparted/labels/gpt.c
+static inline PedPartition*
+_find_first_part (PedDisk* disk)
+{
+ PedPartition *retval = NULL, *part;
+ PedPartition *retval = NULL, *part = NULL;
+ 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)
+ if (part->geom.end < lowest_end) {
+ retval = part;
+ lowest_end = part->geom.end;
+ }
+ }
+ return retval;
+}
@ -66,7 +68,7 @@ Index: libparted/labels/gpt.c
+ PedDevice * dev = disk->dev;
LegacyMBR_t pmbr;
+#ifdef GPT_SYNC_MBR
+ int i,pmbr_id;
+ int i, pmbr_id, first_entry = 0, last_entry = 3;
+ PedPartition *part = NULL, *esp;
+#endif
@ -82,19 +84,22 @@ Index: libparted/labels/gpt.c
pmbr.PartitionRecord[0].OSType = EFI_PMBR_OSTYPE_EFI;
pmbr.PartitionRecord[0].StartSector = 1;
pmbr.PartitionRecord[0].EndHead = 0xFE;
@@ -947,6 +1003,51 @@ _write_pmbr (PedDevice * dev)
@@ -947,6 +1005,54 @@ _write_pmbr (PedDevice * dev)
pmbr.PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32(0xFFFFFFFF);
else
pmbr.PartitionRecord[0].SizeInLBA = PED_CPU_TO_LE32(dev->length - 1UL);
+#else
+ /* Search for an EFI System Partition */
+ esp = _find_first_part(disk);
+ if (esp && strncmp (esp->fs_type->name, "fat", 3) != 0)
+ if (!esp || !esp->fs_type || strncmp (esp->fs_type->name, "fat", 3) != 0)
+ esp = NULL;
+
+ pmbr_id = 3;
+ if (esp)
+ if (esp) {
+ pmbr_id = 0;
+ first_entry = 1;
+ last_entry = 4;
+ }
+
+ /* Write a pseudo-PMBR so Linux is happy */
+ pmbr.PartitionRecord[pmbr_id].OSType = EFI_PMBR_OSTYPE_EFI;
@ -108,7 +113,7 @@ Index: libparted/labels/gpt.c
+ 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++) {
+ for (i=first_entry; i < last_entry; i++) {
+ part = ped_disk_next_partition (disk, part);
+ if (part == NULL)
+ break;
@ -134,7 +139,7 @@ Index: libparted/labels/gpt.c
return ped_device_write (dev, &pmbr, GPT_PMBR_LBA, GPT_PMBR_SECTORS);
}
@@ -1050,7 +1151,7 @@ gpt_write(const PedDisk * disk)
@@ -1050,7 +1156,7 @@ gpt_write(const PedDisk * disk)
ptes_crc = efi_crc32 (ptes, ptes_size);
/* Write protective MBR */

View File

@ -1,3 +1,8 @@
-------------------------------------------------------------------
Thu Aug 21 11:34:51 CEST 2008 - agraf@suse.de
- fix the GPT sync to work properly on Macs
-------------------------------------------------------------------
Mon Aug 11 16:27:24 CEST 2008 - agraf@suse.de

View File

@ -25,7 +25,7 @@ License: GPL v2 or later
Group: System/Filesystems
Summary: GNU partitioner
Version: 1.8.8
Release: 65
Release: 72
Source0: %{name}-%{version}.tar.bz2
Patch: always-resize-part.dif
Patch1: parted-type.patch
@ -143,6 +143,8 @@ rm -rf "$RPM_BUILD_ROOT"
%{_libdir}/*.so
%changelog
* Thu Aug 21 2008 agraf@suse.de
- fix the GPT sync to work properly on Macs
* Mon Aug 11 2008 agraf@suse.de
- make GPT sync more compatible:
- don't sync on IA64