import parted-3.5-2.el9

c9 imports/c9/parted-3.5-2.el9
CentOS Sources 2 years ago committed by MSVSphere Packaging Team
commit 5189336647

3
.gitignore vendored

@ -0,0 +1,3 @@
SOURCES/parted-3.5.tar.xz
SOURCES/pubkey.brian.lane
SOURCES/pubkey.phillip.susi

@ -0,0 +1,3 @@
55023eb2acb3b22e6fc999d73e285f0a3706101a SOURCES/parted-3.5.tar.xz
2c4a3e3c329d04ece68fdca92225441bc7c28f09 SOURCES/pubkey.brian.lane
0ef8ad4c6cc02bbacd5c9de79187c116c3efb10a SOURCES/pubkey.phillip.susi

@ -0,0 +1,50 @@
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 1/5] 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.35.3

File diff suppressed because it is too large Load Diff

@ -0,0 +1,228 @@
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 3/5] 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.35.3

@ -0,0 +1,30 @@
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 4/5] 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.35.3

@ -0,0 +1,23 @@
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 5/5] 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.35.3

@ -0,0 +1,101 @@
From 22ec6553b00b8cc21bf8e78529e1cd0f775ff36f 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 6/9] 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.1

@ -0,0 +1,160 @@
From 8b4a30cc60ecbe9b7bc966e70560e5ce0fc0c1ad 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 7/9] 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.1

@ -0,0 +1,109 @@
From d37d5e7a9470bb5bf8446f79f8e9c508366e06b6 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 8/9] 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.1

@ -0,0 +1,75 @@
From 3deaae7a19ebfbc2dad6ad67ba65409e7238efc8 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 9/9] 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.1

@ -0,0 +1,11 @@
-----BEGIN PGP SIGNATURE-----
iQEzBAABCgAdFiEEtMa0UeT6i0IyyhkeEX6MFo7+On8FAmJduCkACgkQEX6MFo7+
On9cLAgAmAn86lYjZj+Ka5EHrVtaFgh1Nvz84EOwZd0TVRTJyP/u56QrOXxRYFFr
6SiJuI1sWfpkzMGG8RYhcr/hu0Os4rtDdhwXXA75QexpSZamPRSo/EU7skrPW0ZD
ycw6jUIBO5de4kCLmM/4byl6LV5eFixJYJ5zfD+SnQsMJvO6/fBo0Dv+pNGF/m5F
mQeLWmgfqCNZ3INoHLPxuP08gpA9aELp6UFipbqBZqeRIk4K+jGSWlLu62mwl2sQ
1OYIIdKacBrh14ZhRqXZKGKHk94RxiFtD/7CLXK/qzEFylKUMQ/XpUB0QkZNHVZW
l2kRXsEGC1c7dWSbMX8lgy02HjfuVQ==
=7scj
-----END PGP SIGNATURE-----

@ -0,0 +1,208 @@
Summary: The GNU disk partition manipulation program
Name: parted
Version: 3.5
Release: 2%{?dist}
License: GPLv3+
URL: http://www.gnu.org/software/parted
Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz
Source1: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz.sig
Source2: pubkey.phillip.susi
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-handling-of-gpt-partition-types.patch
Patch0007: 0007-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch
Patch0008: 0008-libparted-Fix-handling-of-msdos-partition-types.patch
Patch0009: 0009-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch
BuildRequires: gcc
BuildRequires: e2fsprogs-devel
BuildRequires: readline-devel
BuildRequires: ncurses-devel
BuildRequires: gettext-devel
BuildRequires: texinfo
BuildRequires: device-mapper-devel
BuildRequires: libuuid-devel
BuildRequires: libblkid-devel >= 2.17
BuildRequires: gnupg2
BuildRequires: git
BuildRequires: autoconf
BuildRequires: automake
BuildRequires: libtool
BuildRequires: e2fsprogs
BuildRequires: xfsprogs
BuildRequires: dosfstools
BuildRequires: perl-Digest-CRC
BuildRequires: bc
Buildrequires: python3
BuildRequires: gperf
BuildRequires: make
BuildRequires: check-devel
# bundled gnulib library exception, as per packaging guidelines
# https://fedoraproject.org/wiki/Packaging:No_Bundled_Libraries
Provides: bundled(gnulib)
%description
The GNU Parted program allows you to create, destroy, resize, move,
and copy hard disk partitions. Parted can be used for creating space
for new operating systems, reorganizing disk usage, and copying data
to new hard disks.
%package devel
Summary: Files for developing apps which will manipulate disk partitions
Requires: %{name} = %{version}-%{release}
Requires: pkgconfig
%description devel
The GNU Parted library is a set of routines for hard disk partition
manipulation. If you want to develop programs that manipulate disk
partitions and filesystems using the routines provided by the GNU
Parted library, you need to install this package.
%prep
%autosetup -S git_am
gpg2 --import %{SOURCE2} %{SOURCE3}
gpg2 --verify %{SOURCE1} %{SOURCE0}
iconv -f ISO-8859-1 -t UTF8 AUTHORS > tmp; touch -r AUTHORS tmp; mv tmp AUTHORS
%build
# RHEL has 2.69 which works fine with the macros parted uses
sed -i s/2.71/2.69/ configure.ac
autoreconf -fiv
CFLAGS="$RPM_OPT_FLAGS -Wno-unused-but-set-variable"; export CFLAGS
%configure --disable-static --disable-gcc-warnings
# Don't use rpath!
%{__sed} -i 's|^hardcode_libdir_flag_spec=.*|hardcode_libdir_flag_spec=""|g' libtool
%{__sed} -i 's|^runpath_var=LD_RUN_PATH|runpath_var=DIE_RPATH_DIE|g' libtool
%make_build
%install
%{__rm} -rf %{buildroot}
%make_install
# Remove components we do not ship
%{__rm} -rf %{buildroot}%{_libdir}/*.la
%{__rm} -rf %{buildroot}%{_infodir}/dir
%{__rm} -rf %{buildroot}%{_bindir}/label
%{__rm} -rf %{buildroot}%{_bindir}/disk
%find_lang %{name}
%check
export LD_LIBRARY_PATH=$(pwd)/libparted/.libs:$(pwd)/libparted/fs/.libs
make check
%files -f %{name}.lang
%doc AUTHORS NEWS README THANKS
%{!?_licensedir:%global license %%doc}
%license COPYING
%{_sbindir}/parted
%{_sbindir}/partprobe
%{_mandir}/man8/parted.8.gz
%{_mandir}/man8/partprobe.8.gz
%{_libdir}/libparted.so.2
%{_libdir}/libparted.so.2.0.4
%{_libdir}/libparted-fs-resize.so.0
%{_libdir}/libparted-fs-resize.so.0.0.4
%{_infodir}/parted.info.*
%files devel
%doc TODO doc/API doc/FAT
%{_includedir}/parted
%{_libdir}/libparted.so
%{_libdir}/libparted-fs-resize.so
%{_libdir}/pkgconfig/libparted.pc
%{_libdir}/pkgconfig/libparted-fs-resize.pc
%changelog
* Tue Aug 09 2022 Brian C. Lane <bcl@redhat.com> - 3.5-2
- Fix ped_partition_set_system handling of existing flags
Resolves: rhbz#2116505
* Fri May 27 2022 Brian C. Lane <bcl@redhat.com> - 3.5-1
- Rebase to upstream release 3.5
- Drop patches included in new upstream tar
- Add upstream patches for new type command
- Add upstream patch for swap flag on DASD
Resolves: rhbz#1999333
* Mon Aug 09 2021 Mohan Boddu <mboddu@redhat.com> - 3.4-6
- Rebuilt for IMA sigs, glibc 2.34, aarch64 flags
Related: rhbz#1991688
* Tue Jun 15 2021 Brian C. Lane <bcl@redhat.com> - 3.4-5
- Install to /usr/sbin and /usr/lib64
Resolves: rhbz#1972346
* Thu Jun 10 2021 Brian C. Lane <bcl@redhat.com> - 3.4-4
- Fix issues that covscan classifies as important
Resolves: rhbz#1938836
- Work around a mkswap bug
* Fri Apr 16 2021 Mohan Boddu <mboddu@redhat.com> - 3.4-3
- Rebuilt for RHEL 9 BETA on Apr 15th 2021. Related: rhbz#1947937
* Wed Feb 03 2021 Brian C. Lane <bcl@redhat.com> - 3.4-2
- Add --fix support from upstream
* Wed Jan 27 2021 Brian C. Lane <bcl@redhat.com> - 3.4-1
- New stable upstream release v3.4
* Tue Jan 26 2021 Fedora Release Engineering <releng@fedoraproject.org> - 3.3.52-2
- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild
* Mon Dec 14 2020 Brian C. Lane <bcl@redhat.com> - 3.3.52-1
- New upstream ALPHA release v3.3.52
- Includes all patches
* Mon Nov 30 2020 Brian C. Lane <bcl@redhat.com> - 3.3-8
- Add upstream commits to fix various gcc 10 warnings (bcl)
* Thu Nov 05 2020 Brian C. Lane <bcl@redhat.com> - 3.3-7
- Do not link to libselinux
* Fri Sep 25 2020 Brian C. Lane <bcl@redhat.com> - 3.3-6
- tests: Add a test for resizepart on a busy partition (bcl)
- parted: Preserve resizepart End when prompted for busy partition (bcl)
- tests: Add f2fs to the fs probe test (romain.perier)
- Add support for the F2FS filesystem (romain.perier)
- Removed reference to ped_file_system_create (max)
* Tue Jul 28 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.3-5
- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild
* Tue Jul 14 2020 Tom Stellard <tstellar@redhat.com> - 3.3-4
- Use make macros
https://fedoraproject.org/wiki/Changes/UseMakeBuildInstallMacro
- Switch to using %%autosetup instead of %%setup and git (bcl)
- Update tests.yml to install git and simplify source usage (bgoncalv)
* Fri Mar 06 2020 Brian C. Lane <bcl@redhat.com> - 3.3-3
- Add chromeos_kernel partition flag for gpt disklabels
- Add bls_boot partition flag for msdos and gpt disklabels
* Wed Jan 29 2020 Fedora Release Engineering <releng@fedoraproject.org> - 3.3-3
- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild
* Mon Dec 16 2019 Brian C. Lane <bcl@redhat.com> - 3.3-2
- tests: Test incomplete resizepart command
- Fix end_input usage in do_resizepart
Resolves: rhbz#1701411
* Fri Oct 11 2019 Brian C. Lane <bcl@redhat.com> - 3.3-1
- New upstream release v3.3
Includes the DASD virtio-blk fix.
- Dropping pre-3.2 changelog entries
Loading…
Cancel
Save