0b7af917e2
- Drop patches incorporated into upstream - Still adds the various DASD patches
242 lines
7.9 KiB
Diff
242 lines
7.9 KiB
Diff
From 6a5b3b5727845af0c5cef35dee3d8e8c69262fdc Mon Sep 17 00:00:00 2001
|
|
From: "Brian C. Lane" <bcl@redhat.com>
|
|
Date: Wed, 11 Sep 2013 12:25:04 -0700
|
|
Subject: [PATCH 76/89] libparted: Add UEFI System Partition flag.
|
|
|
|
This adds support for the ESP partition type on MS-DOS. It also aliases
|
|
it to the boot flag on GPT which sets the ESP GUID type.
|
|
|
|
* NEWS (New Features): Mention it.
|
|
* doc/C/parted.8: Document esp flag.
|
|
* doc/parted.texti: Document esp flag.
|
|
* include/parted/disk.in.h (_PedPartitionFlag): Add PED_PARTITION_ESP flag
|
|
* libparted/disk.c (ped_partition_flag_get_name): Add esp flag
|
|
* libparted/labels/dos.c (DosPartitionData): Likewise
|
|
(raw_part_parse): Likewise
|
|
(msdos_partition_new): Likewise
|
|
(msdos_partition_duplicate): Likewise
|
|
(msdos_partition_set_system): Likewise
|
|
(clear_flags): Likewise
|
|
(msdos_partition_set_flag): Likewise
|
|
(msdos_partition_get_flag): Likewise
|
|
(msdos_partition_is_flag_available): Likewise
|
|
* libparted/labels/gpt.c (gpt_partition_set_flag): Add PED_PARTITION_ESP
|
|
(gpt_partition_get_flag): Likewise
|
|
(gpt_partition_is_flag_available): Likewise
|
|
---
|
|
NEWS | 3 +++
|
|
doc/C/parted.8 | 2 +-
|
|
doc/parted.texi | 4 ++++
|
|
include/parted/disk.in.h | 5 +++--
|
|
libparted/disk.c | 2 ++
|
|
libparted/labels/dos.c | 21 +++++++++++++++++++++
|
|
libparted/labels/gpt.c | 3 +++
|
|
7 files changed, 37 insertions(+), 3 deletions(-)
|
|
|
|
diff --git a/NEWS b/NEWS
|
|
index 27710b6..abb73c6 100644
|
|
--- a/NEWS
|
|
+++ b/NEWS
|
|
@@ -4,6 +4,9 @@ GNU parted NEWS -*- outline -*-
|
|
|
|
** New Features
|
|
|
|
+ Added new partition type flag, esp, to set the type to 0xEF on MS-DOS.
|
|
+ Also aliased to boot on GPT to set the UEFI ESP GUID.
|
|
+
|
|
Added new partition type flag, irst, for use with Intel Rapid Start
|
|
Technology. On MS-DOS disk labels it sets the type to 0x84 and on GPT
|
|
it sets the GUID to D3BFE2DE-3DAF-11DF-BA-40-E3A556D89593.
|
|
diff --git a/doc/C/parted.8 b/doc/C/parted.8
|
|
index 2f8e9f5..f8e6a3d 100644
|
|
--- a/doc/C/parted.8
|
|
+++ b/doc/C/parted.8
|
|
@@ -104,7 +104,7 @@ or an LVM logical volume if necessary.
|
|
.B set \fIpartition\fP \fIflag\fP \fIstate\fP
|
|
Change the state of the \fIflag\fP on \fIpartition\fP to \fIstate\fP.
|
|
Supported flags are: "boot", "root", "swap", "hidden", "raid", "lvm", "lba",
|
|
-"legacy_boot", "irst" and "palo".
|
|
+"legacy_boot", "irst", "esp" and "palo".
|
|
\fIstate\fP should be either "on" or "off".
|
|
.TP
|
|
.B unit \fIunit\fP
|
|
diff --git a/doc/parted.texi b/doc/parted.texi
|
|
index 4c63fe3..9e00808 100644
|
|
--- a/doc/parted.texi
|
|
+++ b/doc/parted.texi
|
|
@@ -840,6 +840,10 @@ filesystems).
|
|
(MS-DOS, GPT) - this flag identifies an Intel Rapid Start Technology
|
|
partition.
|
|
|
|
+@item esp
|
|
+(MS-DOS, GPT) - this flag identifies a UEFI System Partition. On GPT
|
|
+it is an alias for boot.
|
|
+
|
|
@item lba
|
|
(MS-DOS) - this flag can be enabled to tell MS DOS, MS Windows 9x and
|
|
MS Windows ME based operating systems to use Linear (LBA) mode.
|
|
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
|
|
index 585383d..d144e21 100644
|
|
--- a/include/parted/disk.in.h
|
|
+++ b/include/parted/disk.in.h
|
|
@@ -74,10 +74,11 @@ enum _PedPartitionFlag {
|
|
PED_PARTITION_DIAG=14,
|
|
PED_PARTITION_LEGACY_BOOT=15,
|
|
PED_PARTITION_MSFT_DATA=16,
|
|
- PED_PARTITION_IRST=17
|
|
+ PED_PARTITION_IRST=17,
|
|
+ PED_PARTITION_ESP=18
|
|
};
|
|
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
|
|
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_IRST
|
|
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_ESP
|
|
|
|
enum _PedDiskTypeFeature {
|
|
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
|
|
diff --git a/libparted/disk.c b/libparted/disk.c
|
|
index 18c94ac..5421c03 100644
|
|
--- a/libparted/disk.c
|
|
+++ b/libparted/disk.c
|
|
@@ -2404,6 +2404,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
|
|
return N_("legacy_boot");
|
|
case PED_PARTITION_IRST:
|
|
return N_("irst");
|
|
+ case PED_PARTITION_ESP:
|
|
+ return N_("esp");
|
|
|
|
default:
|
|
ped_exception_throw (
|
|
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
|
|
index c754970..eff1c03 100644
|
|
--- a/libparted/labels/dos.c
|
|
+++ b/libparted/labels/dos.c
|
|
@@ -92,6 +92,7 @@ static const char MBR_BOOT_CODE[] = {
|
|
#define PARTITION_SUN_UFS 0xbf
|
|
#define PARTITION_DELL_DIAG 0xde
|
|
#define PARTITION_GPT 0xee
|
|
+#define PARTITION_ESP 0xef
|
|
#define PARTITION_PALO 0xf0
|
|
#define PARTITION_PREP 0x41
|
|
#define PARTITION_LINUX_RAID 0xfd
|
|
@@ -161,6 +162,7 @@ typedef struct {
|
|
int prep;
|
|
int diag;
|
|
int irst;
|
|
+ int esp;
|
|
OrigState* orig; /* used for CHS stuff */
|
|
} DosPartitionData;
|
|
|
|
@@ -927,6 +929,7 @@ raw_part_parse (const PedDisk* disk, const DosRawPartition* raw_part,
|
|
dos_data->palo = raw_part->type == PARTITION_PALO;
|
|
dos_data->prep = raw_part->type == PARTITION_PREP;
|
|
dos_data->irst = raw_part->type == PARTITION_IRST;
|
|
+ dos_data->esp = raw_part->type == PARTITION_ESP;
|
|
dos_data->orig = ped_malloc (sizeof (OrigState));
|
|
if (!dos_data->orig) {
|
|
ped_partition_destroy (part);
|
|
@@ -1320,6 +1323,7 @@ msdos_partition_new (const PedDisk* disk, PedPartitionType part_type,
|
|
dos_data->palo = 0;
|
|
dos_data->prep = 0;
|
|
dos_data->irst = 0;
|
|
+ dos_data->esp = 0;
|
|
} else {
|
|
part->disk_specific = NULL;
|
|
}
|
|
@@ -1356,6 +1360,7 @@ msdos_partition_duplicate (const PedPartition* part)
|
|
new_dos_data->palo = old_dos_data->palo;
|
|
new_dos_data->prep = old_dos_data->prep;
|
|
new_dos_data->irst = old_dos_data->irst;
|
|
+ new_dos_data->esp = old_dos_data->esp;
|
|
|
|
if (old_dos_data->orig) {
|
|
new_dos_data->orig = ped_malloc (sizeof (OrigState));
|
|
@@ -1405,6 +1410,7 @@ msdos_partition_set_system (PedPartition* part,
|
|
dos_data->palo = 0;
|
|
dos_data->prep = 0;
|
|
dos_data->irst = 0;
|
|
+ dos_data->esp = 0;
|
|
if (dos_data->lba)
|
|
dos_data->system = PARTITION_EXT_LBA;
|
|
else
|
|
@@ -1441,6 +1447,10 @@ msdos_partition_set_system (PedPartition* part,
|
|
dos_data->system = PARTITION_IRST;
|
|
return 1;
|
|
}
|
|
+ if (dos_data->esp) {
|
|
+ dos_data->system = PARTITION_ESP;
|
|
+ return 1;
|
|
+ }
|
|
|
|
if (!fs_type)
|
|
dos_data->system = PARTITION_LINUX;
|
|
@@ -1478,6 +1488,7 @@ clear_flags (DosPartitionData *dos_data)
|
|
dos_data->palo = 0;
|
|
dos_data->prep = 0;
|
|
dos_data->irst = 0;
|
|
+ dos_data->esp = 0;
|
|
dos_data->raid = 0;
|
|
}
|
|
|
|
@@ -1562,6 +1573,12 @@ msdos_partition_set_flag (PedPartition* part,
|
|
dos_data->irst = state;
|
|
return ped_partition_set_system (part, part->fs_type);
|
|
|
|
+ case PED_PARTITION_ESP:
|
|
+ if (state)
|
|
+ clear_flags (dos_data);
|
|
+ dos_data->esp = state;
|
|
+ return ped_partition_set_system (part, part->fs_type);
|
|
+
|
|
default:
|
|
return 0;
|
|
}
|
|
@@ -1607,6 +1624,9 @@ msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
|
|
case PED_PARTITION_IRST:
|
|
return dos_data->irst;
|
|
|
|
+ case PED_PARTITION_ESP:
|
|
+ return dos_data->esp;
|
|
+
|
|
default:
|
|
return 0;
|
|
}
|
|
@@ -1630,6 +1650,7 @@ msdos_partition_is_flag_available (const PedPartition* part,
|
|
case PED_PARTITION_PALO:
|
|
case PED_PARTITION_PREP:
|
|
case PED_PARTITION_IRST:
|
|
+ case PED_PARTITION_ESP:
|
|
case PED_PARTITION_DIAG:
|
|
return 1;
|
|
|
|
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
|
|
index ff87708..42b0360 100644
|
|
--- a/libparted/labels/gpt.c
|
|
+++ b/libparted/labels/gpt.c
|
|
@@ -1622,6 +1622,7 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
|
|
|
switch (flag)
|
|
{
|
|
+ case PED_PARTITION_ESP:
|
|
case PED_PARTITION_BOOT:
|
|
gpt_part_data->boot = state;
|
|
if (state)
|
|
@@ -1806,6 +1807,7 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
|
|
return gpt_part_data->raid;
|
|
case PED_PARTITION_LVM:
|
|
return gpt_part_data->lvm;
|
|
+ case PED_PARTITION_ESP:
|
|
case PED_PARTITION_BOOT:
|
|
return gpt_part_data->boot;
|
|
case PED_PARTITION_BIOS_GRUB:
|
|
@@ -1856,6 +1858,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
|
|
case PED_PARTITION_LEGACY_BOOT:
|
|
case PED_PARTITION_PREP:
|
|
case PED_PARTITION_IRST:
|
|
+ case PED_PARTITION_ESP:
|
|
return 1;
|
|
case PED_PARTITION_SWAP:
|
|
case PED_PARTITION_ROOT:
|
|
--
|
|
1.8.5.3
|
|
|