249 lines
9.9 KiB
Diff
249 lines
9.9 KiB
Diff
|
From e5fe9328c890a266544a7ef0d272150519fdfc5d Mon Sep 17 00:00:00 2001
|
||
|
From: "Brian C. Lane" <bcl@redhat.com>
|
||
|
Date: Fri, 20 Dec 2019 10:52:35 -0800
|
||
|
Subject: [PATCH 7/7] libparted: Add support for bls_boot to GPT disks
|
||
|
|
||
|
This sets the partition GUID to bc13c2ff-59e6-4262-a352-b275fd6f7172 to
|
||
|
indicate that the partition is a Boot Loader Specification compatible
|
||
|
/boot partition.
|
||
|
---
|
||
|
doc/parted.texi | 4 ++++
|
||
|
include/parted/disk.in.h | 5 +++--
|
||
|
libparted/disk.c | 2 ++
|
||
|
libparted/labels/gpt.c | 47 +++++++++++++++++++++++++++++++++++++++-
|
||
|
4 files changed, 55 insertions(+), 3 deletions(-)
|
||
|
|
||
|
diff --git a/doc/parted.texi b/doc/parted.texi
|
||
|
index f983d2c..213fc84 100644
|
||
|
--- a/doc/parted.texi
|
||
|
+++ b/doc/parted.texi
|
||
|
@@ -844,6 +844,10 @@ GRUB BIOS partition.
|
||
|
(GPT) - this flag is used to tell special purpose software that the GPT
|
||
|
partition may be bootable.
|
||
|
|
||
|
+@item bls_boot
|
||
|
+(MS-DOS, GPT) - Enable this to indicate that the selected partition is a
|
||
|
+Linux Boot Loader Specification compatible /boot partition.
|
||
|
+
|
||
|
@item boot
|
||
|
(Mac, MS-DOS, PC98) - should be enabled if you want to boot off the
|
||
|
partition. The semantics vary between disk labels. For MS-DOS disk
|
||
|
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
|
||
|
index b257c27..fadb995 100644
|
||
|
--- a/include/parted/disk.in.h
|
||
|
+++ b/include/parted/disk.in.h
|
||
|
@@ -76,10 +76,11 @@ enum _PedPartitionFlag {
|
||
|
PED_PARTITION_MSFT_DATA=16,
|
||
|
PED_PARTITION_IRST=17,
|
||
|
PED_PARTITION_ESP=18,
|
||
|
- PED_PARTITION_CHROMEOS_KERNEL=19
|
||
|
+ PED_PARTITION_CHROMEOS_KERNEL=19,
|
||
|
+ PED_PARTITION_BLS_BOOT=20
|
||
|
};
|
||
|
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
|
||
|
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_CHROMEOS_KERNEL
|
||
|
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_BLS_BOOT
|
||
|
|
||
|
enum _PedDiskTypeFeature {
|
||
|
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
|
||
|
diff --git a/libparted/disk.c b/libparted/disk.c
|
||
|
index d1f1077..099837b 100644
|
||
|
--- a/libparted/disk.c
|
||
|
+++ b/libparted/disk.c
|
||
|
@@ -2409,6 +2409,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
|
||
|
return N_("esp");
|
||
|
case PED_PARTITION_CHROMEOS_KERNEL:
|
||
|
return N_("chromeos_kernel");
|
||
|
+ case PED_PARTITION_BLS_BOOT:
|
||
|
+ return N_("bls_boot");
|
||
|
|
||
|
default:
|
||
|
ped_exception_throw (
|
||
|
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
|
||
|
index b8b58cd..93f7add 100644
|
||
|
--- a/libparted/labels/gpt.c
|
||
|
+++ b/libparted/labels/gpt.c
|
||
|
@@ -160,6 +160,10 @@ typedef struct
|
||
|
((efi_guid_t) { PED_CPU_TO_LE32 (0xfe3a2a5d), PED_CPU_TO_LE16 (0x4f32), \
|
||
|
PED_CPU_TO_LE16 (0x41a7), 0xb7, 0x25, \
|
||
|
{ 0xac, 0xcc, 0x32, 0x85, 0xa3, 0x09 }})
|
||
|
+#define PARTITION_BLS_BOOT_GUID \
|
||
|
+ ((efi_guid_t) { PED_CPU_TO_LE32 (0xbc13c2ff), PED_CPU_TO_LE16 (0x59e6), \
|
||
|
+ PED_CPU_TO_LE16 (0x4262), 0xa3, 0x52, \
|
||
|
+ { 0xb2, 0x75, 0xfd, 0x6f, 0x71, 0x72 }})
|
||
|
|
||
|
struct __attribute__ ((packed)) _GuidPartitionTableHeader_t
|
||
|
{
|
||
|
@@ -308,6 +312,7 @@ typedef struct _GPTPartitionData
|
||
|
int prep;
|
||
|
int irst;
|
||
|
int chromeos_kernel;
|
||
|
+ int bls_boot;
|
||
|
} GPTPartitionData;
|
||
|
|
||
|
static PedDiskType gpt_disk_type;
|
||
|
@@ -832,6 +837,7 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
|
||
|
= gpt_part_data->prep
|
||
|
= gpt_part_data->irst
|
||
|
= gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->bls_boot
|
||
|
= gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0;
|
||
|
|
||
|
if (pte->Attributes.RequiredToFunction & 0x1)
|
||
|
@@ -865,6 +871,8 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte)
|
||
|
gpt_part_data->irst = 1;
|
||
|
else if (!guid_cmp (gpt_part_data->type, PARTITION_CHROMEOS_KERNEL_GUID))
|
||
|
gpt_part_data->chromeos_kernel = 1;
|
||
|
+ else if (!guid_cmp (gpt_part_data->type, PARTITION_BLS_BOOT_GUID))
|
||
|
+ gpt_part_data->bls_boot = 1;
|
||
|
|
||
|
return part;
|
||
|
}
|
||
|
@@ -1386,6 +1394,7 @@ gpt_partition_new (const PedDisk *disk,
|
||
|
gpt_part_data->translated_name = 0;
|
||
|
gpt_part_data->irst = 0;
|
||
|
gpt_part_data->chromeos_kernel = 0;
|
||
|
+ gpt_part_data->bls_boot = 0;
|
||
|
uuid_generate ((unsigned char *) &gpt_part_data->uuid);
|
||
|
swap_uuid_and_efi_guid (&gpt_part_data->uuid);
|
||
|
memset (gpt_part_data->name, 0, sizeof gpt_part_data->name);
|
||
|
@@ -1521,6 +1530,11 @@ gpt_partition_set_system (PedPartition *part,
|
||
|
gpt_part_data->type = PARTITION_CHROMEOS_KERNEL_GUID;
|
||
|
return 1;
|
||
|
}
|
||
|
+ if (gpt_part_data->bls_boot)
|
||
|
+ {
|
||
|
+ gpt_part_data->type = PARTITION_BLS_BOOT_GUID;
|
||
|
+ return 1;
|
||
|
+ }
|
||
|
|
||
|
if (fs_type)
|
||
|
{
|
||
|
@@ -1668,6 +1682,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
||
|
= gpt_part_data->prep
|
||
|
= gpt_part_data->irst
|
||
|
= gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->bls_boot
|
||
|
= gpt_part_data->atvrecv = 0;
|
||
|
return gpt_partition_set_system (part, part->fs_type);
|
||
|
case PED_PARTITION_BIOS_GRUB:
|
||
|
@@ -1684,6 +1699,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
||
|
= gpt_part_data->prep
|
||
|
= gpt_part_data->irst
|
||
|
= gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->bls_boot
|
||
|
= gpt_part_data->atvrecv = 0;
|
||
|
return gpt_partition_set_system (part, part->fs_type);
|
||
|
case PED_PARTITION_RAID:
|
||
|
@@ -1700,6 +1716,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
||
|
= gpt_part_data->prep
|
||
|
= gpt_part_data->irst
|
||
|
= gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->bls_boot
|
||
|
= gpt_part_data->atvrecv = 0;
|
||
|
return gpt_partition_set_system (part, part->fs_type);
|
||
|
case PED_PARTITION_LVM:
|
||
|
@@ -1716,6 +1733,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
||
|
= gpt_part_data->prep
|
||
|
= gpt_part_data->irst
|
||
|
= gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->bls_boot
|
||
|
= gpt_part_data->atvrecv = 0;
|
||
|
return gpt_partition_set_system (part, part->fs_type);
|
||
|
case PED_PARTITION_SWAP:
|
||
|
@@ -1732,6 +1750,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
||
|
= gpt_part_data->prep
|
||
|
= gpt_part_data->irst
|
||
|
= gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->bls_boot
|
||
|
= gpt_part_data->atvrecv = 0;
|
||
|
return gpt_partition_set_system (part, part->fs_type);
|
||
|
case PED_PARTITION_HPSERVICE:
|
||
|
@@ -1748,6 +1767,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
||
|
= gpt_part_data->prep
|
||
|
= gpt_part_data->irst
|
||
|
= gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->bls_boot
|
||
|
= gpt_part_data->atvrecv = 0;
|
||
|
return gpt_partition_set_system (part, part->fs_type);
|
||
|
case PED_PARTITION_MSFT_RESERVED:
|
||
|
@@ -1764,6 +1784,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
||
|
= gpt_part_data->prep
|
||
|
= gpt_part_data->irst
|
||
|
= gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->bls_boot
|
||
|
= gpt_part_data->atvrecv = 0;
|
||
|
return gpt_partition_set_system (part, part->fs_type);
|
||
|
case PED_PARTITION_MSFT_DATA:
|
||
|
@@ -1780,6 +1801,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
||
|
= gpt_part_data->prep
|
||
|
= gpt_part_data->irst
|
||
|
= gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->bls_boot
|
||
|
= gpt_part_data->atvrecv = 0;
|
||
|
gpt_part_data->msftdata = 1;
|
||
|
} else {
|
||
|
@@ -1830,6 +1852,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
||
|
= gpt_part_data->irst
|
||
|
= gpt_part_data->atvrecv
|
||
|
= gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->bls_boot
|
||
|
= gpt_part_data->msftrecv = 0;
|
||
|
return gpt_partition_set_system (part, part->fs_type);
|
||
|
case PED_PARTITION_IRST:
|
||
|
@@ -1846,6 +1869,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
||
|
= gpt_part_data->msftrecv
|
||
|
= gpt_part_data->prep
|
||
|
= gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->bls_boot
|
||
|
= gpt_part_data->atvrecv = 0;
|
||
|
return gpt_partition_set_system (part, part->fs_type);
|
||
|
case PED_PARTITION_CHROMEOS_KERNEL:
|
||
|
@@ -1862,7 +1886,25 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
||
|
= gpt_part_data->msftrecv
|
||
|
= gpt_part_data->atvrecv
|
||
|
= gpt_part_data->prep
|
||
|
- = gpt_part_data->irst = 0;
|
||
|
+ = gpt_part_data->irst
|
||
|
+ = gpt_part_data->bls_boot = 0;
|
||
|
+ return gpt_partition_set_system (part, part->fs_type);
|
||
|
+ case PED_PARTITION_BLS_BOOT:
|
||
|
+ gpt_part_data->bls_boot = state;
|
||
|
+ if (state)
|
||
|
+ gpt_part_data->boot
|
||
|
+ = gpt_part_data->raid
|
||
|
+ = gpt_part_data->lvm
|
||
|
+ = gpt_part_data->swap
|
||
|
+ = gpt_part_data->bios_grub
|
||
|
+ = gpt_part_data->hp_service
|
||
|
+ = gpt_part_data->msftres
|
||
|
+ = gpt_part_data->msftdata
|
||
|
+ = gpt_part_data->msftrecv
|
||
|
+ = gpt_part_data->prep
|
||
|
+ = gpt_part_data->irst
|
||
|
+ = gpt_part_data->chromeos_kernel
|
||
|
+ = gpt_part_data->atvrecv = 0;
|
||
|
return gpt_partition_set_system (part, part->fs_type);
|
||
|
case PED_PARTITION_HIDDEN:
|
||
|
gpt_part_data->hidden = state;
|
||
|
@@ -1914,6 +1956,8 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
|
||
|
return gpt_part_data->prep;
|
||
|
case PED_PARTITION_IRST:
|
||
|
return gpt_part_data->irst;
|
||
|
+ case PED_PARTITION_BLS_BOOT:
|
||
|
+ return gpt_part_data->bls_boot;
|
||
|
case PED_PARTITION_SWAP:
|
||
|
return gpt_part_data->swap;
|
||
|
case PED_PARTITION_CHROMEOS_KERNEL:
|
||
|
@@ -1948,6 +1992,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
|
||
|
case PED_PARTITION_IRST:
|
||
|
case PED_PARTITION_ESP:
|
||
|
case PED_PARTITION_CHROMEOS_KERNEL:
|
||
|
+ case PED_PARTITION_BLS_BOOT:
|
||
|
return 1;
|
||
|
case PED_PARTITION_ROOT:
|
||
|
case PED_PARTITION_LBA:
|
||
|
--
|
||
|
2.24.1
|
||
|
|