- Upstream 3.5.28 Alpha release
- Dropped all patches included in new upstream release - Bumped minor version on libparted.so and libparted-fs-resize.so
This commit is contained in:
parent
d747d1a8fe
commit
7fdac872b5
2
.gitignore
vendored
2
.gitignore
vendored
@ -23,3 +23,5 @@ clog
|
|||||||
/parted-3.4.64.tar.xz.sig
|
/parted-3.4.64.tar.xz.sig
|
||||||
/parted-3.5.tar.xz
|
/parted-3.5.tar.xz
|
||||||
/parted-3.5.tar.xz.sig
|
/parted-3.5.tar.xz.sig
|
||||||
|
/parted-3.5.28.tar.xz
|
||||||
|
/parted-3.5.28.tar.xz.sig
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
From cec533a00a2cd0b64a7a0f5debc26554f6025831 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Mon, 18 Apr 2022 15:10:06 -0400
|
|
||||||
Subject: [PATCH 01/13] maint: post-release administrivia
|
|
||||||
|
|
||||||
* NEWS: Add header line for next release.
|
|
||||||
* .prev-version: Record previous version.
|
|
||||||
* cfg.mk (old_NEWS_hash): Auto-update.
|
|
||||||
---
|
|
||||||
.prev-version | 2 +-
|
|
||||||
NEWS | 3 +++
|
|
||||||
cfg.mk | 2 +-
|
|
||||||
3 files changed, 5 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/.prev-version b/.prev-version
|
|
||||||
index e917998..5a95802 100644
|
|
||||||
--- a/.prev-version
|
|
||||||
+++ b/.prev-version
|
|
||||||
@@ -1 +1 @@
|
|
||||||
-3.4.64.2
|
|
||||||
+3.5
|
|
||||||
diff --git a/NEWS b/NEWS
|
|
||||||
index 68a164a..2bd161f 100644
|
|
||||||
--- a/NEWS
|
|
||||||
+++ b/NEWS
|
|
||||||
@@ -1,5 +1,8 @@
|
|
||||||
GNU parted NEWS -*- outline -*-
|
|
||||||
|
|
||||||
+* Noteworthy changes in release ?.? (????-??-??) [?]
|
|
||||||
+
|
|
||||||
+
|
|
||||||
* Noteworthy changes in release 3.5 (2022-04-18) [stable]
|
|
||||||
|
|
||||||
** New Features
|
|
||||||
diff --git a/cfg.mk b/cfg.mk
|
|
||||||
index d5fdd80..11fa51b 100644
|
|
||||||
--- a/cfg.mk
|
|
||||||
+++ b/cfg.mk
|
|
||||||
@@ -45,7 +45,7 @@ local-checks-to-skip = \
|
|
||||||
export VERBOSE = yes
|
|
||||||
|
|
||||||
# Hash of lines 42-208 for release 3.2
|
|
||||||
-old_NEWS_hash = 64a8f4d9ec1a5c256f3cc792450dc257
|
|
||||||
+old_NEWS_hash = 81f624d1d62a34f24e1286bd3cf5c736
|
|
||||||
|
|
||||||
include $(srcdir)/dist-check.mk
|
|
||||||
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
@ -1,228 +0,0 @@
|
|||||||
From 29ffc6a1f285f48ac0b9efa7299373e486c486e8 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Arvin Schnell <aschnell@suse.com>
|
|
||||||
Date: Fri, 8 Oct 2021 10:06:24 +0000
|
|
||||||
Subject: [PATCH 03/13] libparted: add swap flag for DASD label
|
|
||||||
|
|
||||||
Support the swap flag and fix reading flags from disk. Also
|
|
||||||
cleanup code by dropping the 2 flags "raid" and "lvm" from
|
|
||||||
DasdPartitionData and instead use "system" directly.
|
|
||||||
|
|
||||||
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
||||||
---
|
|
||||||
include/parted/fdasd.in.h | 2 -
|
|
||||||
libparted/labels/dasd.c | 118 ++++++++++++++++----------------------
|
|
||||||
2 files changed, 50 insertions(+), 70 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/parted/fdasd.in.h b/include/parted/fdasd.in.h
|
|
||||||
index 9e5d7d1..e3ba183 100644
|
|
||||||
--- a/include/parted/fdasd.in.h
|
|
||||||
+++ b/include/parted/fdasd.in.h
|
|
||||||
@@ -28,10 +28,8 @@
|
|
||||||
|
|
||||||
#define PARTITION_LINUX_SWAP 0x82
|
|
||||||
#define PARTITION_LINUX 0x83
|
|
||||||
-#define PARTITION_LINUX_EXT 0x85
|
|
||||||
#define PARTITION_LINUX_LVM 0x8e
|
|
||||||
#define PARTITION_LINUX_RAID 0xfd
|
|
||||||
-#define PARTITION_LINUX_LVM_OLD 0xfe
|
|
||||||
|
|
||||||
#define PART_TYPE_NATIVE "NATIVE"
|
|
||||||
#define PART_TYPE_SWAP "SWAP "
|
|
||||||
diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c
|
|
||||||
index 0c00c4f..27baad0 100644
|
|
||||||
--- a/libparted/labels/dasd.c
|
|
||||||
+++ b/libparted/labels/dasd.c
|
|
||||||
@@ -53,10 +53,8 @@
|
|
||||||
|
|
||||||
#define PARTITION_LINUX_SWAP 0x82
|
|
||||||
#define PARTITION_LINUX 0x83
|
|
||||||
-#define PARTITION_LINUX_EXT 0x85
|
|
||||||
#define PARTITION_LINUX_LVM 0x8e
|
|
||||||
#define PARTITION_LINUX_RAID 0xfd
|
|
||||||
-#define PARTITION_LINUX_LVM_OLD 0xfe
|
|
||||||
|
|
||||||
extern void ped_disk_dasd_init ();
|
|
||||||
extern void ped_disk_dasd_done ();
|
|
||||||
@@ -66,8 +64,6 @@ extern void ped_disk_dasd_done ();
|
|
||||||
typedef struct {
|
|
||||||
int type;
|
|
||||||
int system;
|
|
||||||
- int raid;
|
|
||||||
- int lvm;
|
|
||||||
} DasdPartitionData;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
@@ -134,6 +130,31 @@ static PedDiskType dasd_disk_type = {
|
|
||||||
features: 0
|
|
||||||
};
|
|
||||||
|
|
||||||
+struct flag_id_mapping_t
|
|
||||||
+{
|
|
||||||
+ enum _PedPartitionFlag flag;
|
|
||||||
+ int type_id;
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static const struct flag_id_mapping_t flag_id_mapping[] =
|
|
||||||
+{
|
|
||||||
+ { PED_PARTITION_LVM, PARTITION_LINUX_LVM },
|
|
||||||
+ { PED_PARTITION_RAID, PARTITION_LINUX_RAID },
|
|
||||||
+ { PED_PARTITION_SWAP, PARTITION_LINUX_SWAP },
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
+static const struct flag_id_mapping_t* _GL_ATTRIBUTE_CONST
|
|
||||||
+dasd_find_flag_id_mapping (PedPartitionFlag flag)
|
|
||||||
+{
|
|
||||||
+ int n = sizeof(flag_id_mapping) / sizeof(flag_id_mapping[0]);
|
|
||||||
+
|
|
||||||
+ for (int i = 0; i < n; ++i)
|
|
||||||
+ if (flag_id_mapping[i].flag == flag)
|
|
||||||
+ return &flag_id_mapping[i];
|
|
||||||
+
|
|
||||||
+ return NULL;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static PedDisk*
|
|
||||||
dasd_alloc (const PedDevice* dev)
|
|
||||||
{
|
|
||||||
@@ -310,8 +331,6 @@ dasd_read (PedDisk* disk)
|
|
||||||
part->num = 1;
|
|
||||||
part->fs_type = ped_file_system_probe (&part->geom);
|
|
||||||
dasd_data = part->disk_specific;
|
|
||||||
- dasd_data->raid = 0;
|
|
||||||
- dasd_data->lvm = 0;
|
|
||||||
dasd_data->type = 0;
|
|
||||||
|
|
||||||
if (!ped_disk_add_partition (disk, part, NULL))
|
|
||||||
@@ -394,8 +413,6 @@ dasd_read (PedDisk* disk)
|
|
||||||
part->num = 1;
|
|
||||||
part->fs_type = ped_file_system_probe (&part->geom);
|
|
||||||
dasd_data = part->disk_specific;
|
|
||||||
- dasd_data->raid = 0;
|
|
||||||
- dasd_data->lvm = 0;
|
|
||||||
dasd_data->type = 0;
|
|
||||||
|
|
||||||
if (!ped_disk_add_partition (disk, part, NULL))
|
|
||||||
@@ -452,25 +469,12 @@ dasd_read (PedDisk* disk)
|
|
||||||
|
|
||||||
dasd_data = part->disk_specific;
|
|
||||||
|
|
||||||
- if ((strncmp(PART_TYPE_RAID, str, 6) == 0) &&
|
|
||||||
- (ped_file_system_probe(&part->geom) == NULL))
|
|
||||||
- ped_partition_set_flag(part, PED_PARTITION_RAID, 1);
|
|
||||||
- else
|
|
||||||
- ped_partition_set_flag(part, PED_PARTITION_RAID, 0);
|
|
||||||
-
|
|
||||||
- if ((strncmp(PART_TYPE_LVM, str, 6) == 0) &&
|
|
||||||
- (ped_file_system_probe(&part->geom) == NULL))
|
|
||||||
- ped_partition_set_flag(part, PED_PARTITION_LVM, 1);
|
|
||||||
- else
|
|
||||||
- ped_partition_set_flag(part, PED_PARTITION_LVM, 0);
|
|
||||||
-
|
|
||||||
- if (strncmp(PART_TYPE_SWAP, str, 6) == 0) {
|
|
||||||
- fs = ped_file_system_probe(&part->geom);
|
|
||||||
- if (fs && is_linux_swap(fs->name)) {
|
|
||||||
- dasd_data->system = PARTITION_LINUX_SWAP;
|
|
||||||
- PDEBUG;
|
|
||||||
- }
|
|
||||||
- }
|
|
||||||
+ if (strncmp(PART_TYPE_RAID, str, 6) == 0)
|
|
||||||
+ dasd_data->system = PARTITION_LINUX_RAID;
|
|
||||||
+ else if (strncmp(PART_TYPE_LVM, str, 6) == 0)
|
|
||||||
+ dasd_data->system = PARTITION_LINUX_LVM;
|
|
||||||
+ else if (strncmp(PART_TYPE_SWAP, str, 6) == 0)
|
|
||||||
+ dasd_data->system = PARTITION_LINUX_SWAP;
|
|
||||||
|
|
||||||
vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
|
|
||||||
|
|
||||||
@@ -747,20 +751,17 @@ dasd_partition_set_flag (PedPartition* part, PedPartitionFlag flag, int state)
|
|
||||||
PED_ASSERT(part->disk_specific != NULL);
|
|
||||||
dasd_data = part->disk_specific;
|
|
||||||
|
|
||||||
- switch (flag) {
|
|
||||||
- case PED_PARTITION_RAID:
|
|
||||||
- if (state)
|
|
||||||
- dasd_data->lvm = 0;
|
|
||||||
- dasd_data->raid = state;
|
|
||||||
- return ped_partition_set_system(part, part->fs_type);
|
|
||||||
- case PED_PARTITION_LVM:
|
|
||||||
- if (state)
|
|
||||||
- dasd_data->raid = 0;
|
|
||||||
- dasd_data->lvm = state;
|
|
||||||
- return ped_partition_set_system(part, part->fs_type);
|
|
||||||
- default:
|
|
||||||
- return 0;
|
|
||||||
+ const struct flag_id_mapping_t* p = dasd_find_flag_id_mapping (flag);
|
|
||||||
+ if (p)
|
|
||||||
+ {
|
|
||||||
+ if (state)
|
|
||||||
+ dasd_data->system = p->type_id;
|
|
||||||
+ else if (dasd_data->system == p->type_id)
|
|
||||||
+ return dasd_partition_set_system (part, part->fs_type);
|
|
||||||
+ return 1;
|
|
||||||
}
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
static int
|
|
||||||
@@ -772,14 +773,11 @@ dasd_partition_get_flag (const PedPartition* part, PedPartitionFlag flag)
|
|
||||||
PED_ASSERT (part->disk_specific != NULL);
|
|
||||||
dasd_data = part->disk_specific;
|
|
||||||
|
|
||||||
- switch (flag) {
|
|
||||||
- case PED_PARTITION_RAID:
|
|
||||||
- return dasd_data->raid;
|
|
||||||
- case PED_PARTITION_LVM:
|
|
||||||
- return dasd_data->lvm;
|
|
||||||
- default:
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
+ const struct flag_id_mapping_t* p = dasd_find_flag_id_mapping (flag);
|
|
||||||
+ if (p)
|
|
||||||
+ return dasd_data->system == p->type_id;
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
@@ -800,14 +798,10 @@ dasd_partition_is_flag_available (const PedPartition* part,
|
|
||||||
if (disk_specific->format_type == 1)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
- switch (flag) {
|
|
||||||
- case PED_PARTITION_RAID:
|
|
||||||
- return 1;
|
|
||||||
- case PED_PARTITION_LVM:
|
|
||||||
- return 1;
|
|
||||||
- default:
|
|
||||||
- return 0;
|
|
||||||
- }
|
|
||||||
+ if (dasd_find_flag_id_mapping (flag))
|
|
||||||
+ return 1;
|
|
||||||
+
|
|
||||||
+ return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
@@ -938,18 +932,6 @@ dasd_partition_set_system (PedPartition* part,
|
|
||||||
|
|
||||||
part->fs_type = fs_type;
|
|
||||||
|
|
||||||
- if (dasd_data->lvm) {
|
|
||||||
- dasd_data->system = PARTITION_LINUX_LVM;
|
|
||||||
- PDEBUG;
|
|
||||||
- return 1;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- if (dasd_data->raid) {
|
|
||||||
- dasd_data->system = PARTITION_LINUX_RAID;
|
|
||||||
- PDEBUG;
|
|
||||||
- return 1;
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
if (!fs_type) {
|
|
||||||
dasd_data->system = PARTITION_LINUX;
|
|
||||||
PDEBUG;
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
|||||||
From 9b0a83a747b28bd1b778bdd32616e6f7ea88c84d Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Fri, 13 May 2022 10:02:06 -0700
|
|
||||||
Subject: [PATCH 04/13] parted: Reset the filesystem type when changing the
|
|
||||||
id/uuid
|
|
||||||
|
|
||||||
Without this the print command keeps showing the type selected with
|
|
||||||
mkpart, which doesn't match the id/uuid set by the user. So rescan the
|
|
||||||
partition for a filesystem.
|
|
||||||
---
|
|
||||||
parted/parted.c | 3 +++
|
|
||||||
1 file changed, 3 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/parted/parted.c b/parted/parted.c
|
|
||||||
index b8a4acf..96da30d 100644
|
|
||||||
--- a/parted/parted.c
|
|
||||||
+++ b/parted/parted.c
|
|
||||||
@@ -991,6 +991,9 @@ do_type (PedDevice** dev, PedDisk** diskp)
|
|
||||||
|
|
||||||
free (input);
|
|
||||||
|
|
||||||
+ // Reset the fs_type based on the filesystem, if it exists
|
|
||||||
+ part->fs_type = ped_file_system_probe (&part->geom);
|
|
||||||
+
|
|
||||||
if (!ped_disk_commit (*diskp))
|
|
||||||
goto error;
|
|
||||||
return 1;
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
@ -1,23 +0,0 @@
|
|||||||
From ac2a35c2214ef42352d0ddb4f7f4cb77d116e92e Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Fri, 13 May 2022 10:15:41 -0700
|
|
||||||
Subject: [PATCH 05/13] tests: t3200-type-change now passes
|
|
||||||
|
|
||||||
---
|
|
||||||
tests/Makefile.am | 3 ---
|
|
||||||
1 file changed, 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
||||||
index 2da653b..1d109d7 100644
|
|
||||||
--- a/tests/Makefile.am
|
|
||||||
+++ b/tests/Makefile.am
|
|
||||||
@@ -1,6 +1,3 @@
|
|
||||||
-XFAIL_TESTS = \
|
|
||||||
- t3200-type-change.sh
|
|
||||||
-
|
|
||||||
TEST_EXTENSIONS = .sh
|
|
||||||
SH_LOG_COMPILER = $(SHELL)
|
|
||||||
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
@ -1,40 +0,0 @@
|
|||||||
From bafa84b25a265ef9eed3872790d52bf56ac42998 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Arvin Schnell <aschnell@suse.com>
|
|
||||||
Date: Wed, 27 Jul 2022 09:36:54 +0000
|
|
||||||
Subject: [PATCH 06/13] libparted: Fix check for availability of _type_id
|
|
||||||
functions
|
|
||||||
|
|
||||||
Fix a copy/paste error. In practice this didn't cause any problems
|
|
||||||
because the *_set_type_id and *_get_type_id are either both NULL or both
|
|
||||||
set to the function.
|
|
||||||
|
|
||||||
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
||||||
---
|
|
||||||
libparted/disk.c | 4 ++--
|
|
||||||
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libparted/disk.c b/libparted/disk.c
|
|
||||||
index 22dff36..a961d65 100644
|
|
||||||
--- a/libparted/disk.c
|
|
||||||
+++ b/libparted/disk.c
|
|
||||||
@@ -1572,7 +1572,7 @@ ped_partition_get_type_id (const PedPartition *part)
|
|
||||||
if (!_assert_partition_type_id_feature (part->disk->type))
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
- PED_ASSERT (part->disk->type->ops->partition_set_type_id != NULL);
|
|
||||||
+ PED_ASSERT (part->disk->type->ops->partition_get_type_id != NULL);
|
|
||||||
return part->disk->type->ops->partition_get_type_id (part);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -1608,7 +1608,7 @@ ped_partition_get_type_uuid (const PedPartition *part)
|
|
||||||
if (!_assert_partition_type_uuid_feature (part->disk->type))
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
- PED_ASSERT (part->disk->type->ops->partition_set_type_uuid != NULL);
|
|
||||||
+ PED_ASSERT (part->disk->type->ops->partition_get_type_uuid != NULL);
|
|
||||||
return part->disk->type->ops->partition_get_type_uuid (part);
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
@ -1,34 +0,0 @@
|
|||||||
From b16be5ffc8e700df2b6b2545c4b6794cea71b8e7 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Arvin Schnell <aschnell@suse.com>
|
|
||||||
Date: Wed, 27 Jul 2022 13:36:08 +0000
|
|
||||||
Subject: [PATCH 07/13] parted: Simplify code for json output
|
|
||||||
|
|
||||||
_PedDiskOps::get_max_primary_partition_count is always available, the
|
|
||||||
macro PT_op_function_initializers ensures it. So use
|
|
||||||
ped_disk_get_max_primary_partition_count instead of
|
|
||||||
_PedDiskOps::get_max_primary_partition_count directly.
|
|
||||||
|
|
||||||
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
||||||
---
|
|
||||||
parted/parted.c | 5 ++---
|
|
||||||
1 file changed, 2 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/parted/parted.c b/parted/parted.c
|
|
||||||
index 96da30d..36c39c7 100644
|
|
||||||
--- a/parted/parted.c
|
|
||||||
+++ b/parted/parted.c
|
|
||||||
@@ -1215,9 +1215,8 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
|
|
||||||
ul_jsonwrt_value_u64 (&json, "physical-sector-size", dev->phys_sector_size);
|
|
||||||
ul_jsonwrt_value_s (&json, "label", pt_name);
|
|
||||||
if (diskp) {
|
|
||||||
- if (diskp->type->ops->get_max_primary_partition_count)
|
|
||||||
- ul_jsonwrt_value_u64 (&json, "max-partitions",
|
|
||||||
- diskp->type->ops->get_max_primary_partition_count(diskp));
|
|
||||||
+ ul_jsonwrt_value_u64 (&json, "max-partitions",
|
|
||||||
+ ped_disk_get_max_primary_partition_count(diskp));
|
|
||||||
disk_print_flags_json (diskp);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
@ -1,59 +0,0 @@
|
|||||||
From aa690ee275db86d1edb2468bcf31c3d7cf81228e Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Thu, 4 Aug 2022 11:39:09 -0700
|
|
||||||
Subject: [PATCH 08/13] disk.in.h: Remove use of enums with #define
|
|
||||||
|
|
||||||
The preprocessor doesn't evaluate the enum, so it ends up being 0, which
|
|
||||||
causes problems for library users like pyparted which try to use the _LAST
|
|
||||||
value to conditionally include support for newer flags.
|
|
||||||
|
|
||||||
Instead just define the int that is the first and last entry in each enum.
|
|
||||||
|
|
||||||
Thanks to adamw and dcantrell for help arriving at a solution.
|
|
||||||
---
|
|
||||||
include/parted/disk.in.h | 15 +++++++++------
|
|
||||||
1 file changed, 9 insertions(+), 6 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
|
|
||||||
index 672c4ee..715637d 100644
|
|
||||||
--- a/include/parted/disk.in.h
|
|
||||||
+++ b/include/parted/disk.in.h
|
|
||||||
@@ -47,8 +47,9 @@ enum _PedDiskFlag {
|
|
||||||
/* This flag controls whether the boot flag of a GPT PMBR is set */
|
|
||||||
PED_DISK_GPT_PMBR_BOOT=2,
|
|
||||||
};
|
|
||||||
-#define PED_DISK_FIRST_FLAG PED_DISK_CYLINDER_ALIGNMENT
|
|
||||||
-#define PED_DISK_LAST_FLAG PED_DISK_GPT_PMBR_BOOT
|
|
||||||
+// NOTE: DO NOT define using enums
|
|
||||||
+#define PED_DISK_FIRST_FLAG 1 // PED_DISK_CYLINDER_ALIGNMENT
|
|
||||||
+#define PED_DISK_LAST_FLAG 2 // PED_DISK_GPT_PMBR_BOOT
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Partition types
|
|
||||||
@@ -88,8 +89,9 @@ enum _PedPartitionFlag {
|
|
||||||
PED_PARTITION_BLS_BOOT=20,
|
|
||||||
PED_PARTITION_LINUX_HOME=21,
|
|
||||||
};
|
|
||||||
-#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
|
|
||||||
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_LINUX_HOME
|
|
||||||
+// NOTE: DO NOT define using enums
|
|
||||||
+#define PED_PARTITION_FIRST_FLAG 1 // PED_PARTITION_BOOT
|
|
||||||
+#define PED_PARTITION_LAST_FLAG 21 // PED_PARTITION_LINUX_HOME
|
|
||||||
|
|
||||||
enum _PedDiskTypeFeature {
|
|
||||||
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
|
|
||||||
@@ -97,8 +99,9 @@ enum _PedDiskTypeFeature {
|
|
||||||
PED_DISK_TYPE_PARTITION_TYPE_ID=4, /**< supports partition type-ids */
|
|
||||||
PED_DISK_TYPE_PARTITION_TYPE_UUID=8, /**< supports partition type-uuids */
|
|
||||||
};
|
|
||||||
-#define PED_DISK_TYPE_FIRST_FEATURE PED_DISK_TYPE_EXTENDED
|
|
||||||
-#define PED_DISK_TYPE_LAST_FEATURE PED_DISK_TYPE_PARTITION_TYPE_UUID
|
|
||||||
+// NOTE: DO NOT define using enums
|
|
||||||
+#define PED_DISK_TYPE_FIRST_FEATURE 1 // PED_DISK_TYPE_EXTENDED
|
|
||||||
+#define PED_DISK_TYPE_LAST_FEATURE 8 // PED_DISK_TYPE_PARTITION_TYPE_UUID
|
|
||||||
|
|
||||||
struct _PedDisk;
|
|
||||||
struct _PedPartition;
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
@ -1,101 +0,0 @@
|
|||||||
From 8957382b98fd79bc06dad132ef28a0be8b46ea16 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Mon, 8 Aug 2022 12:04:32 -0700
|
|
||||||
Subject: [PATCH 09/13] libparted: Fix handling of gpt partition types
|
|
||||||
|
|
||||||
This restores the previous behavior by testing the GUID against the list
|
|
||||||
of known types and skipping the filesystem GUID reset. Now the sequence
|
|
||||||
of:
|
|
||||||
|
|
||||||
ped_partition_new(...)
|
|
||||||
ped_partition_set_flag(part, PED_PARTITION_BIOS_GRUB, 1);
|
|
||||||
ped_partition_set_system(part, ped_file_system_type_get("ext4"));
|
|
||||||
|
|
||||||
Will keep the GUID set to PED_PARTITION_BIOS_GRUB, which is how it used
|
|
||||||
to behave.
|
|
||||||
---
|
|
||||||
libparted/labels/gpt.c | 45 ++++++++++++++++++++++++++++++++++++++++--
|
|
||||||
1 file changed, 43 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
|
|
||||||
index 0e9e060..8e6a37d 100644
|
|
||||||
--- a/libparted/labels/gpt.c
|
|
||||||
+++ b/libparted/labels/gpt.c
|
|
||||||
@@ -196,6 +196,24 @@ static const struct flag_uuid_mapping_t flag_uuid_mapping[] =
|
|
||||||
{ PED_PARTITION_SWAP, PARTITION_SWAP_GUID },
|
|
||||||
};
|
|
||||||
|
|
||||||
+static const efi_guid_t skip_set_system_guids[] =
|
|
||||||
+{
|
|
||||||
+ PARTITION_LVM_GUID,
|
|
||||||
+ PARTITION_SWAP_GUID,
|
|
||||||
+ PARTITION_RAID_GUID,
|
|
||||||
+ PARTITION_PREP_GUID,
|
|
||||||
+ PARTITION_SYSTEM_GUID,
|
|
||||||
+ PARTITION_BIOS_GRUB_GUID,
|
|
||||||
+ PARTITION_HPSERVICE_GUID,
|
|
||||||
+ PARTITION_MSFT_RESERVED_GUID,
|
|
||||||
+ PARTITION_BASIC_DATA_GUID,
|
|
||||||
+ PARTITION_MSFT_RECOVERY,
|
|
||||||
+ PARTITION_APPLE_TV_RECOVERY_GUID,
|
|
||||||
+ PARTITION_IRST_GUID,
|
|
||||||
+ PARTITION_CHROMEOS_KERNEL_GUID,
|
|
||||||
+ PARTITION_BLS_BOOT_GUID,
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
static const struct flag_uuid_mapping_t* _GL_ATTRIBUTE_CONST
|
|
||||||
gpt_find_flag_uuid_mapping (PedPartitionFlag flag)
|
|
||||||
{
|
|
||||||
@@ -1421,6 +1439,21 @@ gpt_partition_destroy (PedPartition *part)
|
|
||||||
_ped_partition_free (part);
|
|
||||||
}
|
|
||||||
|
|
||||||
+/* is_skip_guid checks the guid against the list of guids that should not be
|
|
||||||
+ * overridden by set_system. It returns a 1 if it is in the list.
|
|
||||||
+*/
|
|
||||||
+static bool
|
|
||||||
+is_skip_guid(efi_guid_t guid) {
|
|
||||||
+ int n = sizeof(skip_set_system_guids) / sizeof(skip_set_system_guids[0]);
|
|
||||||
+ for (int i = 0; i < n; ++i) {
|
|
||||||
+ if (guid_cmp(guid, skip_set_system_guids[i]) == 0) {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return false;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int
|
|
||||||
gpt_partition_set_system (PedPartition *part,
|
|
||||||
const PedFileSystemType *fs_type)
|
|
||||||
@@ -1431,6 +1464,11 @@ gpt_partition_set_system (PedPartition *part,
|
|
||||||
|
|
||||||
part->fs_type = fs_type;
|
|
||||||
|
|
||||||
+ // Is this a GUID that should skip fs_type checking?
|
|
||||||
+ if (is_skip_guid(gpt_part_data->type)) {
|
|
||||||
+ return 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (fs_type)
|
|
||||||
{
|
|
||||||
if (strncmp (fs_type->name, "fat", 3) == 0
|
|
||||||
@@ -1563,10 +1601,13 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
|
||||||
const struct flag_uuid_mapping_t* p = gpt_find_flag_uuid_mapping (flag);
|
|
||||||
if (p)
|
|
||||||
{
|
|
||||||
- if (state)
|
|
||||||
+ if (state) {
|
|
||||||
gpt_part_data->type = p->type_uuid;
|
|
||||||
- else if (guid_cmp (gpt_part_data->type, p->type_uuid) == 0)
|
|
||||||
+ } else if (guid_cmp (gpt_part_data->type, p->type_uuid) == 0) {
|
|
||||||
+ // Clear the GUID so that fs_type will be used to return it to the default
|
|
||||||
+ gpt_part_data->type = PARTITION_LINUX_DATA_GUID;
|
|
||||||
return gpt_partition_set_system (part, part->fs_type);
|
|
||||||
+ }
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
@ -1,160 +0,0 @@
|
|||||||
From d50b7bf2b66b7b67ee332c1af63bc1f5fdfba7ad Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Mon, 8 Aug 2022 13:49:09 -0700
|
|
||||||
Subject: [PATCH 10/13] tests: Add a libparted test for
|
|
||||||
ped_partition_set_system on gpt
|
|
||||||
|
|
||||||
Test the libparted API to make sure the flag is not cleared by calling
|
|
||||||
ped_partition_set_system.
|
|
||||||
---
|
|
||||||
libparted/tests/Makefile.am | 6 ++-
|
|
||||||
libparted/tests/flags.c | 81 ++++++++++++++++++++++++++++++++++
|
|
||||||
libparted/tests/t1001-flags.sh | 23 ++++++++++
|
|
||||||
3 files changed, 108 insertions(+), 2 deletions(-)
|
|
||||||
create mode 100644 libparted/tests/flags.c
|
|
||||||
create mode 100755 libparted/tests/t1001-flags.sh
|
|
||||||
|
|
||||||
diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am
|
|
||||||
index fd5cba5..260b692 100644
|
|
||||||
--- a/libparted/tests/Makefile.am
|
|
||||||
+++ b/libparted/tests/Makefile.am
|
|
||||||
@@ -3,9 +3,10 @@
|
|
||||||
#
|
|
||||||
# This file may be modified and/or distributed without restriction.
|
|
||||||
|
|
||||||
-TESTS = t1000-label.sh t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh t4000-volser.sh
|
|
||||||
+TESTS = t1000-label.sh t1001-flags.sh t2000-disk.sh t2100-zerolen.sh \
|
|
||||||
+ t3000-symlink.sh t4000-volser.sh
|
|
||||||
EXTRA_DIST = $(TESTS)
|
|
||||||
-check_PROGRAMS = label disk zerolen symlink volser
|
|
||||||
+check_PROGRAMS = label disk zerolen symlink volser flags
|
|
||||||
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
|
|
||||||
|
|
||||||
LDADD = \
|
|
||||||
@@ -24,6 +25,7 @@ disk_SOURCES = common.h common.c disk.c
|
|
||||||
zerolen_SOURCES = common.h common.c zerolen.c
|
|
||||||
symlink_SOURCES = common.h common.c symlink.c
|
|
||||||
volser_SOURCES = common.h common.c volser.c
|
|
||||||
+flags_SOURCES = common.h common.c flags.c
|
|
||||||
|
|
||||||
# Arrange to symlink to tests/init.sh.
|
|
||||||
CLEANFILES = init.sh
|
|
||||||
diff --git a/libparted/tests/flags.c b/libparted/tests/flags.c
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..c83a361
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/libparted/tests/flags.c
|
|
||||||
@@ -0,0 +1,81 @@
|
|
||||||
+#include <config.h>
|
|
||||||
+#include <unistd.h>
|
|
||||||
+
|
|
||||||
+#include <check.h>
|
|
||||||
+
|
|
||||||
+#include <parted/parted.h>
|
|
||||||
+
|
|
||||||
+#include "common.h"
|
|
||||||
+#include "progname.h"
|
|
||||||
+
|
|
||||||
+#define STREQ(a, b) (strcmp (a, b) == 0)
|
|
||||||
+
|
|
||||||
+static char* temporary_disk;
|
|
||||||
+
|
|
||||||
+static void
|
|
||||||
+create_disk (void)
|
|
||||||
+{
|
|
||||||
+ temporary_disk = _create_disk (80 * 1024 * 1024);
|
|
||||||
+ fail_if (temporary_disk == NULL, "Failed to create temporary disk");
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+static void
|
|
||||||
+destroy_disk (void)
|
|
||||||
+{
|
|
||||||
+ unlink (temporary_disk);
|
|
||||||
+ free (temporary_disk);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* TEST: Test partition type flag on gpt disklabel */
|
|
||||||
+START_TEST (test_gpt_flag)
|
|
||||||
+{
|
|
||||||
+ PedDevice* dev = ped_device_get (temporary_disk);
|
|
||||||
+ if (dev == NULL)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ PedDisk* disk = ped_disk_new_fresh (dev, ped_disk_type_get ("gpt"));
|
|
||||||
+ PedConstraint *constraint = ped_constraint_any (dev);
|
|
||||||
+ PedPartition *part = ped_partition_new (disk, PED_PARTITION_NORMAL,
|
|
||||||
+ ped_file_system_type_get("ext4"), 2048, 4096);
|
|
||||||
+ ped_partition_set_flag(part, PED_PARTITION_BIOS_GRUB, 1);
|
|
||||||
+ // Type should remain set to BIOS_GRUB
|
|
||||||
+ ped_partition_set_system(part, ped_file_system_type_get("ext4"));
|
|
||||||
+
|
|
||||||
+ ped_disk_add_partition (disk, part, constraint);
|
|
||||||
+ ped_disk_commit (disk);
|
|
||||||
+ ped_constraint_destroy (constraint);
|
|
||||||
+
|
|
||||||
+ // Check flag to confirm it is still set
|
|
||||||
+ part = ped_disk_get_partition (disk, 1);
|
|
||||||
+ fail_if (ped_partition_get_flag(part, PED_PARTITION_BIOS_GRUB) != 1, "BIOS_GRUB flag not set");
|
|
||||||
+
|
|
||||||
+ ped_disk_destroy (disk);
|
|
||||||
+ ped_device_destroy (dev);
|
|
||||||
+}
|
|
||||||
+END_TEST
|
|
||||||
+
|
|
||||||
+int
|
|
||||||
+main (int argc, char **argv)
|
|
||||||
+{
|
|
||||||
+ set_program_name (argv[0]);
|
|
||||||
+ int number_failed;
|
|
||||||
+ Suite* suite = suite_create ("Partition Flags");
|
|
||||||
+ TCase* tcase_gpt = tcase_create ("GPT");
|
|
||||||
+
|
|
||||||
+ /* Fail when an exception is raised */
|
|
||||||
+ ped_exception_set_handler (_test_exception_handler);
|
|
||||||
+
|
|
||||||
+ tcase_add_checked_fixture (tcase_gpt, create_disk, destroy_disk);
|
|
||||||
+ tcase_add_test (tcase_gpt, test_gpt_flag);
|
|
||||||
+ /* Disable timeout for this test */
|
|
||||||
+ tcase_set_timeout (tcase_gpt, 0);
|
|
||||||
+ suite_add_tcase (suite, tcase_gpt);
|
|
||||||
+
|
|
||||||
+ SRunner* srunner = srunner_create (suite);
|
|
||||||
+ srunner_run_all (srunner, CK_VERBOSE);
|
|
||||||
+
|
|
||||||
+ number_failed = srunner_ntests_failed (srunner);
|
|
||||||
+ srunner_free (srunner);
|
|
||||||
+
|
|
||||||
+ return (number_failed == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
||||||
+}
|
|
||||||
diff --git a/libparted/tests/t1001-flags.sh b/libparted/tests/t1001-flags.sh
|
|
||||||
new file mode 100755
|
|
||||||
index 0000000..60a6248
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/libparted/tests/t1001-flags.sh
|
|
||||||
@@ -0,0 +1,23 @@
|
|
||||||
+#!/bin/sh
|
|
||||||
+# run the flags unittest
|
|
||||||
+
|
|
||||||
+# Copyright (C) 2007-2014, 2019-2022 Free Software Foundation, Inc.
|
|
||||||
+
|
|
||||||
+# This program is free software; you can redistribute it and/or modify
|
|
||||||
+# it under the terms of the GNU General Public License as published by
|
|
||||||
+# the Free Software Foundation; either version 3 of the License, or
|
|
||||||
+# (at your option) any later version.
|
|
||||||
+
|
|
||||||
+# This program is distributed in the hope that it will be useful,
|
|
||||||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+# GNU General Public License for more details.
|
|
||||||
+
|
|
||||||
+# You should have received a copy of the GNU General Public License
|
|
||||||
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
+
|
|
||||||
+. "${top_srcdir=../..}/tests/init.sh"; path_prepend_ .
|
|
||||||
+
|
|
||||||
+flags || fail=1
|
|
||||||
+
|
|
||||||
+Exit $fail
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
@ -1,109 +0,0 @@
|
|||||||
From 4a0e468ed63fff85a1f9b923189f20945b32f4f1 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Mon, 8 Aug 2022 15:02:30 -0700
|
|
||||||
Subject: [PATCH 11/13] libparted: Fix handling of msdos partition types
|
|
||||||
|
|
||||||
This restores the previous behavior by testing the partition type
|
|
||||||
against the list of known types and skipping the filesystem type reset.
|
|
||||||
Now the sequence of:
|
|
||||||
|
|
||||||
ped_partition_new(...)
|
|
||||||
ped_partition_set_flag(part, PED_PARTITION_BLS_BOOT, 1);
|
|
||||||
ped_partition_set_system(part, ped_file_system_type_get("ext4"));
|
|
||||||
|
|
||||||
Will keep the type set to PED_PARTITION_BLS_BOOT, which is how it used
|
|
||||||
to behave.
|
|
||||||
---
|
|
||||||
libparted/labels/dos.c | 54 +++++++++++++++++++++++++++++++++++-------
|
|
||||||
1 file changed, 46 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
|
|
||||||
index bd7465d..4359276 100644
|
|
||||||
--- a/libparted/labels/dos.c
|
|
||||||
+++ b/libparted/labels/dos.c
|
|
||||||
@@ -121,6 +121,22 @@ static const struct flag_id_mapping_t flag_id_mapping[] =
|
|
||||||
{ PED_PARTITION_SWAP, PARTITION_LINUX_SWAP },
|
|
||||||
};
|
|
||||||
|
|
||||||
+static const unsigned char skip_set_system_types[] =
|
|
||||||
+{
|
|
||||||
+ PARTITION_EXT_LBA,
|
|
||||||
+ PARTITION_DOS_EXT,
|
|
||||||
+ PARTITION_COMPAQ_DIAG,
|
|
||||||
+ PARTITION_MSFT_RECOVERY,
|
|
||||||
+ PARTITION_LINUX_LVM,
|
|
||||||
+ PARTITION_LINUX_SWAP,
|
|
||||||
+ PARTITION_LINUX_RAID,
|
|
||||||
+ PARTITION_PALO,
|
|
||||||
+ PARTITION_PREP,
|
|
||||||
+ PARTITION_IRST,
|
|
||||||
+ PARTITION_ESP,
|
|
||||||
+ PARTITION_BLS_BOOT
|
|
||||||
+};
|
|
||||||
+
|
|
||||||
static const struct flag_id_mapping_t* _GL_ATTRIBUTE_CONST
|
|
||||||
dos_find_flag_id_mapping (PedPartitionFlag flag)
|
|
||||||
{
|
|
||||||
@@ -1540,6 +1556,21 @@ msdos_partition_destroy (PedPartition* part)
|
|
||||||
free (part);
|
|
||||||
}
|
|
||||||
|
|
||||||
+/* is_skip_type checks the type against the list of types that should not be
|
|
||||||
+ * overridden by set_system. It returns a 1 if it is in the list.
|
|
||||||
+*/
|
|
||||||
+static bool
|
|
||||||
+is_skip_type(unsigned char type_id) {
|
|
||||||
+ int n = sizeof(skip_set_system_types) / sizeof(skip_set_system_types[0]);
|
|
||||||
+ for (int i = 0; i < n; ++i) {
|
|
||||||
+ if (type_id == skip_set_system_types[i]) {
|
|
||||||
+ return true;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
+ return false;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int
|
|
||||||
msdos_partition_set_system (PedPartition* part,
|
|
||||||
const PedFileSystemType* fs_type)
|
|
||||||
@@ -1548,6 +1579,11 @@ msdos_partition_set_system (PedPartition* part,
|
|
||||||
|
|
||||||
part->fs_type = fs_type;
|
|
||||||
|
|
||||||
+ // Is this a type that should skip fs_type checking?
|
|
||||||
+ if (is_skip_type(dos_data->system)) {
|
|
||||||
+ return 1;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (part->type & PED_PARTITION_EXTENDED) {
|
|
||||||
dos_data->system = PARTITION_EXT_LBA;
|
|
||||||
return 1;
|
|
||||||
@@ -1590,15 +1626,17 @@ msdos_partition_set_flag (PedPartition* part,
|
|
||||||
const struct flag_id_mapping_t* p = dos_find_flag_id_mapping (flag);
|
|
||||||
if (p)
|
|
||||||
{
|
|
||||||
- if (part->type & PED_PARTITION_EXTENDED)
|
|
||||||
- return 0;
|
|
||||||
-
|
|
||||||
- if (state)
|
|
||||||
- dos_data->system = p->type_id;
|
|
||||||
- else if (dos_data->system == p->type_id || dos_data->system == p->alt_type_id)
|
|
||||||
- return ped_partition_set_system (part, part->fs_type);
|
|
||||||
+ if (part->type & PED_PARTITION_EXTENDED)
|
|
||||||
+ return 0;
|
|
||||||
|
|
||||||
- return 1;
|
|
||||||
+ if (state) {
|
|
||||||
+ dos_data->system = p->type_id;
|
|
||||||
+ } else if (dos_data->system == p->type_id || dos_data->system == p->alt_type_id) {
|
|
||||||
+ // Clear the type so that fs_type will be used to return it to the default
|
|
||||||
+ dos_data->system = PARTITION_LINUX;
|
|
||||||
+ return ped_partition_set_system (part, part->fs_type);
|
|
||||||
+ }
|
|
||||||
+ return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (flag) {
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
@ -1,75 +0,0 @@
|
|||||||
From 8f37b28825933af9bbbac7f00cc7e23f916c7018 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Mon, 8 Aug 2022 15:06:03 -0700
|
|
||||||
Subject: [PATCH 12/13] tests: Add a libparted test for
|
|
||||||
ped_partition_set_system on msdos
|
|
||||||
|
|
||||||
Test the libparted API to make sure the flag is not cleared by calling
|
|
||||||
ped_partition_set_system.
|
|
||||||
---
|
|
||||||
libparted/tests/flags.c | 35 +++++++++++++++++++++++++++++++++++
|
|
||||||
1 file changed, 35 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/libparted/tests/flags.c b/libparted/tests/flags.c
|
|
||||||
index c83a361..c4b290b 100644
|
|
||||||
--- a/libparted/tests/flags.c
|
|
||||||
+++ b/libparted/tests/flags.c
|
|
||||||
@@ -54,6 +54,34 @@ START_TEST (test_gpt_flag)
|
|
||||||
}
|
|
||||||
END_TEST
|
|
||||||
|
|
||||||
+/* TEST: Test partition type flag on msdos disklabel */
|
|
||||||
+START_TEST (test_msdos_flag)
|
|
||||||
+{
|
|
||||||
+ PedDevice* dev = ped_device_get (temporary_disk);
|
|
||||||
+ if (dev == NULL)
|
|
||||||
+ return;
|
|
||||||
+
|
|
||||||
+ PedDisk* disk = ped_disk_new_fresh (dev, ped_disk_type_get ("msdos"));
|
|
||||||
+ PedConstraint *constraint = ped_constraint_any (dev);
|
|
||||||
+ PedPartition *part = ped_partition_new (disk, PED_PARTITION_NORMAL,
|
|
||||||
+ ped_file_system_type_get("ext4"), 2048, 4096);
|
|
||||||
+ ped_partition_set_flag(part, PED_PARTITION_BLS_BOOT, 1);
|
|
||||||
+ // Type should remain set to BIOS_GRUB
|
|
||||||
+ ped_partition_set_system(part, ped_file_system_type_get("ext4"));
|
|
||||||
+
|
|
||||||
+ ped_disk_add_partition (disk, part, constraint);
|
|
||||||
+ ped_disk_commit (disk);
|
|
||||||
+ ped_constraint_destroy (constraint);
|
|
||||||
+
|
|
||||||
+ // Check flag to confirm it is still set
|
|
||||||
+ part = ped_disk_get_partition (disk, 1);
|
|
||||||
+ fail_if (ped_partition_get_flag(part, PED_PARTITION_BLS_BOOT) != 1, "BLS_BOOT flag not set");
|
|
||||||
+
|
|
||||||
+ ped_disk_destroy (disk);
|
|
||||||
+ ped_device_destroy (dev);
|
|
||||||
+}
|
|
||||||
+END_TEST
|
|
||||||
+
|
|
||||||
int
|
|
||||||
main (int argc, char **argv)
|
|
||||||
{
|
|
||||||
@@ -61,6 +89,7 @@ main (int argc, char **argv)
|
|
||||||
int number_failed;
|
|
||||||
Suite* suite = suite_create ("Partition Flags");
|
|
||||||
TCase* tcase_gpt = tcase_create ("GPT");
|
|
||||||
+ TCase* tcase_msdos = tcase_create ("MSDOS");
|
|
||||||
|
|
||||||
/* Fail when an exception is raised */
|
|
||||||
ped_exception_set_handler (_test_exception_handler);
|
|
||||||
@@ -71,6 +100,12 @@ main (int argc, char **argv)
|
|
||||||
tcase_set_timeout (tcase_gpt, 0);
|
|
||||||
suite_add_tcase (suite, tcase_gpt);
|
|
||||||
|
|
||||||
+ tcase_add_checked_fixture (tcase_msdos, create_disk, destroy_disk);
|
|
||||||
+ tcase_add_test (tcase_msdos, test_msdos_flag);
|
|
||||||
+ /* Disable timeout for this test */
|
|
||||||
+ tcase_set_timeout (tcase_msdos, 0);
|
|
||||||
+ suite_add_tcase (suite, tcase_msdos);
|
|
||||||
+
|
|
||||||
SRunner* srunner = srunner_create (suite);
|
|
||||||
srunner_run_all (srunner, CK_VERBOSE);
|
|
||||||
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
@ -1,351 +0,0 @@
|
|||||||
From 2194035fc0fe678472d279676a13511769f7ef20 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Arvin Schnell <aschnell@suse.com>
|
|
||||||
Date: Thu, 28 Jul 2022 09:20:09 +0000
|
|
||||||
Subject: [PATCH 13/13] show GPT UUIDs in JSON output
|
|
||||||
|
|
||||||
Include GPT UUIDs in JSON output.
|
|
||||||
---
|
|
||||||
include/parted/disk.in.h | 13 ++++++--
|
|
||||||
libparted/disk.c | 64 ++++++++++++++++++++++++++++++++++++++++
|
|
||||||
libparted/labels/gpt.c | 40 ++++++++++++++++++++++++-
|
|
||||||
parted/parted.c | 18 +++++++++++
|
|
||||||
tests/t0800-json-gpt.sh | 7 +++--
|
|
||||||
tests/t0900-type-gpt.sh | 8 +++--
|
|
||||||
6 files changed, 142 insertions(+), 8 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
|
|
||||||
index 715637d..f649bcc 100644
|
|
||||||
--- a/include/parted/disk.in.h
|
|
||||||
+++ b/include/parted/disk.in.h
|
|
||||||
@@ -98,10 +98,12 @@ enum _PedDiskTypeFeature {
|
|
||||||
PED_DISK_TYPE_PARTITION_NAME=2, /**< supports partition names */
|
|
||||||
PED_DISK_TYPE_PARTITION_TYPE_ID=4, /**< supports partition type-ids */
|
|
||||||
PED_DISK_TYPE_PARTITION_TYPE_UUID=8, /**< supports partition type-uuids */
|
|
||||||
+ PED_DISK_TYPE_DISK_UUID=16, /**< supports disk uuids */
|
|
||||||
+ PED_DISK_TYPE_PARTITION_UUID=32, /**< supports partition uuids */
|
|
||||||
};
|
|
||||||
// NOTE: DO NOT define using enums
|
|
||||||
-#define PED_DISK_TYPE_FIRST_FEATURE 1 // PED_DISK_TYPE_EXTENDED
|
|
||||||
-#define PED_DISK_TYPE_LAST_FEATURE 8 // PED_DISK_TYPE_PARTITION_TYPE_UUID
|
|
||||||
+#define PED_DISK_TYPE_FIRST_FEATURE 1 // PED_DISK_TYPE_EXTENDED
|
|
||||||
+#define PED_DISK_TYPE_LAST_FEATURE 32 // PED_DISK_TYPE_PARTITION_UUID
|
|
||||||
|
|
||||||
struct _PedDisk;
|
|
||||||
struct _PedPartition;
|
|
||||||
@@ -228,6 +230,7 @@ struct _PedDiskOps {
|
|
||||||
int (*disk_is_flag_available) (
|
|
||||||
const PedDisk *disk,
|
|
||||||
PedDiskFlag flag);
|
|
||||||
+ uint8_t* (*disk_get_uuid) (const PedDisk* disk);
|
|
||||||
/** \todo add label guessing op here */
|
|
||||||
|
|
||||||
/* partition operations */
|
|
||||||
@@ -260,6 +263,8 @@ struct _PedDiskOps {
|
|
||||||
int (*partition_set_type_uuid) (PedPartition* part, const uint8_t* uuid);
|
|
||||||
uint8_t* (*partition_get_type_uuid) (const PedPartition* part);
|
|
||||||
|
|
||||||
+ uint8_t* (*partition_get_uuid) (const PedPartition* part);
|
|
||||||
+
|
|
||||||
int (*partition_align) (PedPartition* part,
|
|
||||||
const PedConstraint* constraint);
|
|
||||||
int (*partition_enumerate) (PedPartition* part);
|
|
||||||
@@ -331,6 +336,8 @@ extern int ped_disk_set_flag(PedDisk *disk, PedDiskFlag flag, int state);
|
|
||||||
extern int ped_disk_get_flag(const PedDisk *disk, PedDiskFlag flag);
|
|
||||||
extern int ped_disk_is_flag_available(const PedDisk *disk, PedDiskFlag flag);
|
|
||||||
|
|
||||||
+extern uint8_t* ped_disk_get_uuid (const PedDisk* disk);
|
|
||||||
+
|
|
||||||
extern const char *ped_disk_flag_get_name(PedDiskFlag flag);
|
|
||||||
extern PedDiskFlag ped_disk_flag_get_by_name(const char *name);
|
|
||||||
extern PedDiskFlag ped_disk_flag_next(PedDiskFlag flag) _GL_ATTRIBUTE_CONST;
|
|
||||||
@@ -367,6 +374,8 @@ extern uint8_t ped_partition_get_type_id (const PedPartition* part);
|
|
||||||
extern int ped_partition_set_type_uuid (PedPartition* part, const uint8_t* uuid);
|
|
||||||
extern uint8_t* ped_partition_get_type_uuid (const PedPartition* part);
|
|
||||||
|
|
||||||
+extern uint8_t* ped_partition_get_uuid (const PedPartition* part);
|
|
||||||
+
|
|
||||||
extern int ped_partition_is_busy (const PedPartition* part);
|
|
||||||
extern char* ped_partition_get_path (const PedPartition* part);
|
|
||||||
|
|
||||||
diff --git a/libparted/disk.c b/libparted/disk.c
|
|
||||||
index a961d65..0ed3d91 100644
|
|
||||||
--- a/libparted/disk.c
|
|
||||||
+++ b/libparted/disk.c
|
|
||||||
@@ -886,6 +886,37 @@ ped_disk_flag_next(PedDiskFlag flag)
|
|
||||||
return (flag + 1) % (PED_DISK_LAST_FLAG + 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int
|
|
||||||
+_assert_disk_uuid_feature (const PedDiskType* disk_type)
|
|
||||||
+{
|
|
||||||
+ if (!ped_disk_type_check_feature (
|
|
||||||
+ disk_type, PED_DISK_TYPE_DISK_UUID)) {
|
|
||||||
+ ped_exception_throw (
|
|
||||||
+ PED_EXCEPTION_ERROR,
|
|
||||||
+ PED_EXCEPTION_CANCEL,
|
|
||||||
+ "%s disk labels do not support disk uuids.",
|
|
||||||
+ disk_type->name);
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+ return 1;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/**
|
|
||||||
+ * Get the uuid of the disk \p disk. This will only work if the disk label
|
|
||||||
+ * supports it.
|
|
||||||
+ */
|
|
||||||
+uint8_t*
|
|
||||||
+ped_disk_get_uuid (const PedDisk *disk)
|
|
||||||
+{
|
|
||||||
+ PED_ASSERT (disk != NULL);
|
|
||||||
+
|
|
||||||
+ if (!_assert_disk_uuid_feature (disk->type))
|
|
||||||
+ return NULL;
|
|
||||||
+
|
|
||||||
+ PED_ASSERT (disk->type->ops->disk_get_uuid != NULL);
|
|
||||||
+ return disk->type->ops->disk_get_uuid (disk);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* \internal We turned a really nasty bureaucracy problem into an elegant maths
|
|
||||||
* problem :-) Basically, there are some constraints to a partition's
|
|
||||||
@@ -1488,6 +1519,21 @@ _assert_partition_type_uuid_feature (const PedDiskType* disk_type)
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
+static int
|
|
||||||
+_assert_partition_uuid_feature (const PedDiskType* disk_type)
|
|
||||||
+{
|
|
||||||
+ if (!ped_disk_type_check_feature (
|
|
||||||
+ disk_type, PED_DISK_TYPE_PARTITION_UUID)) {
|
|
||||||
+ ped_exception_throw (
|
|
||||||
+ PED_EXCEPTION_ERROR,
|
|
||||||
+ PED_EXCEPTION_CANCEL,
|
|
||||||
+ "%s disk labels do not support partition uuids.",
|
|
||||||
+ disk_type->name);
|
|
||||||
+ return 0;
|
|
||||||
+ }
|
|
||||||
+ return 1;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
/**
|
|
||||||
* Sets the name of a partition.
|
|
||||||
*
|
|
||||||
@@ -1612,6 +1658,24 @@ ped_partition_get_type_uuid (const PedPartition *part)
|
|
||||||
return part->disk->type->ops->partition_get_type_uuid (part);
|
|
||||||
}
|
|
||||||
|
|
||||||
+/**
|
|
||||||
+ * Get the uuid of the partition \p part. This will only work if the disk label
|
|
||||||
+ * supports it.
|
|
||||||
+ */
|
|
||||||
+uint8_t*
|
|
||||||
+ped_partition_get_uuid (const PedPartition *part)
|
|
||||||
+{
|
|
||||||
+ PED_ASSERT (part != NULL);
|
|
||||||
+ PED_ASSERT (part->disk != NULL);
|
|
||||||
+ PED_ASSERT (ped_partition_is_active (part));
|
|
||||||
+
|
|
||||||
+ if (!_assert_partition_uuid_feature (part->disk->type))
|
|
||||||
+ return NULL;
|
|
||||||
+
|
|
||||||
+ PED_ASSERT (part->disk->type->ops->partition_get_uuid != NULL);
|
|
||||||
+ return part->disk->type->ops->partition_get_uuid (part);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
/** @} */
|
|
||||||
|
|
||||||
/**
|
|
||||||
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
|
|
||||||
index 8e6a37d..1993863 100644
|
|
||||||
--- a/libparted/labels/gpt.c
|
|
||||||
+++ b/libparted/labels/gpt.c
|
|
||||||
@@ -1576,6 +1576,24 @@ gpt_disk_is_flag_available(const PedDisk *disk, PedDiskFlag flag)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
+static uint8_t*
|
|
||||||
+gpt_disk_get_uuid (const PedDisk *disk)
|
|
||||||
+{
|
|
||||||
+ GPTDiskData *gpt_disk_data = disk->disk_specific;
|
|
||||||
+
|
|
||||||
+ efi_guid_t uuid = gpt_disk_data->uuid;
|
|
||||||
+
|
|
||||||
+ /* uuid is always LE, while uint8_t is always kind of BE */
|
|
||||||
+
|
|
||||||
+ uuid.time_low = PED_SWAP32(uuid.time_low);
|
|
||||||
+ uuid.time_mid = PED_SWAP16(uuid.time_mid);
|
|
||||||
+ uuid.time_hi_and_version = PED_SWAP16(uuid.time_hi_and_version);
|
|
||||||
+
|
|
||||||
+ uint8_t *buf = ped_malloc(sizeof (uuid_t));
|
|
||||||
+ memcpy(buf, &uuid, sizeof (uuid_t));
|
|
||||||
+ return buf;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static int
|
|
||||||
gpt_disk_get_flag (const PedDisk *disk, PedDiskFlag flag)
|
|
||||||
{
|
|
||||||
@@ -1764,6 +1782,23 @@ gpt_partition_get_type_uuid (const PedPartition *part)
|
|
||||||
return buf;
|
|
||||||
}
|
|
||||||
|
|
||||||
+static uint8_t*
|
|
||||||
+gpt_partition_get_uuid (const PedPartition *part)
|
|
||||||
+{
|
|
||||||
+ const GPTPartitionData *gpt_part_data = part->disk_specific;
|
|
||||||
+
|
|
||||||
+ efi_guid_t uuid = gpt_part_data->uuid;
|
|
||||||
+
|
|
||||||
+ /* uuid is always LE, while uint8_t is always kind of BE */
|
|
||||||
+
|
|
||||||
+ uuid.time_low = PED_SWAP32(uuid.time_low);
|
|
||||||
+ uuid.time_mid = PED_SWAP16(uuid.time_mid);
|
|
||||||
+ uuid.time_hi_and_version = PED_SWAP16(uuid.time_hi_and_version);
|
|
||||||
+
|
|
||||||
+ uint8_t *buf = ped_malloc(sizeof (uuid_t));
|
|
||||||
+ memcpy(buf, &uuid, sizeof (uuid_t));
|
|
||||||
+ return buf;
|
|
||||||
+}
|
|
||||||
|
|
||||||
static int
|
|
||||||
gpt_get_max_primary_partition_count (const PedDisk *disk)
|
|
||||||
@@ -1864,9 +1899,11 @@ static PedDiskOps gpt_disk_ops =
|
|
||||||
partition_get_type_id: NULL,
|
|
||||||
partition_set_type_uuid: gpt_partition_set_type_uuid,
|
|
||||||
partition_get_type_uuid: gpt_partition_get_type_uuid,
|
|
||||||
+ partition_get_uuid: gpt_partition_get_uuid,
|
|
||||||
disk_set_flag: gpt_disk_set_flag,
|
|
||||||
disk_get_flag: gpt_disk_get_flag,
|
|
||||||
disk_is_flag_available: gpt_disk_is_flag_available,
|
|
||||||
+ disk_get_uuid: gpt_disk_get_uuid,
|
|
||||||
|
|
||||||
PT_op_function_initializers (gpt)
|
|
||||||
};
|
|
||||||
@@ -1876,7 +1913,8 @@ static PedDiskType gpt_disk_type =
|
|
||||||
next: NULL,
|
|
||||||
name: "gpt",
|
|
||||||
ops: &gpt_disk_ops,
|
|
||||||
- features: PED_DISK_TYPE_PARTITION_NAME | PED_DISK_TYPE_PARTITION_TYPE_UUID
|
|
||||||
+ features: PED_DISK_TYPE_PARTITION_NAME | PED_DISK_TYPE_PARTITION_TYPE_UUID |
|
|
||||||
+ PED_DISK_TYPE_DISK_UUID | PED_DISK_TYPE_PARTITION_UUID
|
|
||||||
};
|
|
||||||
|
|
||||||
void
|
|
||||||
diff --git a/parted/parted.c b/parted/parted.c
|
|
||||||
index 36c39c7..84187b7 100644
|
|
||||||
--- a/parted/parted.c
|
|
||||||
+++ b/parted/parted.c
|
|
||||||
@@ -1215,6 +1215,14 @@ _print_disk_info (const PedDevice *dev, const PedDisk *diskp)
|
|
||||||
ul_jsonwrt_value_u64 (&json, "physical-sector-size", dev->phys_sector_size);
|
|
||||||
ul_jsonwrt_value_s (&json, "label", pt_name);
|
|
||||||
if (diskp) {
|
|
||||||
+ bool has_disk_uuid = ped_disk_type_check_feature (diskp->type, PED_DISK_TYPE_DISK_UUID);
|
|
||||||
+ if (has_disk_uuid) {
|
|
||||||
+ uint8_t* uuid = ped_disk_get_uuid (diskp);
|
|
||||||
+ static char buf[UUID_STR_LEN];
|
|
||||||
+ uuid_unparse_lower (uuid, buf);
|
|
||||||
+ ul_jsonwrt_value_s (&json, "uuid", buf);
|
|
||||||
+ free (uuid);
|
|
||||||
+ }
|
|
||||||
ul_jsonwrt_value_u64 (&json, "max-partitions",
|
|
||||||
ped_disk_get_max_primary_partition_count(diskp));
|
|
||||||
disk_print_flags_json (diskp);
|
|
||||||
@@ -1360,6 +1368,8 @@ do_print (PedDevice** dev, PedDisk** diskp)
|
|
||||||
PED_DISK_TYPE_PARTITION_TYPE_ID);
|
|
||||||
bool has_type_uuid = ped_disk_type_check_feature ((*diskp)->type,
|
|
||||||
PED_DISK_TYPE_PARTITION_TYPE_UUID);
|
|
||||||
+ bool has_part_uuid = ped_disk_type_check_feature ((*diskp)->type,
|
|
||||||
+ PED_DISK_TYPE_PARTITION_UUID);
|
|
||||||
|
|
||||||
PedPartition* part;
|
|
||||||
if (opt_output_mode == HUMAN) {
|
|
||||||
@@ -1512,6 +1522,14 @@ do_print (PedDevice** dev, PedDisk** diskp)
|
|
||||||
free (type_uuid);
|
|
||||||
}
|
|
||||||
|
|
||||||
+ if (has_part_uuid) {
|
|
||||||
+ uint8_t* uuid = ped_partition_get_uuid (part);
|
|
||||||
+ static char buf[UUID_STR_LEN];
|
|
||||||
+ uuid_unparse_lower (uuid, buf);
|
|
||||||
+ ul_jsonwrt_value_s (&json, "uuid", buf);
|
|
||||||
+ free (uuid);
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
if (has_name) {
|
|
||||||
name = ped_partition_get_name (part);
|
|
||||||
if (strcmp (name, "") != 0)
|
|
||||||
diff --git a/tests/t0800-json-gpt.sh b/tests/t0800-json-gpt.sh
|
|
||||||
index 354c0bd..f6a3fb9 100755
|
|
||||||
--- a/tests/t0800-json-gpt.sh
|
|
||||||
+++ b/tests/t0800-json-gpt.sh
|
|
||||||
@@ -32,8 +32,8 @@ parted --script "$dev" mkpart "test1" ext4 10% 20% > out 2>&1 || fail=1
|
|
||||||
parted --script "$dev" mkpart "test2" xfs 20% 60% > out 2>&1 || fail=1
|
|
||||||
parted --script "$dev" set 2 raid on > out 2>&1 || fail=1
|
|
||||||
|
|
||||||
-# print with json format
|
|
||||||
-parted --script --json "$dev" unit s print free > out 2>&1 || fail=1
|
|
||||||
+# print with json format, replace non-deterministic uuids
|
|
||||||
+parted --script --json "$dev" unit s print free | sed -E 's/"uuid": "[0-9a-f-]{36}"/"uuid": "<uuid>"/' > out 2>&1 || fail=1
|
|
||||||
|
|
||||||
cat <<EOF > exp || fail=1
|
|
||||||
{
|
|
||||||
@@ -45,6 +45,7 @@ cat <<EOF > exp || fail=1
|
|
||||||
"logical-sector-size": 512,
|
|
||||||
"physical-sector-size": 512,
|
|
||||||
"label": "gpt",
|
|
||||||
+ "uuid": "<uuid>",
|
|
||||||
"max-partitions": 128,
|
|
||||||
"flags": [
|
|
||||||
"pmbr_boot"
|
|
||||||
@@ -63,6 +64,7 @@ cat <<EOF > exp || fail=1
|
|
||||||
"size": "10240s",
|
|
||||||
"type": "primary",
|
|
||||||
"type-uuid": "0fc63daf-8483-4772-8e79-3d69d8477de4",
|
|
||||||
+ "uuid": "<uuid>",
|
|
||||||
"name": "test1"
|
|
||||||
},{
|
|
||||||
"number": 2,
|
|
||||||
@@ -71,6 +73,7 @@ cat <<EOF > exp || fail=1
|
|
||||||
"size": "40960s",
|
|
||||||
"type": "primary",
|
|
||||||
"type-uuid": "a19d880f-05fc-4d3b-a006-743f0f84911e",
|
|
||||||
+ "uuid": "<uuid>",
|
|
||||||
"name": "test2",
|
|
||||||
"flags": [
|
|
||||||
"raid"
|
|
||||||
diff --git a/tests/t0900-type-gpt.sh b/tests/t0900-type-gpt.sh
|
|
||||||
index 2014820..03febba 100755
|
|
||||||
--- a/tests/t0900-type-gpt.sh
|
|
||||||
+++ b/tests/t0900-type-gpt.sh
|
|
||||||
@@ -32,8 +32,8 @@ parted --script "$dev" mkpart "''" "linux-swap" 10% 20% > out 2>&1 || fail=1
|
|
||||||
# set type-uuid
|
|
||||||
parted --script "$dev" type 1 "deadfd6d-a4ab-43c4-84e5-0933c84b4f4f" || fail=1
|
|
||||||
|
|
||||||
-# print with json format
|
|
||||||
-parted --script --json "$dev" unit s print > out 2>&1 || fail=1
|
|
||||||
+# print with json format, replace non-deterministic uuids
|
|
||||||
+parted --script --json "$dev" unit s print | sed -E 's/"uuid": "[0-9a-f-]{36}"/"uuid": "<uuid>"/' > out 2>&1 || fail=1
|
|
||||||
|
|
||||||
cat <<EOF > exp || fail=1
|
|
||||||
{
|
|
||||||
@@ -45,6 +45,7 @@ cat <<EOF > exp || fail=1
|
|
||||||
"logical-sector-size": 512,
|
|
||||||
"physical-sector-size": 512,
|
|
||||||
"label": "gpt",
|
|
||||||
+ "uuid": "<uuid>",
|
|
||||||
"max-partitions": 128,
|
|
||||||
"partitions": [
|
|
||||||
{
|
|
||||||
@@ -53,7 +54,8 @@ cat <<EOF > exp || fail=1
|
|
||||||
"end": "20479s",
|
|
||||||
"size": "10240s",
|
|
||||||
"type": "primary",
|
|
||||||
- "type-uuid": "deadfd6d-a4ab-43c4-84e5-0933c84b4f4f"
|
|
||||||
+ "type-uuid": "deadfd6d-a4ab-43c4-84e5-0933c84b4f4f",
|
|
||||||
+ "uuid": "<uuid>"
|
|
||||||
}
|
|
||||||
]
|
|
||||||
}
|
|
||||||
--
|
|
||||||
2.37.3
|
|
||||||
|
|
@ -1,145 +0,0 @@
|
|||||||
From 55e4775c989af42d629401b9aa22c60ba2993e7d Mon Sep 17 00:00:00 2001
|
|
||||||
From: Mike Fleetwood <mike.fleetwood@googlemail.com>
|
|
||||||
Date: Tue, 13 Dec 2022 12:53:07 +0000
|
|
||||||
Subject: [PATCH] gpt: Add no_automount partition flag
|
|
||||||
|
|
||||||
Add user requested support for GPT partition type attribute bit 63 [1]
|
|
||||||
so the no-auto flag in the systemd originated Discoverable Partitions
|
|
||||||
Specification [2] can be manipulated. The UEFI specification [3] says
|
|
||||||
partition attribute bits 48 to 63 are partition type specific, however
|
|
||||||
the DPS [2] and Microsoft [4] use the bit 63 to mean no automounting /
|
|
||||||
assign no drive letter and apply it to multiple partition types so don't
|
|
||||||
restrict its application.
|
|
||||||
|
|
||||||
[1] Request for GPT partition attribute bit 63 "no automount" editing
|
|
||||||
support
|
|
||||||
https://gitlab.gnome.org/GNOME/gparted/-/issues/214
|
|
||||||
[2] The Discoverable Partitions Specification (DPS),
|
|
||||||
Partition Attribute Flags
|
|
||||||
https://uapi-group.org/specifications/specs/discoverable_partitions_specification/
|
|
||||||
[3] UEFI Specification, version 2.8,
|
|
||||||
Table 24. Defined GPT Partition Entry - Attributes
|
|
||||||
https://uefi.org/sites/default/files/resources/UEFI_Spec_2_8_final.pdf
|
|
||||||
[4] CREATE_PARTITION_PARAMETERS structure (vds.h)
|
|
||||||
https://learn.microsoft.com/en-gb/windows/win32/api/vds/ns-vds-create_partition_parameters
|
|
||||||
|
|
||||||
Signed-off-by: Mike Fleetwood <mike.fleetwood@googlemail.com>
|
|
||||||
Signed-off-by: Brian C. Lane <bcl@redhat.com>
|
|
||||||
---
|
|
||||||
NEWS | 2 ++
|
|
||||||
doc/C/parted.8 | 2 +-
|
|
||||||
include/parted/disk.in.h | 3 ++-
|
|
||||||
libparted/disk.c | 2 ++
|
|
||||||
libparted/labels/gpt.c | 12 ++++++++++--
|
|
||||||
5 files changed, 17 insertions(+), 4 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/NEWS b/NEWS
|
|
||||||
index 099f8bd..ac759fe 100644
|
|
||||||
--- a/NEWS
|
|
||||||
+++ b/NEWS
|
|
||||||
@@ -4,6 +4,8 @@ GNU parted NEWS -*- outline -*-
|
|
||||||
|
|
||||||
** New Features
|
|
||||||
|
|
||||||
+ Support GPT partition attribute bit 63 as no_automount flag.
|
|
||||||
+
|
|
||||||
Add type commands to set type-id on MS-DOS and type-uuid on GPT.
|
|
||||||
|
|
||||||
* Noteworthy changes in release 3.5 (2022-04-18) [stable]
|
|
||||||
diff --git a/doc/C/parted.8 b/doc/C/parted.8
|
|
||||||
index ab34be7..3069c33 100644
|
|
||||||
--- a/doc/C/parted.8
|
|
||||||
+++ b/doc/C/parted.8
|
|
||||||
@@ -120,7 +120,7 @@ or an LVM logical volume if necessary.
|
|
||||||
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", "msftres", "esp", "chromeos_kernel", "bls_boot", "linux-home",
|
|
||||||
-"bios_grub", and "palo".
|
|
||||||
+"no_automount", "bios_grub", and "palo".
|
|
||||||
\fIstate\fP should be either "on" or "off".
|
|
||||||
.TP
|
|
||||||
.B unit \fIunit\fP
|
|
||||||
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
|
|
||||||
index f649bcc..402d78a 100644
|
|
||||||
--- a/include/parted/disk.in.h
|
|
||||||
+++ b/include/parted/disk.in.h
|
|
||||||
@@ -88,10 +88,11 @@ enum _PedPartitionFlag {
|
|
||||||
PED_PARTITION_CHROMEOS_KERNEL=19,
|
|
||||||
PED_PARTITION_BLS_BOOT=20,
|
|
||||||
PED_PARTITION_LINUX_HOME=21,
|
|
||||||
+ PED_PARTITION_NO_AUTOMOUNT=22,
|
|
||||||
};
|
|
||||||
// NOTE: DO NOT define using enums
|
|
||||||
#define PED_PARTITION_FIRST_FLAG 1 // PED_PARTITION_BOOT
|
|
||||||
-#define PED_PARTITION_LAST_FLAG 21 // PED_PARTITION_LINUX_HOME
|
|
||||||
+#define PED_PARTITION_LAST_FLAG 22 // PED_PARTITION_NO_AUTOMOUNT
|
|
||||||
|
|
||||||
enum _PedDiskTypeFeature {
|
|
||||||
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
|
|
||||||
diff --git a/libparted/disk.c b/libparted/disk.c
|
|
||||||
index 0ed3d91..45f35fd 100644
|
|
||||||
--- a/libparted/disk.c
|
|
||||||
+++ b/libparted/disk.c
|
|
||||||
@@ -2579,6 +2579,8 @@ ped_partition_flag_get_name (PedPartitionFlag flag)
|
|
||||||
return N_("bls_boot");
|
|
||||||
case PED_PARTITION_LINUX_HOME:
|
|
||||||
return N_("linux-home");
|
|
||||||
+ case PED_PARTITION_NO_AUTOMOUNT:
|
|
||||||
+ return N_("no_automount");
|
|
||||||
|
|
||||||
default:
|
|
||||||
ped_exception_throw (
|
|
||||||
diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c
|
|
||||||
index 1993863..780fb70 100644
|
|
||||||
--- a/libparted/labels/gpt.c
|
|
||||||
+++ b/libparted/labels/gpt.c
|
|
||||||
@@ -252,7 +252,8 @@ struct __attribute__ ((packed)) _GuidPartitionEntryAttributes_t
|
|
||||||
uint64_t NoBlockIOProtocol:1;
|
|
||||||
uint64_t LegacyBIOSBootable:1;
|
|
||||||
uint64_t Reserved:45;
|
|
||||||
- uint64_t GuidSpecific:16;
|
|
||||||
+ uint64_t GuidSpecific:15;
|
|
||||||
+ uint64_t NoAutomount:1;
|
|
||||||
#else
|
|
||||||
# warning "Using crippled partition entry type"
|
|
||||||
uint32_t RequiredToFunction:1;
|
|
||||||
@@ -260,7 +261,8 @@ struct __attribute__ ((packed)) _GuidPartitionEntryAttributes_t
|
|
||||||
uint32_t LegacyBIOSBootable:1;
|
|
||||||
uint32_t Reserved:30;
|
|
||||||
uint32_t LOST:5;
|
|
||||||
- uint32_t GuidSpecific:16;
|
|
||||||
+ uint32_t GuidSpecific:15;
|
|
||||||
+ uint32_t NoAutomount:1;
|
|
||||||
#endif
|
|
||||||
};
|
|
||||||
|
|
||||||
@@ -1637,6 +1639,9 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state)
|
|
||||||
case PED_PARTITION_LEGACY_BOOT:
|
|
||||||
gpt_part_data->attributes.LegacyBIOSBootable = state;
|
|
||||||
return 1;
|
|
||||||
+ case PED_PARTITION_NO_AUTOMOUNT:
|
|
||||||
+ gpt_part_data->attributes.NoAutomount = state;
|
|
||||||
+ return 1;
|
|
||||||
case PED_PARTITION_ROOT:
|
|
||||||
case PED_PARTITION_LBA:
|
|
||||||
default:
|
|
||||||
@@ -1662,6 +1667,8 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag)
|
|
||||||
return gpt_part_data->attributes.RequiredToFunction;
|
|
||||||
case PED_PARTITION_LEGACY_BOOT:
|
|
||||||
return gpt_part_data->attributes.LegacyBIOSBootable;
|
|
||||||
+ case PED_PARTITION_NO_AUTOMOUNT:
|
|
||||||
+ return gpt_part_data->attributes.NoAutomount;
|
|
||||||
case PED_PARTITION_LBA:
|
|
||||||
case PED_PARTITION_ROOT:
|
|
||||||
default:
|
|
||||||
@@ -1681,6 +1688,7 @@ gpt_partition_is_flag_available (const PedPartition *part,
|
|
||||||
{
|
|
||||||
case PED_PARTITION_HIDDEN:
|
|
||||||
case PED_PARTITION_LEGACY_BOOT:
|
|
||||||
+ case PED_PARTITION_NO_AUTOMOUNT:
|
|
||||||
return 1;
|
|
||||||
case PED_PARTITION_ROOT:
|
|
||||||
case PED_PARTITION_LBA:
|
|
||||||
--
|
|
||||||
2.38.1
|
|
||||||
|
|
@ -1,54 +0,0 @@
|
|||||||
From caa588269709659d5cf51bf64c559e193f371de4 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Tue, 13 Dec 2022 14:38:24 -0800
|
|
||||||
Subject: [PATCH] tests: XFS requires a minimum size of 300M
|
|
||||||
|
|
||||||
---
|
|
||||||
tests/t1700-probe-fs.sh | 3 ++-
|
|
||||||
tests/t4100-dvh-partition-limits.sh | 2 +-
|
|
||||||
tests/t4100-msdos-partition-limits.sh | 2 +-
|
|
||||||
3 files changed, 4 insertions(+), 3 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh
|
|
||||||
index d33606e..f8af74e 100755
|
|
||||||
--- a/tests/t1700-probe-fs.sh
|
|
||||||
+++ b/tests/t1700-probe-fs.sh
|
|
||||||
@@ -42,7 +42,8 @@ for type in ext2 ext3 ext4 btrfs xfs nilfs2 ntfs vfat hfsplus udf f2fs; do
|
|
||||||
# create an $type file system, creation failures are not parted bugs,
|
|
||||||
# skip the filesystem instead of failing the test.
|
|
||||||
if [ "$type" = "xfs" ]; then
|
|
||||||
- mkfs.xfs -ssize=$ss -dfile,name=$dev,size=${n_sectors}s || { warn_ "$ME: mkfs.$type failed, skipping"; continue; }
|
|
||||||
+ # XFS requires at least 300M which is > 1024 sectors with 8192b sector size
|
|
||||||
+ mkfs.xfs -ssize=$ss -dfile,name=$dev,size=300m || { warn_ "$ME: mkfs.$type failed, skipping"; continue; }
|
|
||||||
else
|
|
||||||
dd if=/dev/null of=$dev bs=$ss seek=$n_sectors >/dev/null || { warn_ "$ME: dd failed, skipping $type"; continue; }
|
|
||||||
mkfs.$type $force $dev || { warn_ "$ME: mkfs.$type failed skipping"; continue; }
|
|
||||||
diff --git a/tests/t4100-dvh-partition-limits.sh b/tests/t4100-dvh-partition-limits.sh
|
|
||||||
index d3798d2..a5b3516 100755
|
|
||||||
--- a/tests/t4100-dvh-partition-limits.sh
|
|
||||||
+++ b/tests/t4100-dvh-partition-limits.sh
|
|
||||||
@@ -37,7 +37,7 @@ mp=`pwd`/mount-point
|
|
||||||
n=4096
|
|
||||||
|
|
||||||
# create an XFS file system
|
|
||||||
-mkfs.xfs -dfile,name=$fs,size=100m || fail=1
|
|
||||||
+mkfs.xfs -dfile,name=$fs,size=300m || fail=1
|
|
||||||
mkdir "$mp" || fail=1
|
|
||||||
|
|
||||||
# Unmount upon interrupt, failure, etc., as well as upon normal completion.
|
|
||||||
diff --git a/tests/t4100-msdos-partition-limits.sh b/tests/t4100-msdos-partition-limits.sh
|
|
||||||
index b591123..09267b5 100755
|
|
||||||
--- a/tests/t4100-msdos-partition-limits.sh
|
|
||||||
+++ b/tests/t4100-msdos-partition-limits.sh
|
|
||||||
@@ -37,7 +37,7 @@ mp=`pwd`/mount-point
|
|
||||||
n=4096
|
|
||||||
|
|
||||||
# create an XFS file system
|
|
||||||
-mkfs.xfs -dfile,name=$fs,size=100m || fail=1
|
|
||||||
+mkfs.xfs -dfile,name=$fs,size=300m || fail=1
|
|
||||||
mkdir "$mp" || fail=1
|
|
||||||
|
|
||||||
# Unmount upon interrupt, failure, etc., as well as upon normal completion.
|
|
||||||
--
|
|
||||||
2.38.1
|
|
||||||
|
|
@ -1,133 +0,0 @@
|
|||||||
From 9b009985da2e5eee5b5c179acfafab3aa1624f8b Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Tue, 10 May 2022 15:04:12 -0700
|
|
||||||
Subject: [PATCH 16/17] libparted: Fix problem with creating 1s partitions
|
|
||||||
|
|
||||||
There was a 1-off error in _partition_get_overlap_constraint that
|
|
||||||
prevented partitions from being created in 1s free space. You could
|
|
||||||
create 1s partitions as long they were done in order, but not after
|
|
||||||
leaving 'holes'.
|
|
||||||
|
|
||||||
This fixes this and adds tests for it on msdos and gpt disklabels.
|
|
||||||
---
|
|
||||||
libparted/disk.c | 2 +-
|
|
||||||
tests/Makefile.am | 2 ++
|
|
||||||
tests/t9024-msdos-1s-partition.sh | 36 +++++++++++++++++++++++++++++++
|
|
||||||
tests/t9025-gpt-1s-partition.sh | 36 +++++++++++++++++++++++++++++++
|
|
||||||
4 files changed, 75 insertions(+), 1 deletion(-)
|
|
||||||
create mode 100644 tests/t9024-msdos-1s-partition.sh
|
|
||||||
create mode 100644 tests/t9025-gpt-1s-partition.sh
|
|
||||||
|
|
||||||
diff --git a/libparted/disk.c b/libparted/disk.c
|
|
||||||
index 45f35fd..e1a3489 100644
|
|
||||||
--- a/libparted/disk.c
|
|
||||||
+++ b/libparted/disk.c
|
|
||||||
@@ -1960,7 +1960,7 @@ _partition_get_overlap_constraint (PedPartition* part, PedGeometry* geom)
|
|
||||||
if (walk)
|
|
||||||
max_end = walk->geom.start - 1;
|
|
||||||
|
|
||||||
- if (min_start >= max_end)
|
|
||||||
+ if (min_start > max_end)
|
|
||||||
return NULL;
|
|
||||||
|
|
||||||
ped_geometry_init (&free_space, part->disk->dev,
|
|
||||||
diff --git a/tests/Makefile.am b/tests/Makefile.am
|
|
||||||
index 1d109d7..fa27b44 100644
|
|
||||||
--- a/tests/Makefile.am
|
|
||||||
+++ b/tests/Makefile.am
|
|
||||||
@@ -91,6 +91,8 @@ TESTS = \
|
|
||||||
t9021-maxima.sh \
|
|
||||||
t9022-one-unit-snap.sh \
|
|
||||||
t9023-value-lt-one.sh \
|
|
||||||
+ t9024-msdos-1s-partition.sh \
|
|
||||||
+ t9025-gpt-1s-partition.sh \
|
|
||||||
t9030-align-check.sh \
|
|
||||||
t9040-many-partitions.sh \
|
|
||||||
t9041-undetected-in-use-16th-partition.sh \
|
|
||||||
diff --git a/tests/t9024-msdos-1s-partition.sh b/tests/t9024-msdos-1s-partition.sh
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..7115156
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/tests/t9024-msdos-1s-partition.sh
|
|
||||||
@@ -0,0 +1,36 @@
|
|
||||||
+#!/bin/sh
|
|
||||||
+# Test creating 1s partitions in 1s free space
|
|
||||||
+
|
|
||||||
+# Copyright (C) 2022 Free Software Foundation, Inc.
|
|
||||||
+
|
|
||||||
+# This program is free software; you can redistribute it and/or modify
|
|
||||||
+# it under the terms of the GNU General Public License as published by
|
|
||||||
+# the Free Software Foundation; either version 3 of the License, or
|
|
||||||
+# (at your option) any later version.
|
|
||||||
+
|
|
||||||
+# This program is distributed in the hope that it will be useful,
|
|
||||||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+# GNU General Public License for more details.
|
|
||||||
+
|
|
||||||
+# You should have received a copy of the GNU General Public License
|
|
||||||
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
+
|
|
||||||
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
|
|
||||||
+
|
|
||||||
+dev=loop-file
|
|
||||||
+
|
|
||||||
+# create device
|
|
||||||
+truncate --size 10MiB "$dev" || fail=1
|
|
||||||
+
|
|
||||||
+# create msdos label and some partitions with 1s free space between
|
|
||||||
+parted --script "$dev" mklabel msdos > out 2>&1 || fail=1
|
|
||||||
+parted --script "$dev" mkpart primary ext4 64s 128s > out 2>&1 || fail=1
|
|
||||||
+parted --script "$dev" mkpart primary ext4 130s 200s > out 2>&1 || fail=1
|
|
||||||
+parted --script "$dev" u s p free
|
|
||||||
+
|
|
||||||
+# Free space is at 129s
|
|
||||||
+parted --script "$dev" mkpart primary ext4 129s 129s > out 2>&1 || fail=1
|
|
||||||
+parted --script "$dev" u s p free
|
|
||||||
+
|
|
||||||
+Exit $fail
|
|
||||||
diff --git a/tests/t9025-gpt-1s-partition.sh b/tests/t9025-gpt-1s-partition.sh
|
|
||||||
new file mode 100644
|
|
||||||
index 0000000..c97ab8b
|
|
||||||
--- /dev/null
|
|
||||||
+++ b/tests/t9025-gpt-1s-partition.sh
|
|
||||||
@@ -0,0 +1,36 @@
|
|
||||||
+#!/bin/sh
|
|
||||||
+# Test creating 1s partitions in 1s free space
|
|
||||||
+
|
|
||||||
+# Copyright (C) 2022 Free Software Foundation, Inc.
|
|
||||||
+
|
|
||||||
+# This program is free software; you can redistribute it and/or modify
|
|
||||||
+# it under the terms of the GNU General Public License as published by
|
|
||||||
+# the Free Software Foundation; either version 3 of the License, or
|
|
||||||
+# (at your option) any later version.
|
|
||||||
+
|
|
||||||
+# This program is distributed in the hope that it will be useful,
|
|
||||||
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
+# GNU General Public License for more details.
|
|
||||||
+
|
|
||||||
+# You should have received a copy of the GNU General Public License
|
|
||||||
+# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
+
|
|
||||||
+. "${srcdir=.}/init.sh"; path_prepend_ ../parted
|
|
||||||
+
|
|
||||||
+dev=loop-file
|
|
||||||
+
|
|
||||||
+# create device
|
|
||||||
+truncate --size 10MiB "$dev" || fail=1
|
|
||||||
+
|
|
||||||
+# create msdos label and some partitions with 1s free space between
|
|
||||||
+parted --script "$dev" mklabel gpt > out 2>&1 || fail=1
|
|
||||||
+parted --script "$dev" mkpart p1 ext4 64s 128s > out 2>&1 || fail=1
|
|
||||||
+parted --script "$dev" mkpart p2 ext4 130s 200s > out 2>&1 || fail=1
|
|
||||||
+parted --script "$dev" u s p free
|
|
||||||
+
|
|
||||||
+# Free space is at 129s
|
|
||||||
+parted --script "$dev" mkpart p3 ext4 129s 129s > out 2>&1 || fail=1
|
|
||||||
+parted --script "$dev" u s p free
|
|
||||||
+
|
|
||||||
+Exit $fail
|
|
||||||
--
|
|
||||||
2.39.1
|
|
||||||
|
|
@ -1,262 +0,0 @@
|
|||||||
From 7b555132be63172a2d621afcdedfa7797185d3b5 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Tue, 7 Feb 2023 09:31:42 -0800
|
|
||||||
Subject: [PATCH 17/17] tests: Fixing libparted test framework usage
|
|
||||||
|
|
||||||
The fail and fail_if functions from libcheck are deprecated, replace
|
|
||||||
them with ck_abort_msg and ck_assert_msg. Note that the logic of assert
|
|
||||||
is the opposite of fail_if.
|
|
||||||
---
|
|
||||||
libparted/tests/common.c | 8 ++++----
|
|
||||||
libparted/tests/disk.c | 6 +++---
|
|
||||||
libparted/tests/flags.c | 6 +++---
|
|
||||||
libparted/tests/label.c | 14 ++++++--------
|
|
||||||
libparted/tests/symlink.c | 31 +++++++++++++++++++++----------
|
|
||||||
libparted/tests/volser.c | 2 +-
|
|
||||||
libparted/tests/zerolen.c | 2 +-
|
|
||||||
7 files changed, 39 insertions(+), 30 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libparted/tests/common.c b/libparted/tests/common.c
|
|
||||||
index 2be0e3a..8c42ece 100644
|
|
||||||
--- a/libparted/tests/common.c
|
|
||||||
+++ b/libparted/tests/common.c
|
|
||||||
@@ -27,7 +27,7 @@ size_t get_sector_size (void)
|
|
||||||
PedExceptionOption
|
|
||||||
_test_exception_handler (PedException* e)
|
|
||||||
{
|
|
||||||
- fail ("Exception of type %s has been raised: %s",
|
|
||||||
+ ck_abort_msg("Exception of type %s has been raised: %s",
|
|
||||||
ped_exception_get_type_string (e->type),
|
|
||||||
e->message);
|
|
||||||
|
|
||||||
@@ -69,10 +69,10 @@ _create_disk_label (PedDevice *dev, PedDiskType *type)
|
|
||||||
|
|
||||||
/* Create the label */
|
|
||||||
disk = ped_disk_new_fresh (dev, type);
|
|
||||||
- fail_if (!disk, "Failed to create a label of type: %s",
|
|
||||||
+ ck_assert_msg(disk != NULL, "Failed to create a label of type: %s",
|
|
||||||
type->name);
|
|
||||||
- fail_if (!ped_disk_commit(disk),
|
|
||||||
- "Failed to commit label to device");
|
|
||||||
+ ck_assert_msg(ped_disk_commit(disk) != 0,
|
|
||||||
+ "Failed to commit label to device");
|
|
||||||
|
|
||||||
return disk;
|
|
||||||
}
|
|
||||||
diff --git a/libparted/tests/disk.c b/libparted/tests/disk.c
|
|
||||||
index 62d20c1..f7b16a5 100644
|
|
||||||
--- a/libparted/tests/disk.c
|
|
||||||
+++ b/libparted/tests/disk.c
|
|
||||||
@@ -14,7 +14,7 @@ static void
|
|
||||||
create_disk (void)
|
|
||||||
{
|
|
||||||
temporary_disk = _create_disk (get_sector_size () * 4 * 10 * 1024);
|
|
||||||
- fail_if (temporary_disk == NULL, "Failed to create temporary disk");
|
|
||||||
+ ck_assert_msg(temporary_disk != NULL, "Failed to create temporary disk");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
@@ -72,8 +72,8 @@ START_TEST (test_duplicate)
|
|
||||||
part = ped_disk_get_partition (disk, *i);
|
|
||||||
part_dup = ped_disk_get_partition (disk_dup, *i);
|
|
||||||
|
|
||||||
- fail_if (part->geom.start != part_dup->geom.start ||
|
|
||||||
- part->geom.end != part_dup->geom.end,
|
|
||||||
+ ck_assert_msg(part->geom.start == part_dup->geom.start &&
|
|
||||||
+ part->geom.end == part_dup->geom.end,
|
|
||||||
"Duplicated partition %d doesn't match. "
|
|
||||||
"Details are start: %d/%d end: %d/%d\n",
|
|
||||||
*i, part->geom.start, part_dup->geom.start,
|
|
||||||
diff --git a/libparted/tests/flags.c b/libparted/tests/flags.c
|
|
||||||
index c4b290b..ff4ae71 100644
|
|
||||||
--- a/libparted/tests/flags.c
|
|
||||||
+++ b/libparted/tests/flags.c
|
|
||||||
@@ -16,7 +16,7 @@ static void
|
|
||||||
create_disk (void)
|
|
||||||
{
|
|
||||||
temporary_disk = _create_disk (80 * 1024 * 1024);
|
|
||||||
- fail_if (temporary_disk == NULL, "Failed to create temporary disk");
|
|
||||||
+ ck_assert_msg(temporary_disk != NULL, "Failed to create temporary disk");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
@@ -47,7 +47,7 @@ START_TEST (test_gpt_flag)
|
|
||||||
|
|
||||||
// Check flag to confirm it is still set
|
|
||||||
part = ped_disk_get_partition (disk, 1);
|
|
||||||
- fail_if (ped_partition_get_flag(part, PED_PARTITION_BIOS_GRUB) != 1, "BIOS_GRUB flag not set");
|
|
||||||
+ ck_assert_msg(ped_partition_get_flag(part, PED_PARTITION_BIOS_GRUB) == 1, "BIOS_GRUB flag not set");
|
|
||||||
|
|
||||||
ped_disk_destroy (disk);
|
|
||||||
ped_device_destroy (dev);
|
|
||||||
@@ -75,7 +75,7 @@ START_TEST (test_msdos_flag)
|
|
||||||
|
|
||||||
// Check flag to confirm it is still set
|
|
||||||
part = ped_disk_get_partition (disk, 1);
|
|
||||||
- fail_if (ped_partition_get_flag(part, PED_PARTITION_BLS_BOOT) != 1, "BLS_BOOT flag not set");
|
|
||||||
+ ck_assert_msg(ped_partition_get_flag(part, PED_PARTITION_BLS_BOOT) == 1, "BLS_BOOT flag not set");
|
|
||||||
|
|
||||||
ped_disk_destroy (disk);
|
|
||||||
ped_device_destroy (dev);
|
|
||||||
diff --git a/libparted/tests/label.c b/libparted/tests/label.c
|
|
||||||
index e0d63c7..67b1b07 100644
|
|
||||||
--- a/libparted/tests/label.c
|
|
||||||
+++ b/libparted/tests/label.c
|
|
||||||
@@ -16,7 +16,7 @@ static void
|
|
||||||
create_disk (void)
|
|
||||||
{
|
|
||||||
temporary_disk = _create_disk (80 * 1024 * 1024);
|
|
||||||
- fail_if (temporary_disk == NULL, "Failed to create temporary disk");
|
|
||||||
+ ck_assert_msg(temporary_disk != NULL, "Failed to create temporary disk");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
@@ -72,12 +72,11 @@ START_TEST (test_probe_label)
|
|
||||||
|
|
||||||
/* Try to probe the disk label. */
|
|
||||||
probed = ped_disk_probe (dev);
|
|
||||||
- fail_if (!probed,
|
|
||||||
+ ck_assert_msg(probed,
|
|
||||||
"Failed to probe the just created label of type: %s",
|
|
||||||
type->name);
|
|
||||||
if (probed && !STREQ (probed->name, type->name))
|
|
||||||
- fail_if (1,
|
|
||||||
- "Probe returned label of type: %s as type: %s",
|
|
||||||
+ ck_abort_msg("Probe returned label of type: %s as type: %s",
|
|
||||||
type->name, probed->name);
|
|
||||||
}
|
|
||||||
ped_device_destroy (dev);
|
|
||||||
@@ -105,12 +104,11 @@ START_TEST (test_read_label)
|
|
||||||
|
|
||||||
/* Try to read the disk label. */
|
|
||||||
disk = ped_disk_new (dev);
|
|
||||||
- fail_if (!disk,
|
|
||||||
+ ck_assert_msg(disk,
|
|
||||||
"Failed to read the just created label of type: %s",
|
|
||||||
type->name);
|
|
||||||
if (disk && !STREQ (disk->type->name, type->name))
|
|
||||||
- fail_if (1,
|
|
||||||
- "Read returned label of type: %s as type: %s",
|
|
||||||
+ ck_abort_msg("Read returned label of type: %s as type: %s",
|
|
||||||
type->name, disk->type->name);
|
|
||||||
|
|
||||||
ped_disk_destroy (disk);
|
|
||||||
@@ -138,7 +136,7 @@ START_TEST (test_clone_label)
|
|
||||||
|
|
||||||
/* Try to clone the disk label. */
|
|
||||||
PedDisk* clone = ped_disk_duplicate (disk);
|
|
||||||
- fail_if (!clone,
|
|
||||||
+ ck_assert_msg(clone,
|
|
||||||
"Failed to clone the just created label of type: %s",
|
|
||||||
type->name);
|
|
||||||
|
|
||||||
diff --git a/libparted/tests/symlink.c b/libparted/tests/symlink.c
|
|
||||||
index 52e99ca..da6bef8 100644
|
|
||||||
--- a/libparted/tests/symlink.c
|
|
||||||
+++ b/libparted/tests/symlink.c
|
|
||||||
@@ -30,7 +30,7 @@ static void
|
|
||||||
create_disk (void)
|
|
||||||
{
|
|
||||||
temporary_disk = _create_disk (4096 * 1024);
|
|
||||||
- fail_if (temporary_disk == NULL, "Failed to create temporary disk");
|
|
||||||
+ ck_assert_msg(temporary_disk != NULL, "Failed to create temporary disk");
|
|
||||||
}
|
|
||||||
|
|
||||||
static void
|
|
||||||
@@ -45,7 +45,7 @@ START_TEST (test_symlink)
|
|
||||||
char cwd[256], ln[256] = "/dev/mapper/parted-test-XXXXXX";
|
|
||||||
|
|
||||||
if (!getcwd (cwd, sizeof cwd)) {
|
|
||||||
- fail ("Could not get cwd");
|
|
||||||
+ ck_abort_msg("Could not get cwd");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -53,7 +53,7 @@ START_TEST (test_symlink)
|
|
||||||
temporary disk */
|
|
||||||
int tmp_fd = mkstemp (ln);
|
|
||||||
if (tmp_fd == -1) {
|
|
||||||
- fail ("Could not create tempfile");
|
|
||||||
+ ck_abort_msg("Could not create tempfile");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -62,11 +62,17 @@ START_TEST (test_symlink)
|
|
||||||
close (tmp_fd);
|
|
||||||
unlink (ln);
|
|
||||||
char temp_disk_path[256];
|
|
||||||
- snprintf (temp_disk_path, sizeof temp_disk_path, "%s/%s", cwd,
|
|
||||||
- temporary_disk);
|
|
||||||
+ int r = snprintf(temp_disk_path, sizeof temp_disk_path, "%s/%s",
|
|
||||||
+ cwd,
|
|
||||||
+ temporary_disk);
|
|
||||||
+ if (r < 0 || r >= sizeof temp_disk_path) {
|
|
||||||
+ ck_abort_msg("symlink truncated");
|
|
||||||
+ return;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
int res = symlink (temp_disk_path, ln);
|
|
||||||
if (res) {
|
|
||||||
- fail ("could not create symlink");
|
|
||||||
+ ck_abort_msg("could not create symlink");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -77,7 +83,7 @@ START_TEST (test_symlink)
|
|
||||||
/* Create a second temporary_disk */
|
|
||||||
char *temporary_disk2 = _create_disk (4096 * 1024);
|
|
||||||
if (temporary_disk2 == NULL) {
|
|
||||||
- fail ("Failed to create 2nd temporary disk");
|
|
||||||
+ ck_abort_msg("Failed to create 2nd temporary disk");
|
|
||||||
goto exit_destroy_dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -89,11 +95,16 @@ START_TEST (test_symlink)
|
|
||||||
|
|
||||||
/* Update symlink to point to our new / second temporary disk */
|
|
||||||
unlink (ln);
|
|
||||||
- snprintf (temp_disk_path, sizeof temp_disk_path, "%s/%s", cwd,
|
|
||||||
- temporary_disk);
|
|
||||||
+ r = snprintf (temp_disk_path, sizeof temp_disk_path, "%s/%s",
|
|
||||||
+ cwd, temporary_disk);
|
|
||||||
+ if (r < 0 || r >= sizeof temp_disk_path) {
|
|
||||||
+ ck_abort_msg("2nd symlink truncated");
|
|
||||||
+ goto exit_destroy_dev;
|
|
||||||
+ }
|
|
||||||
+
|
|
||||||
res = symlink (temp_disk_path, ln);
|
|
||||||
if (res) {
|
|
||||||
- fail ("could not create 2nd symlink");
|
|
||||||
+ ck_abort_msg("could not create 2nd symlink");
|
|
||||||
goto exit_destroy_dev;
|
|
||||||
}
|
|
||||||
|
|
||||||
diff --git a/libparted/tests/volser.c b/libparted/tests/volser.c
|
|
||||||
index c6efa5f..4b6e2d1 100644
|
|
||||||
--- a/libparted/tests/volser.c
|
|
||||||
+++ b/libparted/tests/volser.c
|
|
||||||
@@ -34,7 +34,7 @@ static void set_test (void)
|
|
||||||
type = ped_disk_type_get ("dasd");
|
|
||||||
|
|
||||||
tmp_disk = _create_disk (20*1024*1024);
|
|
||||||
- fail_if (tmp_disk == NULL, "Failed to create temporary disk");
|
|
||||||
+ ck_assert_msg(tmp_disk != NULL, "Failed to create temporary disk");
|
|
||||||
dev = ped_device_get (tmp_disk);
|
|
||||||
if (dev == NULL)
|
|
||||||
return;
|
|
||||||
diff --git a/libparted/tests/zerolen.c b/libparted/tests/zerolen.c
|
|
||||||
index cf2bd1c..2d9b424 100644
|
|
||||||
--- a/libparted/tests/zerolen.c
|
|
||||||
+++ b/libparted/tests/zerolen.c
|
|
||||||
@@ -28,7 +28,7 @@ main (int argc, char **argv)
|
|
||||||
TCase* tcase_probe = tcase_create ("Probe");
|
|
||||||
|
|
||||||
if (argc < 2) {
|
|
||||||
- fail ("Insufficient arguments");
|
|
||||||
+ ck_abort_msg("Insufficient arguments");
|
|
||||||
return EXIT_FAILURE;
|
|
||||||
}
|
|
||||||
temporary_disk = argv[1];
|
|
||||||
--
|
|
||||||
2.39.1
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
From c409dbf423d870ab26684cd6a6953c76c4a08d7f Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Wed, 15 Feb 2023 10:04:36 -0800
|
|
||||||
Subject: [PATCH 18/24] filesys: Check for null from close_fn
|
|
||||||
|
|
||||||
If the filesystem type name isn't known it can return a NULL.
|
|
||||||
---
|
|
||||||
libparted/fs/r/filesys.c | 3 ++-
|
|
||||||
1 file changed, 2 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/libparted/fs/r/filesys.c b/libparted/fs/r/filesys.c
|
|
||||||
index 9dafd71..6e795bc 100644
|
|
||||||
--- a/libparted/fs/r/filesys.c
|
|
||||||
+++ b/libparted/fs/r/filesys.c
|
|
||||||
@@ -198,8 +198,9 @@ ped_file_system_close (PedFileSystem* fs)
|
|
||||||
{
|
|
||||||
PED_ASSERT (fs != NULL);
|
|
||||||
PedDevice *dev = fs->geom->dev;
|
|
||||||
+ close_fn_t fn = close_fn (fs->type->name);
|
|
||||||
|
|
||||||
- if (!(close_fn (fs->type->name) (fs)))
|
|
||||||
+ if (!fn || !(fn (fs)))
|
|
||||||
goto error_close_dev;
|
|
||||||
ped_device_close (dev);
|
|
||||||
return 1;
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
@ -1,30 +0,0 @@
|
|||||||
From 31db44c74a96f8e2b495205d18525449e9b29543 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Wed, 15 Feb 2023 10:13:58 -0800
|
|
||||||
Subject: [PATCH 19/24] libparted: Fix potential NULL dereference in
|
|
||||||
ped_disk_next_partition
|
|
||||||
|
|
||||||
---
|
|
||||||
libparted/disk.c | 5 ++++-
|
|
||||||
1 file changed, 4 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/libparted/disk.c b/libparted/disk.c
|
|
||||||
index e1a3489..6c82877 100644
|
|
||||||
--- a/libparted/disk.c
|
|
||||||
+++ b/libparted/disk.c
|
|
||||||
@@ -1718,8 +1718,11 @@ ped_disk_next_partition (const PedDisk* disk, const PedPartition* part)
|
|
||||||
return part->part_list ? part->part_list : part->next;
|
|
||||||
if (part->next)
|
|
||||||
return part->next;
|
|
||||||
- if (part->type & PED_PARTITION_LOGICAL)
|
|
||||||
+ if (part->type & PED_PARTITION_LOGICAL) {
|
|
||||||
+ if (!ped_disk_extended_partition (disk))
|
|
||||||
+ return NULL;
|
|
||||||
return ped_disk_extended_partition (disk)->next;
|
|
||||||
+ }
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
@ -1,28 +0,0 @@
|
|||||||
From 9cb38a7444d02023d112ae8e9e38436104f75f64 Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Wed, 15 Feb 2023 10:32:59 -0800
|
|
||||||
Subject: [PATCH 20/24] strlist: Handle realloc error in wchar_to_str
|
|
||||||
|
|
||||||
It could return a NULL if the realloc fails. This handles the failure in
|
|
||||||
the same way as other failures in wchar_to_str, it exits immediately
|
|
||||||
with an error message.
|
|
||||||
---
|
|
||||||
parted/strlist.c | 2 ++
|
|
||||||
1 file changed, 2 insertions(+)
|
|
||||||
|
|
||||||
diff --git a/parted/strlist.c b/parted/strlist.c
|
|
||||||
index 71cba59..7901789 100644
|
|
||||||
--- a/parted/strlist.c
|
|
||||||
+++ b/parted/strlist.c
|
|
||||||
@@ -166,6 +166,8 @@ wchar_to_str (const wchar_t* str, size_t count)
|
|
||||||
goto error;
|
|
||||||
|
|
||||||
result = realloc (result, strlen (result) + 1);
|
|
||||||
+ if (!result)
|
|
||||||
+ goto error;
|
|
||||||
return result;
|
|
||||||
|
|
||||||
error:
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
@ -1,50 +0,0 @@
|
|||||||
From 09c95d2feab0c087339886134dfe2dc04094348a Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Wed, 15 Feb 2023 11:15:28 -0800
|
|
||||||
Subject: [PATCH 21/24] ui: Add checks for prompt being NULL
|
|
||||||
|
|
||||||
Also removes a cast from const char* to char* when passing to readline
|
|
||||||
that doesn't appear to be necessary any longer.
|
|
||||||
|
|
||||||
Added asserts to make sure prompt isn't NULL after strdup and realloc
|
|
||||||
calls.
|
|
||||||
---
|
|
||||||
parted/ui.c | 7 +++++--
|
|
||||||
1 file changed, 5 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/parted/ui.c b/parted/ui.c
|
|
||||||
index df14e55..9e5ced2 100644
|
|
||||||
--- a/parted/ui.c
|
|
||||||
+++ b/parted/ui.c
|
|
||||||
@@ -564,8 +564,7 @@ _readline (const char* prompt, const StrList* possibilities)
|
|
||||||
wipe_line ();
|
|
||||||
#ifdef HAVE_LIBREADLINE
|
|
||||||
if (!opt_script_mode) {
|
|
||||||
- /* XXX: why isn't prompt const? */
|
|
||||||
- line = readline ((char*) prompt);
|
|
||||||
+ line = readline (prompt);
|
|
||||||
if (line)
|
|
||||||
_add_history_unique (line);
|
|
||||||
} else
|
|
||||||
@@ -781,6 +780,8 @@ realloc_and_cat (char* str, const char* append)
|
|
||||||
int length = strlen (str) + strlen (append) + 1;
|
|
||||||
char* new_str = realloc (str, length);
|
|
||||||
|
|
||||||
+ PED_ASSERT(new_str != NULL);
|
|
||||||
+
|
|
||||||
strcat (new_str, append);
|
|
||||||
return new_str;
|
|
||||||
}
|
|
||||||
@@ -789,7 +790,9 @@ static char*
|
|
||||||
_construct_prompt (const char* head, const char* def,
|
|
||||||
const StrList* possibilities)
|
|
||||||
{
|
|
||||||
+ PED_ASSERT(head != NULL);
|
|
||||||
char* prompt = strdup (head);
|
|
||||||
+ PED_ASSERT(prompt != NULL);
|
|
||||||
|
|
||||||
if (def && possibilities)
|
|
||||||
PED_ASSERT (str_list_match_any (possibilities, def));
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
@ -1,46 +0,0 @@
|
|||||||
From d272bb5b5343fd288a204314654a7fbaea84528d Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Wed, 15 Feb 2023 11:52:42 -0800
|
|
||||||
Subject: [PATCH 22/24] tests: Fix formatting and snprintf warnings in tests.
|
|
||||||
|
|
||||||
The assert message includes sector values, which are long long int, so
|
|
||||||
use the proper formatting of %lld.
|
|
||||||
|
|
||||||
The snprintf warning complained about trying to write 258 bytes so I
|
|
||||||
bumped the buffer size up to 259. The return value is already being
|
|
||||||
checked for truncation so this is just to keep the compiler happy
|
|
||||||
without having to suppress the warning.
|
|
||||||
---
|
|
||||||
libparted/tests/disk.c | 2 +-
|
|
||||||
libparted/tests/symlink.c | 2 +-
|
|
||||||
2 files changed, 2 insertions(+), 2 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/libparted/tests/disk.c b/libparted/tests/disk.c
|
|
||||||
index f7b16a5..a2e304c 100644
|
|
||||||
--- a/libparted/tests/disk.c
|
|
||||||
+++ b/libparted/tests/disk.c
|
|
||||||
@@ -75,7 +75,7 @@ START_TEST (test_duplicate)
|
|
||||||
ck_assert_msg(part->geom.start == part_dup->geom.start &&
|
|
||||||
part->geom.end == part_dup->geom.end,
|
|
||||||
"Duplicated partition %d doesn't match. "
|
|
||||||
- "Details are start: %d/%d end: %d/%d\n",
|
|
||||||
+ "Details are start: %lld/%lld end: %lld/%lld\n",
|
|
||||||
*i, part->geom.start, part_dup->geom.start,
|
|
||||||
part->geom.end, part_dup->geom.end);
|
|
||||||
}
|
|
||||||
diff --git a/libparted/tests/symlink.c b/libparted/tests/symlink.c
|
|
||||||
index da6bef8..7be02cd 100644
|
|
||||||
--- a/libparted/tests/symlink.c
|
|
||||||
+++ b/libparted/tests/symlink.c
|
|
||||||
@@ -61,7 +61,7 @@ START_TEST (test_symlink)
|
|
||||||
here, but as /dev/mapper is root owned this is a non issue */
|
|
||||||
close (tmp_fd);
|
|
||||||
unlink (ln);
|
|
||||||
- char temp_disk_path[256];
|
|
||||||
+ char temp_disk_path[259];
|
|
||||||
int r = snprintf(temp_disk_path, sizeof temp_disk_path, "%s/%s",
|
|
||||||
cwd,
|
|
||||||
temporary_disk);
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
@ -1,146 +0,0 @@
|
|||||||
From 3f6b723a7d610d98afb0c9d0cfefe4700712e4db Mon Sep 17 00:00:00 2001
|
|
||||||
From: "Brian C. Lane" <bcl@redhat.com>
|
|
||||||
Date: Fri, 3 Mar 2023 14:35:22 -0800
|
|
||||||
Subject: [PATCH] parted: Fix ending sector location when using kibi IEC suffix
|
|
||||||
|
|
||||||
This fixes a bug when using KiB to specify the ending location of a
|
|
||||||
partition. It was not subtracting 1s like it does with the other units
|
|
||||||
because it was looking for a 'k' not a 'K'.
|
|
||||||
|
|
||||||
This also fixes a quirk of the suffix checking code, it would check for
|
|
||||||
matching case, but converting to the actual IEC value was case
|
|
||||||
insensitive. This now uses common functions for the matching so that
|
|
||||||
case doesn't matter.
|
|
||||||
|
|
||||||
It also adds tests to check for the fix.
|
|
||||||
|
|
||||||
The only change in behavior is that using KiB to specify the ending
|
|
||||||
location of a partition will now correctly create the end 1s lower than
|
|
||||||
the specified location like it does for MiB, GiB, etc.
|
|
||||||
---
|
|
||||||
parted/parted.c | 29 ++++++++++++++++++----------
|
|
||||||
tests/t0207-IEC-binary-notation.sh | 31 ++++++++++++++++++++++++++++++
|
|
||||||
tests/t0208-mkpart-end-in-IEC.sh | 2 +-
|
|
||||||
3 files changed, 51 insertions(+), 11 deletions(-)
|
|
||||||
|
|
||||||
diff --git a/parted/parted.c b/parted/parted.c
|
|
||||||
index 84187b7..84465d5 100644
|
|
||||||
--- a/parted/parted.c
|
|
||||||
+++ b/parted/parted.c
|
|
||||||
@@ -583,16 +583,27 @@ void _strip_trailing_spaces(char *str)
|
|
||||||
str[i]='\0';
|
|
||||||
}
|
|
||||||
|
|
||||||
-/* Return true, if str ends with [kMGTPEZY]iB, i.e. IEC units. */
|
|
||||||
+/* Return true if the unit is one of the supported IEC unit values */
|
|
||||||
+static bool
|
|
||||||
+_is_unit_IEC(const PedUnit unit) {
|
|
||||||
+ return (unit == PED_UNIT_KIBIBYTE) || (unit == PED_UNIT_MEBIBYTE) ||
|
|
||||||
+ (unit == PED_UNIT_GIBIBYTE) || (unit == PED_UNIT_TEBIBYTE);
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
+/* Return true, if str ends with IEC units. */
|
|
||||||
static bool
|
|
||||||
_string_ends_with_iec_unit(const char *str)
|
|
||||||
{
|
|
||||||
- /* 3 characters for the IEC unit and at least 1 digit */
|
|
||||||
- if (!str || strlen(str) < 4)
|
|
||||||
- return false;
|
|
||||||
+ /* 3 characters for the IEC unit and at least 1 digit */
|
|
||||||
+ if (!str || strlen(str) < 4)
|
|
||||||
+ return false;
|
|
||||||
|
|
||||||
- char const *p = str + strlen(str) - 3;
|
|
||||||
- return strchr ("kMGTPEZY", *p) && c_strcasecmp (p+1, "iB") == 0;
|
|
||||||
+ char const *p = str + strlen(str) - 3;
|
|
||||||
+ PedUnit unit = ped_unit_get_by_name(p);
|
|
||||||
+ if (unit == -1) {
|
|
||||||
+ return false;
|
|
||||||
+ }
|
|
||||||
+ return _is_unit_IEC(unit);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Return true if str ends with explicit unit identifier.
|
|
||||||
@@ -612,7 +623,7 @@ _string_has_unit_suffix(const char *str)
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
-/* If the selected unit is one of kiB, MiB, GiB or TiB and the partition is not
|
|
||||||
+/* If the selected unit is one of KiB, MiB, GiB or TiB and the partition is not
|
|
||||||
* only 1 sector long, then adjust the end so that it is one sector before the
|
|
||||||
* given position. Also adjust range_end accordingly. Thus next partition can
|
|
||||||
* start immediately after this one.
|
|
||||||
@@ -636,9 +647,7 @@ _adjust_end_if_iec (PedSector* start, PedSector* end,
|
|
||||||
_strip_trailing_spaces(end_input);
|
|
||||||
PedUnit unit = ped_unit_get_default();
|
|
||||||
if (_string_ends_with_iec_unit(end_input) ||
|
|
||||||
- (!_string_has_unit_suffix(end_input) &&
|
|
||||||
- ((unit == PED_UNIT_KIBIBYTE) || (unit == PED_UNIT_MEBIBYTE) ||
|
|
||||||
- (unit == PED_UNIT_GIBIBYTE) || (unit == PED_UNIT_TEBIBYTE)))) {
|
|
||||||
+ (!_string_has_unit_suffix(end_input) && _is_unit_IEC(unit))) {
|
|
||||||
*end -= 1;
|
|
||||||
range_end->start -= 1;
|
|
||||||
range_end->end -= 1;
|
|
||||||
diff --git a/tests/t0207-IEC-binary-notation.sh b/tests/t0207-IEC-binary-notation.sh
|
|
||||||
index d9bbad6..b8a789e 100644
|
|
||||||
--- a/tests/t0207-IEC-binary-notation.sh
|
|
||||||
+++ b/tests/t0207-IEC-binary-notation.sh
|
|
||||||
@@ -28,6 +28,7 @@ parted --align=none -s $dev mklabel gpt mkpart p1 $((64*1024))B $((1024*1024-$ss
|
|
||||||
compare /dev/null err || fail=1
|
|
||||||
parted -m -s $dev u s p > exp || fail=1
|
|
||||||
|
|
||||||
+# Test using MiB
|
|
||||||
rm $dev
|
|
||||||
dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
|
|
||||||
parted --align=none -s $dev mklabel gpt mkpart p1 64KiB 1MiB \
|
|
||||||
@@ -37,4 +38,34 @@ parted -m -s $dev u s p > out || fail=1
|
|
||||||
|
|
||||||
compare exp out || fail=1
|
|
||||||
|
|
||||||
+# Test using lower case kib and mib
|
|
||||||
+rm $dev
|
|
||||||
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
|
|
||||||
+parted --align=none -s $dev mklabel gpt mkpart p1 64kib 1mib \
|
|
||||||
+ > err 2>&1 || fail=1
|
|
||||||
+compare /dev/null err || fail=1
|
|
||||||
+parted -m -s $dev u s p > out || fail=1
|
|
||||||
+
|
|
||||||
+compare exp out || fail=1
|
|
||||||
+
|
|
||||||
+# Test using KiB
|
|
||||||
+rm $dev
|
|
||||||
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
|
|
||||||
+parted --align=none -s $dev mklabel gpt mkpart p1 64KiB 1024KiB \
|
|
||||||
+ > err 2>&1 || fail=1
|
|
||||||
+compare /dev/null err || fail=1
|
|
||||||
+parted -m -s $dev u s p > out || fail=1
|
|
||||||
+
|
|
||||||
+compare exp out || fail=1
|
|
||||||
+
|
|
||||||
+# Test using kiB
|
|
||||||
+rm $dev
|
|
||||||
+dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || fail=1
|
|
||||||
+parted --align=none -s $dev mklabel gpt mkpart p1 64kiB 1024kiB \
|
|
||||||
+ > err 2>&1 || fail=1
|
|
||||||
+compare /dev/null err || fail=1
|
|
||||||
+parted -m -s $dev u s p > out || fail=1
|
|
||||||
+
|
|
||||||
+compare exp out || fail=1
|
|
||||||
+
|
|
||||||
Exit $fail
|
|
||||||
diff --git a/tests/t0208-mkpart-end-in-IEC.sh b/tests/t0208-mkpart-end-in-IEC.sh
|
|
||||||
index 118ec72..a3db2c3 100644
|
|
||||||
--- a/tests/t0208-mkpart-end-in-IEC.sh
|
|
||||||
+++ b/tests/t0208-mkpart-end-in-IEC.sh
|
|
||||||
@@ -25,7 +25,7 @@ dev=dev-file
|
|
||||||
|
|
||||||
dd if=/dev/null of=$dev bs=1M seek=$n_mbs || fail=1
|
|
||||||
# create 1st partition
|
|
||||||
-parted --align=none -s $dev mklabel gpt mkpart p1 1MiB 2MiB > err 2>&1 || fail=1
|
|
||||||
+parted --align=none -s $dev mklabel gpt mkpart p1 1MiB 2048KiB > err 2>&1 || fail=1
|
|
||||||
compare /dev/null err || fail=1 # expect no output
|
|
||||||
#parted -m -s $dev u s p > exp || fail=1
|
|
||||||
|
|
||||||
--
|
|
||||||
2.39.2
|
|
||||||
|
|
38
parted.spec
38
parted.spec
@ -1,7 +1,7 @@
|
|||||||
Summary: The GNU disk partition manipulation program
|
Summary: The GNU disk partition manipulation program
|
||||||
Name: parted
|
Name: parted
|
||||||
Version: 3.5
|
Version: 3.5.28
|
||||||
Release: 11%{?dist}
|
Release: 1%{?dist}
|
||||||
License: GPL-3.0-or-later
|
License: GPL-3.0-or-later
|
||||||
URL: http://www.gnu.org/software/parted
|
URL: http://www.gnu.org/software/parted
|
||||||
|
|
||||||
@ -10,31 +10,6 @@ Source1: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz.sig
|
|||||||
Source2: pubkey.phillip.susi
|
Source2: pubkey.phillip.susi
|
||||||
Source3: pubkey.brian.lane
|
Source3: pubkey.brian.lane
|
||||||
|
|
||||||
# Upstream patches since v3.5 release
|
|
||||||
Patch0001: 0001-maint-post-release-administrivia.patch
|
|
||||||
Patch0002: 0002-parted-add-type-command.patch
|
|
||||||
Patch0003: 0003-libparted-add-swap-flag-for-DASD-label.patch
|
|
||||||
Patch0004: 0004-parted-Reset-the-filesystem-type-when-changing-the-i.patch
|
|
||||||
Patch0005: 0005-tests-t3200-type-change-now-passes.patch
|
|
||||||
Patch0006: 0006-libparted-Fix-check-for-availability-of-_type_id-fun.patch
|
|
||||||
Patch0007: 0007-parted-Simplify-code-for-json-output.patch
|
|
||||||
Patch0008: 0008-disk.in.h-Remove-use-of-enums-with-define.patch
|
|
||||||
Patch0009: 0009-libparted-Fix-handling-of-gpt-partition-types.patch
|
|
||||||
Patch0010: 0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch
|
|
||||||
Patch0011: 0011-libparted-Fix-handling-of-msdos-partition-types.patch
|
|
||||||
Patch0012: 0012-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch
|
|
||||||
Patch0013: 0013-show-GPT-UUIDs-in-JSON-output.patch
|
|
||||||
Patch0014: 0014-gpt-Add-no_automount-partition-flag.patch
|
|
||||||
Patch0015: 0015-tests-XFS-requires-a-minimum-size-of-300M.patch
|
|
||||||
Patch0016: 0016-libparted-Fix-problem-with-creating-1s-partitions.patch
|
|
||||||
Patch0017: 0017-tests-Fixing-libparted-test-framework-usage.patch
|
|
||||||
Patch0018: 0018-filesys-Check-for-null-from-close_fn.patch
|
|
||||||
Patch0019: 0019-libparted-Fix-potential-NULL-dereference-in-ped_disk.patch
|
|
||||||
Patch0020: 0020-strlist-Handle-realloc-error-in-wchar_to_str.patch
|
|
||||||
Patch0021: 0021-ui-Add-checks-for-prompt-being-NULL.patch
|
|
||||||
Patch0022: 0022-tests-Fix-formatting-and-snprintf-warnings-in-tests.patch
|
|
||||||
Patch0023: 0023-parted-Fix-ending-sector-location-when-using-kibi-IE.patch
|
|
||||||
|
|
||||||
BuildRequires: gcc
|
BuildRequires: gcc
|
||||||
BuildRequires: e2fsprogs-devel
|
BuildRequires: e2fsprogs-devel
|
||||||
BuildRequires: readline-devel
|
BuildRequires: readline-devel
|
||||||
@ -123,9 +98,9 @@ make check
|
|||||||
%{_mandir}/man8/parted.8*
|
%{_mandir}/man8/parted.8*
|
||||||
%{_mandir}/man8/partprobe.8*
|
%{_mandir}/man8/partprobe.8*
|
||||||
%{_libdir}/libparted.so.2
|
%{_libdir}/libparted.so.2
|
||||||
%{_libdir}/libparted.so.2.0.4
|
%{_libdir}/libparted.so.2.0.5
|
||||||
%{_libdir}/libparted-fs-resize.so.0
|
%{_libdir}/libparted-fs-resize.so.0
|
||||||
%{_libdir}/libparted-fs-resize.so.0.0.4
|
%{_libdir}/libparted-fs-resize.so.0.0.5
|
||||||
%{_infodir}/parted.info*
|
%{_infodir}/parted.info*
|
||||||
|
|
||||||
%files devel
|
%files devel
|
||||||
@ -138,6 +113,11 @@ make check
|
|||||||
|
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon Mar 27 2023 Brian C. Lane <bcl@redhat.com> - 3.5.28-1
|
||||||
|
- Upstream 3.5.28 Alpha release
|
||||||
|
- Dropped all patches included in new upstream release
|
||||||
|
- Bumped minor version on libparted.so and libparted-fs-resize.so
|
||||||
|
|
||||||
* Fri Mar 17 2023 Brian C. Lane <bcl@redhat.com> - 3.5-11
|
* Fri Mar 17 2023 Brian C. Lane <bcl@redhat.com> - 3.5-11
|
||||||
- parted: Fix ending sector location when using kibi IEC suffix (bcl)
|
- parted: Fix ending sector location when using kibi IEC suffix (bcl)
|
||||||
- tests: Fix formatting and snprintf warnings in tests. (bcl)
|
- tests: Fix formatting and snprintf warnings in tests. (bcl)
|
||||||
|
4
sources
4
sources
@ -1,2 +1,2 @@
|
|||||||
SHA512 (parted-3.5.tar.xz) = 87fc69e947de5f0b670ee5373a7cdf86180cd782f6d7280f970f217f73f55ee1b1b018563f48954f3a54fdde5974b33e07eee68c9ccdf08e621d3dc0e3ce126a
|
SHA512 (parted-3.5.28.tar.xz) = 6cbd280a47b6c8e3beac9db689f505f2f71aaaa62eb1c20cd23e5c4a2dc56841d5bfaa45bf661ac6fe3bb45441bc07f7d0b51e4673fa2c05f968e0a6b3bd4ee6
|
||||||
SHA512 (parted-3.5.tar.xz.sig) = 2ea1209325595416aa9ee27a0e85ca38bce50ca885d3b52ab1c1fb1b68b78d7887386ea3120274648056d2f1d9dca00b77236991765d84ad226c1b1f5a3f5c62
|
SHA512 (parted-3.5.28.tar.xz.sig) = bf806d682ea4fa5f34c6fdcd7bb967c9278e164ba8167ef17e1ba83a4acf5a32355adf4468a457436a85e5ad6a223d2a79a61043728f0d269c69f89775a2e9af
|
||||||
|
Loading…
Reference in New Issue
Block a user