parted/parted-1.9.0-appletv-support.patch

199 lines
8.6 KiB
Diff
Raw Normal View History

2009-07-10 13:16:25 +00:00
From fc419e55f358fae46ca24f15f5ce2bc7ff1b9e4a Mon Sep 17 00:00:00 2001
From: Joel Granados Moreno <jgranado@redhat.com>
Date: Thu, 11 Jun 2009 16:06:43 +0200
Subject: [PATCH] Add support for appletv partitions.
---
include/parted/disk.h | 5 ++-
libparted/disk.c | 2 +
libparted/labels/gpt.c | 50 ++++++++++++++++++++++++++++++++++++++---------
3 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/include/parted/disk.h b/include/parted/disk.h
index 691f413..5207e0b 100644
--- a/include/parted/disk.h
+++ b/include/parted/disk.h
@@ -53,10 +53,11 @@ enum _PedPartitionFlag {
PED_PARTITION_PALO=9,
PED_PARTITION_PREP=10,
PED_PARTITION_MSFT_RESERVED=11,
- PED_PARTITION_BIOS_GRUB=12
+ PED_PARTITION_BIOS_GRUB=12,
+ PED_PARTITION_APPLE_TV_RECOVERY=13
};
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_BIOS_GRUB
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_APPLE_TV_RECOVERY
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
diff --git a/libparted/disk.c b/libparted/disk.c
index 5fb8060..3269b9d 100644
--- a/libparted/disk.c
+++ b/libparted/disk.c
@@ -2246,6 +2246,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
return N_("prep");
case PED_PARTITION_MSFT_RESERVED:
return N_("msftres");
+ case PED_PARTITION_APPLE_TV_RECOVERY:
+ return N_("atvrecv");
default:
ped_exception_throw (
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
index 536e06a..73bdbb2 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -127,6 +127,10 @@ typedef struct {
((efi_guid_t) { PED_CPU_TO_LE32 (0x48465300), PED_CPU_TO_LE16 (0x0000), \
PED_CPU_TO_LE16 (0x11AA), 0xaa, 0x11, \
{ 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC }})
+#define PARTITION_APPLE_TV_RECOVERY_GUID \
+ ((efi_guid_t) { PED_CPU_TO_LE32 (0x5265636F), PED_CPU_TO_LE16 (0x7665), \
+ PED_CPU_TO_LE16 (0x11AA), 0xaa, 0x11, \
+ { 0x00, 0x30, 0x65, 0x43, 0xEC, 0xAC }})
struct __attribute__ ((packed)) _GuidPartitionTableHeader_t {
uint64_t Signature;
@@ -254,6 +258,7 @@ typedef struct _GPTPartitionData {
int hp_service;
int hidden;
int msftres;
+ int atvrecv;
} GPTPartitionData;
static PedDiskType gpt_disk_type;
@@ -768,7 +773,7 @@ _parse_part_entry (PedDisk* disk, GuidPartitionEntry_t* pte)
gpt_part_data->lvm = gpt_part_data->raid
= gpt_part_data->boot = gpt_part_data->hp_service
= gpt_part_data->hidden = gpt_part_data->msftres
- = gpt_part_data->bios_grub = 0;
+ = gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0;
if (pte->Attributes.RequiredToFunction & 0x1)
gpt_part_data->hidden = 1;
@@ -783,9 +788,11 @@ _parse_part_entry (PedDisk* disk, GuidPartitionEntry_t* pte)
gpt_part_data->lvm = 1;
else if (!guid_cmp (gpt_part_data->type, PARTITION_HPSERVICE_GUID))
gpt_part_data->hp_service = 1;
- else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID))
- gpt_part_data->msftres = 1;
-
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_MSFT_RESERVED_GUID))
+ gpt_part_data->msftres = 1;
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_APPLE_TV_RECOVERY_GUID))
+ gpt_part_data->atvrecv = 1;
+
return part;
}
@@ -1182,6 +1189,7 @@ gpt_partition_new (const PedDisk* disk,
gpt_part_data->hp_service = 0;
gpt_part_data->hidden = 0;
gpt_part_data->msftres = 0;
+ gpt_part_data->atvrecv = 0;
uuid_generate ((unsigned char*) &gpt_part_data->uuid);
swap_uuid_and_efi_guid((unsigned char*)(&gpt_part_data->uuid));
memset (gpt_part_data->name, 0, sizeof gpt_part_data->name);
@@ -1269,6 +1277,11 @@ gpt_partition_set_system (PedPartition* part, const PedFileSystemType* fs_type)
gpt_part_data->type = PARTITION_MSFT_RESERVED_GUID;
return 1;
}
+ if (gpt_part_data->atvrecv) {
+ gpt_part_data->type = PARTITION_APPLE_TV_RECOVERY_GUID;
+ return 1;
+ }
+
if (fs_type) {
if (strncmp (fs_type->name, "fat", 3) == 0
@@ -1361,7 +1374,8 @@ gpt_partition_set_flag(PedPartition *part,
= gpt_part_data->lvm
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
- = gpt_part_data->msftres = 0;
+ = gpt_part_data->msftres
+ = gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_BIOS_GRUB:
gpt_part_data->bios_grub = state;
@@ -1370,7 +1384,8 @@ gpt_partition_set_flag(PedPartition *part,
= gpt_part_data->lvm
= gpt_part_data->boot
= gpt_part_data->hp_service
- = gpt_part_data->msftres = 0;
+ = gpt_part_data->msftres
+ = gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_RAID:
gpt_part_data->raid = state;
@@ -1379,7 +1394,8 @@ gpt_partition_set_flag(PedPartition *part,
= gpt_part_data->lvm
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
- = gpt_part_data->msftres = 0;
+ = gpt_part_data->msftres
+ = gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_LVM:
gpt_part_data->lvm = state;
@@ -1388,7 +1404,8 @@ gpt_partition_set_flag(PedPartition *part,
= gpt_part_data->raid
= gpt_part_data->bios_grub
= gpt_part_data->hp_service
- = gpt_part_data->msftres = 0;
+ = gpt_part_data->msftres
+ = gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_HPSERVICE:
gpt_part_data->hp_service = state;
@@ -1397,7 +1414,8 @@ gpt_partition_set_flag(PedPartition *part,
= gpt_part_data->raid
= gpt_part_data->lvm
= gpt_part_data->bios_grub
- = gpt_part_data->msftres = 0;
+ = gpt_part_data->msftres
+ = gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
case PED_PARTITION_MSFT_RESERVED:
gpt_part_data->msftres = state;
@@ -1406,8 +1424,17 @@ gpt_partition_set_flag(PedPartition *part,
= gpt_part_data->raid
= gpt_part_data->lvm
= gpt_part_data->bios_grub
- = gpt_part_data->hp_service = 0;
+ = gpt_part_data->hp_service
+ = gpt_part_data->atvrecv = 0;
return gpt_partition_set_system (part, part->fs_type);
+ case PED_PARTITION_APPLE_TV_RECOVERY:
+ gpt_part_data->atvrecv = state;
+ if (state)
+ gpt_part_data->boot
+ = gpt_part_data->raid
+ = gpt_part_data->lvm
+ = gpt_part_data->hp_service
+ = gpt_part_data->msftres = 0;
case PED_PARTITION_HIDDEN:
gpt_part_data->hidden = state;
return 1;
@@ -1440,6 +1467,8 @@ gpt_partition_get_flag(const PedPartition *part, PedPartitionFlag flag)
return gpt_part_data->hp_service;
case PED_PARTITION_MSFT_RESERVED:
return gpt_part_data->msftres;
+ case PED_PARTITION_APPLE_TV_RECOVERY:
+ return gpt_part_data->atvrecv;
case PED_PARTITION_HIDDEN:
return gpt_part_data->hidden;
case PED_PARTITION_SWAP:
@@ -1462,6 +1491,7 @@ gpt_partition_is_flag_available(const PedPartition * part,
case PED_PARTITION_BIOS_GRUB:
case PED_PARTITION_HPSERVICE:
case PED_PARTITION_MSFT_RESERVED:
+ case PED_PARTITION_APPLE_TV_RECOVERY:
case PED_PARTITION_HIDDEN:
return 1;
case PED_PARTITION_SWAP:
--
1.6.0.6