From 8298c363a4007b0c740e1e27e5f33618b3e4ddbd Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 9 Aug 2022 10:15:30 -0700 Subject: [PATCH 01/23] - Fix ped_partition_set_system handling of existing flags --- ...-Fix-handling-of-gpt-partition-types.patch | 101 +++++++++++ ...arted-test-for-ped_partition_set_sys.patch | 160 ++++++++++++++++++ ...ix-handling-of-msdos-partition-types.patch | 109 ++++++++++++ ...arted-test-for-ped_partition_set_sys.patch | 75 ++++++++ parted.spec | 13 +- 5 files changed, 456 insertions(+), 2 deletions(-) create mode 100644 0007-libparted-Fix-handling-of-gpt-partition-types.patch create mode 100644 0008-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch create mode 100644 0009-libparted-Fix-handling-of-msdos-partition-types.patch create mode 100644 0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch diff --git a/0007-libparted-Fix-handling-of-gpt-partition-types.patch b/0007-libparted-Fix-handling-of-gpt-partition-types.patch new file mode 100644 index 0000000..1d13342 --- /dev/null +++ b/0007-libparted-Fix-handling-of-gpt-partition-types.patch @@ -0,0 +1,101 @@ +From 717d39a0a16b6fddfac65cf355a895d04995cdff Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 8 Aug 2022 12:04:32 -0700 +Subject: [PATCH 07/10] 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 + diff --git a/0008-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch b/0008-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch new file mode 100644 index 0000000..3484833 --- /dev/null +++ b/0008-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch @@ -0,0 +1,160 @@ +From 14cf5be3d322d7e3e81c21a3542ae046a5fe1fda Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 8 Aug 2022 13:49:09 -0700 +Subject: [PATCH 08/10] 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 ++#include ++ ++#include ++ ++#include ++ ++#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 . ++ ++. "${top_srcdir=../..}/tests/init.sh"; path_prepend_ . ++ ++flags || fail=1 ++ ++Exit $fail +-- +2.37.1 + diff --git a/0009-libparted-Fix-handling-of-msdos-partition-types.patch b/0009-libparted-Fix-handling-of-msdos-partition-types.patch new file mode 100644 index 0000000..1b689e0 --- /dev/null +++ b/0009-libparted-Fix-handling-of-msdos-partition-types.patch @@ -0,0 +1,109 @@ +From 9be9067bc5a3641fc890b0d4ba994000941109bf Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 8 Aug 2022 15:02:30 -0700 +Subject: [PATCH 09/10] 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 + diff --git a/0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch b/0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch new file mode 100644 index 0000000..4c313e7 --- /dev/null +++ b/0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch @@ -0,0 +1,75 @@ +From 7830678dbe832ea6815d9a31be8cbe3a67f3ed7e Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Mon, 8 Aug 2022 15:06:03 -0700 +Subject: [PATCH 10/10] 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 + diff --git a/parted.spec b/parted.spec index 7b49a68..ea6c27d 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.5 -Release: 5%{?dist} +Release: 6%{?dist} License: GPLv3+ URL: http://www.gnu.org/software/parted @@ -17,6 +17,11 @@ 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-disk.in.h-Remove-use-of-enums-with-define.patch +Patch0007: 0007-libparted-Fix-handling-of-gpt-partition-types.patch +Patch0008: 0008-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch +Patch0009: 0009-libparted-Fix-handling-of-msdos-partition-types.patch +Patch0010: 0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch + BuildRequires: gcc BuildRequires: e2fsprogs-devel @@ -37,9 +42,10 @@ BuildRequires: xfsprogs BuildRequires: dosfstools BuildRequires: perl-Digest-CRC BuildRequires: bc -Buildrequires: python3 +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 @@ -120,6 +126,9 @@ make check %changelog +* Mon Aug 08 2022 Brian C. Lane - 3.5-5.bcl.1 +- Fix ped_partition_set_system handling of existing flags + * Thu Aug 04 2022 Brian C. Lane - 3.5-5 - Update enum patch description for upstream From 7fc0182f627a5cedbbbb7f44d8f62d509ad90d65 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 4 Oct 2022 08:43:04 -0700 Subject: [PATCH 02/23] - libparted: Fix handling of msdos partition types - tests: Add a libparted test for ped_partition_set_system on msdos - parted: Add display of GPT UUIDs in JSON output - Add no_automount flag support - increase xfs size to 300M --- 0001-maint-post-release-administrivia.patch | 4 +- 0002-parted-add-type-command.patch | 4 +- ...bparted-add-swap-flag-for-DASD-label.patch | 4 +- ...-filesystem-type-when-changing-the-i.patch | 4 +- 0005-tests-t3200-type-change-now-passes.patch | 4 +- ...eck-for-availability-of-_type_id-fun.patch | 40 ++ ...parted-Simplify-code-for-json-output.patch | 34 ++ ...in.h-Remove-use-of-enums-with-define.patch | 4 +- ...arted-test-for-ped_partition_set_sys.patch | 160 -------- ...-Fix-handling-of-gpt-partition-types.patch | 6 +- ...arted-test-for-ped_partition_set_sys.patch | 169 ++++++--- ...ix-handling-of-msdos-partition-types.patch | 6 +- ...arted-test-for-ped_partition_set_sys.patch | 75 ++++ 0013-show-GPT-UUIDs-in-JSON-output.patch | 351 ++++++++++++++++++ ...-gpt-Add-no_automount-partition-flag.patch | 145 ++++++++ ...-XFS-requires-a-minimum-size-of-300M.patch | 54 +++ parted.spec | 25 +- 17 files changed, 862 insertions(+), 227 deletions(-) create mode 100644 0006-libparted-Fix-check-for-availability-of-_type_id-fun.patch create mode 100644 0007-parted-Simplify-code-for-json-output.patch rename 0006-disk.in.h-Remove-use-of-enums-with-define.patch => 0008-disk.in.h-Remove-use-of-enums-with-define.patch (96%) delete mode 100644 0008-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch rename 0007-libparted-Fix-handling-of-gpt-partition-types.patch => 0009-libparted-Fix-handling-of-gpt-partition-types.patch (95%) rename 0009-libparted-Fix-handling-of-msdos-partition-types.patch => 0011-libparted-Fix-handling-of-msdos-partition-types.patch (95%) create mode 100644 0012-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch create mode 100644 0013-show-GPT-UUIDs-in-JSON-output.patch create mode 100644 0014-gpt-Add-no_automount-partition-flag.patch create mode 100644 0015-tests-XFS-requires-a-minimum-size-of-300M.patch diff --git a/0001-maint-post-release-administrivia.patch b/0001-maint-post-release-administrivia.patch index c32732c..d8aa4ef 100644 --- a/0001-maint-post-release-administrivia.patch +++ b/0001-maint-post-release-administrivia.patch @@ -1,7 +1,7 @@ From cec533a00a2cd0b64a7a0f5debc26554f6025831 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 18 Apr 2022 15:10:06 -0400 -Subject: [PATCH 1/5] maint: post-release administrivia +Subject: [PATCH 01/13] maint: post-release administrivia * NEWS: Add header line for next release. * .prev-version: Record previous version. @@ -46,5 +46,5 @@ index d5fdd80..11fa51b 100644 include $(srcdir)/dist-check.mk -- -2.35.3 +2.37.3 diff --git a/0002-parted-add-type-command.patch b/0002-parted-add-type-command.patch index 8472a6b..4eddee7 100644 --- a/0002-parted-add-type-command.patch +++ b/0002-parted-add-type-command.patch @@ -1,7 +1,7 @@ From 61b3a9733c0e0a79ccc43096642d378c8706add6 Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Wed, 11 May 2022 14:02:21 +0000 -Subject: [PATCH 2/5] parted: add type command +Subject: [PATCH 02/13] parted: add type command Include the partition type-id and type-uuid in the JSON output. Also add the the command 'type' to set them. Remove @@ -1632,5 +1632,5 @@ index f2001c5..b35d443 100644 for mode in on_only on_and_off ; do -- -2.35.3 +2.37.3 diff --git a/0003-libparted-add-swap-flag-for-DASD-label.patch b/0003-libparted-add-swap-flag-for-DASD-label.patch index a9d7f7e..424ddc7 100644 --- a/0003-libparted-add-swap-flag-for-DASD-label.patch +++ b/0003-libparted-add-swap-flag-for-DASD-label.patch @@ -1,7 +1,7 @@ From 29ffc6a1f285f48ac0b9efa7299373e486c486e8 Mon Sep 17 00:00:00 2001 From: Arvin Schnell Date: Fri, 8 Oct 2021 10:06:24 +0000 -Subject: [PATCH 3/5] libparted: add swap flag for DASD label +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 @@ -224,5 +224,5 @@ index 0c00c4f..27baad0 100644 dasd_data->system = PARTITION_LINUX; PDEBUG; -- -2.35.3 +2.37.3 diff --git a/0004-parted-Reset-the-filesystem-type-when-changing-the-i.patch b/0004-parted-Reset-the-filesystem-type-when-changing-the-i.patch index 66f1a08..2060b77 100644 --- a/0004-parted-Reset-the-filesystem-type-when-changing-the-i.patch +++ b/0004-parted-Reset-the-filesystem-type-when-changing-the-i.patch @@ -1,7 +1,7 @@ From 9b0a83a747b28bd1b778bdd32616e6f7ea88c84d Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 13 May 2022 10:02:06 -0700 -Subject: [PATCH 4/5] parted: Reset the filesystem type when changing the +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 @@ -26,5 +26,5 @@ index b8a4acf..96da30d 100644 goto error; return 1; -- -2.35.3 +2.37.3 diff --git a/0005-tests-t3200-type-change-now-passes.patch b/0005-tests-t3200-type-change-now-passes.patch index 2b71270..a61d327 100644 --- a/0005-tests-t3200-type-change-now-passes.patch +++ b/0005-tests-t3200-type-change-now-passes.patch @@ -1,7 +1,7 @@ From ac2a35c2214ef42352d0ddb4f7f4cb77d116e92e Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 13 May 2022 10:15:41 -0700 -Subject: [PATCH 5/5] tests: t3200-type-change now passes +Subject: [PATCH 05/13] tests: t3200-type-change now passes --- tests/Makefile.am | 3 --- @@ -19,5 +19,5 @@ index 2da653b..1d109d7 100644 SH_LOG_COMPILER = $(SHELL) -- -2.35.3 +2.37.3 diff --git a/0006-libparted-Fix-check-for-availability-of-_type_id-fun.patch b/0006-libparted-Fix-check-for-availability-of-_type_id-fun.patch new file mode 100644 index 0000000..afa6bc2 --- /dev/null +++ b/0006-libparted-Fix-check-for-availability-of-_type_id-fun.patch @@ -0,0 +1,40 @@ +From bafa84b25a265ef9eed3872790d52bf56ac42998 Mon Sep 17 00:00:00 2001 +From: Arvin Schnell +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 +--- + 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 + diff --git a/0007-parted-Simplify-code-for-json-output.patch b/0007-parted-Simplify-code-for-json-output.patch new file mode 100644 index 0000000..50a600d --- /dev/null +++ b/0007-parted-Simplify-code-for-json-output.patch @@ -0,0 +1,34 @@ +From b16be5ffc8e700df2b6b2545c4b6794cea71b8e7 Mon Sep 17 00:00:00 2001 +From: Arvin Schnell +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 +--- + 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 + diff --git a/0006-disk.in.h-Remove-use-of-enums-with-define.patch b/0008-disk.in.h-Remove-use-of-enums-with-define.patch similarity index 96% rename from 0006-disk.in.h-Remove-use-of-enums-with-define.patch rename to 0008-disk.in.h-Remove-use-of-enums-with-define.patch index 335be09..bb56d68 100644 --- a/0006-disk.in.h-Remove-use-of-enums-with-define.patch +++ b/0008-disk.in.h-Remove-use-of-enums-with-define.patch @@ -1,7 +1,7 @@ From aa690ee275db86d1edb2468bcf31c3d7cf81228e Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 4 Aug 2022 11:39:09 -0700 -Subject: [PATCH] disk.in.h: Remove use of enums with #define +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 @@ -55,5 +55,5 @@ index 672c4ee..715637d 100644 struct _PedDisk; struct _PedPartition; -- -2.37.1 +2.37.3 diff --git a/0008-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch b/0008-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch deleted file mode 100644 index 3484833..0000000 --- a/0008-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch +++ /dev/null @@ -1,160 +0,0 @@ -From 14cf5be3d322d7e3e81c21a3542ae046a5fe1fda Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -Date: Mon, 8 Aug 2022 13:49:09 -0700 -Subject: [PATCH 08/10] 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 -+#include -+ -+#include -+ -+#include -+ -+#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 . -+ -+. "${top_srcdir=../..}/tests/init.sh"; path_prepend_ . -+ -+flags || fail=1 -+ -+Exit $fail --- -2.37.1 - diff --git a/0007-libparted-Fix-handling-of-gpt-partition-types.patch b/0009-libparted-Fix-handling-of-gpt-partition-types.patch similarity index 95% rename from 0007-libparted-Fix-handling-of-gpt-partition-types.patch rename to 0009-libparted-Fix-handling-of-gpt-partition-types.patch index 1d13342..bfe30cb 100644 --- a/0007-libparted-Fix-handling-of-gpt-partition-types.patch +++ b/0009-libparted-Fix-handling-of-gpt-partition-types.patch @@ -1,7 +1,7 @@ -From 717d39a0a16b6fddfac65cf355a895d04995cdff Mon Sep 17 00:00:00 2001 +From 8957382b98fd79bc06dad132ef28a0be8b46ea16 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 8 Aug 2022 12:04:32 -0700 -Subject: [PATCH 07/10] libparted: Fix handling of gpt partition types +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 @@ -97,5 +97,5 @@ index 0e9e060..8e6a37d 100644 } -- -2.37.1 +2.37.3 diff --git a/0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch b/0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch index 4c313e7..b905115 100644 --- a/0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch +++ b/0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch @@ -1,35 +1,90 @@ -From 7830678dbe832ea6815d9a31be8cbe3a67f3ed7e Mon Sep 17 00:00:00 2001 +From d50b7bf2b66b7b67ee332c1af63bc1f5fdfba7ad Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" -Date: Mon, 8 Aug 2022 15:06:03 -0700 -Subject: [PATCH 10/10] tests: Add a libparted test for - ped_partition_set_system on msdos +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/flags.c | 35 +++++++++++++++++++++++++++++++++++ - 1 file changed, 35 insertions(+) + 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/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 +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. -+/* TEST: Test partition type flag on msdos disklabel */ -+START_TEST (test_msdos_flag) +-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 ++#include ++ ++#include ++ ++#include ++ ++#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 ("msdos")); ++ 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_BLS_BOOT, 1); ++ 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")); + @@ -39,37 +94,67 @@ index c83a361..c4b290b 100644 + + // 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"); ++ 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) - { -@@ -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); ++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"); + - SRunner* srunner = srunner_create (suite); - srunner_run_all (srunner, CK_VERBOSE); - ++ /* 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 . ++ ++. "${top_srcdir=../..}/tests/init.sh"; path_prepend_ . ++ ++flags || fail=1 ++ ++Exit $fail -- -2.37.1 +2.37.3 diff --git a/0009-libparted-Fix-handling-of-msdos-partition-types.patch b/0011-libparted-Fix-handling-of-msdos-partition-types.patch similarity index 95% rename from 0009-libparted-Fix-handling-of-msdos-partition-types.patch rename to 0011-libparted-Fix-handling-of-msdos-partition-types.patch index 1b689e0..bcbb062 100644 --- a/0009-libparted-Fix-handling-of-msdos-partition-types.patch +++ b/0011-libparted-Fix-handling-of-msdos-partition-types.patch @@ -1,7 +1,7 @@ -From 9be9067bc5a3641fc890b0d4ba994000941109bf Mon Sep 17 00:00:00 2001 +From 4a0e468ed63fff85a1f9b923189f20945b32f4f1 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 8 Aug 2022 15:02:30 -0700 -Subject: [PATCH 09/10] libparted: Fix handling of msdos partition types +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. @@ -105,5 +105,5 @@ index bd7465d..4359276 100644 switch (flag) { -- -2.37.1 +2.37.3 diff --git a/0012-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch b/0012-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch new file mode 100644 index 0000000..0628463 --- /dev/null +++ b/0012-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch @@ -0,0 +1,75 @@ +From 8f37b28825933af9bbbac7f00cc7e23f916c7018 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +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 + diff --git a/0013-show-GPT-UUIDs-in-JSON-output.patch b/0013-show-GPT-UUIDs-in-JSON-output.patch new file mode 100644 index 0000000..31518b5 --- /dev/null +++ b/0013-show-GPT-UUIDs-in-JSON-output.patch @@ -0,0 +1,351 @@ +From 2194035fc0fe678472d279676a13511769f7ef20 Mon Sep 17 00:00:00 2001 +From: Arvin Schnell +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": ""/' > out 2>&1 || fail=1 + + cat < exp || fail=1 + { +@@ -45,6 +45,7 @@ cat < exp || fail=1 + "logical-sector-size": 512, + "physical-sector-size": 512, + "label": "gpt", ++ "uuid": "", + "max-partitions": 128, + "flags": [ + "pmbr_boot" +@@ -63,6 +64,7 @@ cat < exp || fail=1 + "size": "10240s", + "type": "primary", + "type-uuid": "0fc63daf-8483-4772-8e79-3d69d8477de4", ++ "uuid": "", + "name": "test1" + },{ + "number": 2, +@@ -71,6 +73,7 @@ cat < exp || fail=1 + "size": "40960s", + "type": "primary", + "type-uuid": "a19d880f-05fc-4d3b-a006-743f0f84911e", ++ "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": ""/' > out 2>&1 || fail=1 + + cat < exp || fail=1 + { +@@ -45,6 +45,7 @@ cat < exp || fail=1 + "logical-sector-size": 512, + "physical-sector-size": 512, + "label": "gpt", ++ "uuid": "", + "max-partitions": 128, + "partitions": [ + { +@@ -53,7 +54,8 @@ cat < exp || fail=1 + "end": "20479s", + "size": "10240s", + "type": "primary", +- "type-uuid": "deadfd6d-a4ab-43c4-84e5-0933c84b4f4f" ++ "type-uuid": "deadfd6d-a4ab-43c4-84e5-0933c84b4f4f", ++ "uuid": "" + } + ] + } +-- +2.37.3 + diff --git a/0014-gpt-Add-no_automount-partition-flag.patch b/0014-gpt-Add-no_automount-partition-flag.patch new file mode 100644 index 0000000..66d16eb --- /dev/null +++ b/0014-gpt-Add-no_automount-partition-flag.patch @@ -0,0 +1,145 @@ +From 55e4775c989af42d629401b9aa22c60ba2993e7d Mon Sep 17 00:00:00 2001 +From: Mike Fleetwood +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 +Signed-off-by: Brian C. Lane +--- + 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 + diff --git a/0015-tests-XFS-requires-a-minimum-size-of-300M.patch b/0015-tests-XFS-requires-a-minimum-size-of-300M.patch new file mode 100644 index 0000000..48e0e87 --- /dev/null +++ b/0015-tests-XFS-requires-a-minimum-size-of-300M.patch @@ -0,0 +1,54 @@ +From caa588269709659d5cf51bf64c559e193f371de4 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +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 + diff --git a/parted.spec b/parted.spec index ea6c27d..f2d6583 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.5 -Release: 6%{?dist} +Release: 7%{?dist} License: GPLv3+ URL: http://www.gnu.org/software/parted @@ -16,12 +16,16 @@ 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-disk.in.h-Remove-use-of-enums-with-define.patch -Patch0007: 0007-libparted-Fix-handling-of-gpt-partition-types.patch -Patch0008: 0008-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch -Patch0009: 0009-libparted-Fix-handling-of-msdos-partition-types.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 BuildRequires: gcc BuildRequires: e2fsprogs-devel @@ -126,7 +130,14 @@ make check %changelog -* Mon Aug 08 2022 Brian C. Lane - 3.5-5.bcl.1 +* Wed Dec 14 2022 Brian C. Lane - 3.5-7 +- libparted: Fix handling of msdos partition types +- tests: Add a libparted test for ped_partition_set_system on msdos +- parted: Add display of GPT UUIDs in JSON output +- Add no_automount flag support +- increase xfs size to 300M + +* Mon Aug 08 2022 Brian C. Lane - 3.5-6 - Fix ped_partition_set_system handling of existing flags * Thu Aug 04 2022 Brian C. Lane - 3.5-5 From d2e6c54e3e6a04c5829997e3e8e0b451ec78a6e4 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 14 Dec 2022 15:45:52 -0800 Subject: [PATCH 03/23] tests: Add gating.yaml so tests will be required --- gating.yaml | 7 +++++++ 1 file changed, 7 insertions(+) create mode 100644 gating.yaml diff --git a/gating.yaml b/gating.yaml new file mode 100644 index 0000000..0c1cc35 --- /dev/null +++ b/gating.yaml @@ -0,0 +1,7 @@ +--- !Policy +product_versions: + - fedora-* +decision_contexts: [bodhi_update_push_stable] +subject_type: koji_build +rules: + - !PassingTestCaseRule {test_case_name: fedora-ci.koji-build.tier0.functional} From 270e49b9665c44e0162d813c7726471a0e776e90 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 19 Jan 2023 23:25:37 +0000 Subject: [PATCH 04/23] Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- parted.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parted.spec b/parted.spec index f2d6583..e5a144f 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.5 -Release: 7%{?dist} +Release: 8%{?dist} License: GPLv3+ URL: http://www.gnu.org/software/parted @@ -130,6 +130,9 @@ make check %changelog +* Thu Jan 19 2023 Fedora Release Engineering - 3.5-8 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild + * Wed Dec 14 2022 Brian C. Lane - 3.5-7 - libparted: Fix handling of msdos partition types - tests: Add a libparted test for ped_partition_set_system on msdos From fb7cd25e733cf62ed9722d9f3dee5586402f545f Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 30 Jan 2023 15:09:42 -0800 Subject: [PATCH 05/23] SPDX migration --- parted.spec | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/parted.spec b/parted.spec index e5a144f..1ba4842 100644 --- a/parted.spec +++ b/parted.spec @@ -1,8 +1,8 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.5 -Release: 8%{?dist} -License: GPLv3+ +Release: 9%{?dist} +License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted Source0: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz @@ -130,6 +130,9 @@ make check %changelog +* Mon Jan 30 2023 Brian C. Lane - 3.5-9 +- SPDX migration + * Thu Jan 19 2023 Fedora Release Engineering - 3.5-8 - Rebuilt for https://fedoraproject.org/wiki/Fedora_38_Mass_Rebuild From dc75c40906570c4e1bac7c56fa2b942a6dcd9ab3 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 7 Feb 2023 16:44:57 -0800 Subject: [PATCH 06/23] - libparted: Fix problem with creating 1s partitions - tests: Fixing libparted test framework usage --- ...-problem-with-creating-1s-partitions.patch | 133 +++++++++ ...ixing-libparted-test-framework-usage.patch | 262 ++++++++++++++++++ parted.spec | 8 +- 3 files changed, 402 insertions(+), 1 deletion(-) create mode 100644 0016-libparted-Fix-problem-with-creating-1s-partitions.patch create mode 100644 0017-tests-Fixing-libparted-test-framework-usage.patch diff --git a/0016-libparted-Fix-problem-with-creating-1s-partitions.patch b/0016-libparted-Fix-problem-with-creating-1s-partitions.patch new file mode 100644 index 0000000..1cab2e6 --- /dev/null +++ b/0016-libparted-Fix-problem-with-creating-1s-partitions.patch @@ -0,0 +1,133 @@ +From 9b009985da2e5eee5b5c179acfafab3aa1624f8b Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +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 . ++ ++. "${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 . ++ ++. "${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 + diff --git a/0017-tests-Fixing-libparted-test-framework-usage.patch b/0017-tests-Fixing-libparted-test-framework-usage.patch new file mode 100644 index 0000000..86f0705 --- /dev/null +++ b/0017-tests-Fixing-libparted-test-framework-usage.patch @@ -0,0 +1,262 @@ +From 7b555132be63172a2d621afcdedfa7797185d3b5 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +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 + diff --git a/parted.spec b/parted.spec index 1ba4842..9a2cd2c 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.5 -Release: 9%{?dist} +Release: 10%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -26,6 +26,8 @@ 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 BuildRequires: gcc BuildRequires: e2fsprogs-devel @@ -130,6 +132,10 @@ make check %changelog +* Tue Feb 07 2023 Brian C. Lane - 3.5-9.bcl.1 +- libparted: Fix problem with creating 1s partitions +- tests: Fixing libparted test framework usage + * Mon Jan 30 2023 Brian C. Lane - 3.5-9 - SPDX migration From d747d1a8fec6c2f52350c41756bc72f4ad3955af Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 17 Mar 2023 16:27:05 -0700 Subject: [PATCH 07/23] - parted: Fix ending sector location when using kibi IEC suffix (bcl) - tests: Fix formatting and snprintf warnings in tests. (bcl) - ui: Add checks for prompt being NULL (bcl) - strlist: Handle realloc error in wchar_to_str (bcl) - libparted: Fix potential NULL dereference in ped_disk_next_partition (bcl) - filesys: Check for null from close_fn (bcl) --- ...filesys-Check-for-null-from-close_fn.patch | 28 ++++ ...tential-NULL-dereference-in-ped_disk.patch | 30 ++++ ...Handle-realloc-error-in-wchar_to_str.patch | 28 ++++ ...-ui-Add-checks-for-prompt-being-NULL.patch | 50 ++++++ ...tting-and-snprintf-warnings-in-tests.patch | 46 ++++++ ...g-sector-location-when-using-kibi-IE.patch | 146 ++++++++++++++++++ parted.spec | 18 ++- 7 files changed, 344 insertions(+), 2 deletions(-) create mode 100644 0018-filesys-Check-for-null-from-close_fn.patch create mode 100644 0019-libparted-Fix-potential-NULL-dereference-in-ped_disk.patch create mode 100644 0020-strlist-Handle-realloc-error-in-wchar_to_str.patch create mode 100644 0021-ui-Add-checks-for-prompt-being-NULL.patch create mode 100644 0022-tests-Fix-formatting-and-snprintf-warnings-in-tests.patch create mode 100644 0023-parted-Fix-ending-sector-location-when-using-kibi-IE.patch diff --git a/0018-filesys-Check-for-null-from-close_fn.patch b/0018-filesys-Check-for-null-from-close_fn.patch new file mode 100644 index 0000000..1793509 --- /dev/null +++ b/0018-filesys-Check-for-null-from-close_fn.patch @@ -0,0 +1,28 @@ +From c409dbf423d870ab26684cd6a6953c76c4a08d7f Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +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 + diff --git a/0019-libparted-Fix-potential-NULL-dereference-in-ped_disk.patch b/0019-libparted-Fix-potential-NULL-dereference-in-ped_disk.patch new file mode 100644 index 0000000..7fb9647 --- /dev/null +++ b/0019-libparted-Fix-potential-NULL-dereference-in-ped_disk.patch @@ -0,0 +1,30 @@ +From 31db44c74a96f8e2b495205d18525449e9b29543 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +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 + diff --git a/0020-strlist-Handle-realloc-error-in-wchar_to_str.patch b/0020-strlist-Handle-realloc-error-in-wchar_to_str.patch new file mode 100644 index 0000000..b2f9ca4 --- /dev/null +++ b/0020-strlist-Handle-realloc-error-in-wchar_to_str.patch @@ -0,0 +1,28 @@ +From 9cb38a7444d02023d112ae8e9e38436104f75f64 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +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 + diff --git a/0021-ui-Add-checks-for-prompt-being-NULL.patch b/0021-ui-Add-checks-for-prompt-being-NULL.patch new file mode 100644 index 0000000..4f342a2 --- /dev/null +++ b/0021-ui-Add-checks-for-prompt-being-NULL.patch @@ -0,0 +1,50 @@ +From 09c95d2feab0c087339886134dfe2dc04094348a Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +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 + diff --git a/0022-tests-Fix-formatting-and-snprintf-warnings-in-tests.patch b/0022-tests-Fix-formatting-and-snprintf-warnings-in-tests.patch new file mode 100644 index 0000000..12b403c --- /dev/null +++ b/0022-tests-Fix-formatting-and-snprintf-warnings-in-tests.patch @@ -0,0 +1,46 @@ +From d272bb5b5343fd288a204314654a7fbaea84528d Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +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 + diff --git a/0023-parted-Fix-ending-sector-location-when-using-kibi-IE.patch b/0023-parted-Fix-ending-sector-location-when-using-kibi-IE.patch new file mode 100644 index 0000000..dca568c --- /dev/null +++ b/0023-parted-Fix-ending-sector-location-when-using-kibi-IE.patch @@ -0,0 +1,146 @@ +From 3f6b723a7d610d98afb0c9d0cfefe4700712e4db Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +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 + diff --git a/parted.spec b/parted.spec index 9a2cd2c..f474be6 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.5 -Release: 10%{?dist} +Release: 11%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -28,6 +28,12 @@ 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: e2fsprogs-devel @@ -132,7 +138,15 @@ make check %changelog -* Tue Feb 07 2023 Brian C. Lane - 3.5-9.bcl.1 +* Fri Mar 17 2023 Brian C. Lane - 3.5-11 +- parted: Fix ending sector location when using kibi IEC suffix (bcl) +- tests: Fix formatting and snprintf warnings in tests. (bcl) +- ui: Add checks for prompt being NULL (bcl) +- strlist: Handle realloc error in wchar_to_str (bcl) +- libparted: Fix potential NULL dereference in ped_disk_next_partition (bcl) +- filesys: Check for null from close_fn (bcl) + +* Tue Feb 07 2023 Brian C. Lane - 3.5-10 - libparted: Fix problem with creating 1s partitions - tests: Fixing libparted test framework usage From 7fdac872b5806876f8184185e3b77c6659101ce1 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 27 Mar 2023 08:13:23 -0700 Subject: [PATCH 08/23] - 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 --- .gitignore | 2 + 0001-maint-post-release-administrivia.patch | 50 - 0002-parted-add-type-command.patch | 1636 ----------------- ...bparted-add-swap-flag-for-DASD-label.patch | 228 --- ...-filesystem-type-when-changing-the-i.patch | 30 - 0005-tests-t3200-type-change-now-passes.patch | 23 - ...eck-for-availability-of-_type_id-fun.patch | 40 - ...parted-Simplify-code-for-json-output.patch | 34 - ...in.h-Remove-use-of-enums-with-define.patch | 59 - ...-Fix-handling-of-gpt-partition-types.patch | 101 - ...arted-test-for-ped_partition_set_sys.patch | 160 -- ...ix-handling-of-msdos-partition-types.patch | 109 -- ...arted-test-for-ped_partition_set_sys.patch | 75 - 0013-show-GPT-UUIDs-in-JSON-output.patch | 351 ---- ...-gpt-Add-no_automount-partition-flag.patch | 145 -- ...-XFS-requires-a-minimum-size-of-300M.patch | 54 - ...-problem-with-creating-1s-partitions.patch | 133 -- ...ixing-libparted-test-framework-usage.patch | 262 --- ...filesys-Check-for-null-from-close_fn.patch | 28 - ...tential-NULL-dereference-in-ped_disk.patch | 30 - ...Handle-realloc-error-in-wchar_to_str.patch | 28 - ...-ui-Add-checks-for-prompt-being-NULL.patch | 50 - ...tting-and-snprintf-warnings-in-tests.patch | 46 - ...g-sector-location-when-using-kibi-IE.patch | 146 -- parted.spec | 38 +- sources | 4 +- 26 files changed, 13 insertions(+), 3849 deletions(-) delete mode 100644 0001-maint-post-release-administrivia.patch delete mode 100644 0002-parted-add-type-command.patch delete mode 100644 0003-libparted-add-swap-flag-for-DASD-label.patch delete mode 100644 0004-parted-Reset-the-filesystem-type-when-changing-the-i.patch delete mode 100644 0005-tests-t3200-type-change-now-passes.patch delete mode 100644 0006-libparted-Fix-check-for-availability-of-_type_id-fun.patch delete mode 100644 0007-parted-Simplify-code-for-json-output.patch delete mode 100644 0008-disk.in.h-Remove-use-of-enums-with-define.patch delete mode 100644 0009-libparted-Fix-handling-of-gpt-partition-types.patch delete mode 100644 0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch delete mode 100644 0011-libparted-Fix-handling-of-msdos-partition-types.patch delete mode 100644 0012-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch delete mode 100644 0013-show-GPT-UUIDs-in-JSON-output.patch delete mode 100644 0014-gpt-Add-no_automount-partition-flag.patch delete mode 100644 0015-tests-XFS-requires-a-minimum-size-of-300M.patch delete mode 100644 0016-libparted-Fix-problem-with-creating-1s-partitions.patch delete mode 100644 0017-tests-Fixing-libparted-test-framework-usage.patch delete mode 100644 0018-filesys-Check-for-null-from-close_fn.patch delete mode 100644 0019-libparted-Fix-potential-NULL-dereference-in-ped_disk.patch delete mode 100644 0020-strlist-Handle-realloc-error-in-wchar_to_str.patch delete mode 100644 0021-ui-Add-checks-for-prompt-being-NULL.patch delete mode 100644 0022-tests-Fix-formatting-and-snprintf-warnings-in-tests.patch delete mode 100644 0023-parted-Fix-ending-sector-location-when-using-kibi-IE.patch diff --git a/.gitignore b/.gitignore index c6404f5..fdd046b 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,5 @@ clog /parted-3.4.64.tar.xz.sig /parted-3.5.tar.xz /parted-3.5.tar.xz.sig +/parted-3.5.28.tar.xz +/parted-3.5.28.tar.xz.sig diff --git a/0001-maint-post-release-administrivia.patch b/0001-maint-post-release-administrivia.patch deleted file mode 100644 index d8aa4ef..0000000 --- a/0001-maint-post-release-administrivia.patch +++ /dev/null @@ -1,50 +0,0 @@ -From cec533a00a2cd0b64a7a0f5debc26554f6025831 Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0002-parted-add-type-command.patch b/0002-parted-add-type-command.patch deleted file mode 100644 index 4eddee7..0000000 --- a/0002-parted-add-type-command.patch +++ /dev/null @@ -1,1636 +0,0 @@ -From 61b3a9733c0e0a79ccc43096642d378c8706add6 Mon Sep 17 00:00:00 2001 -From: Arvin Schnell -Date: Wed, 11 May 2022 14:02:21 +0000 -Subject: [PATCH 02/13] parted: add type command - -Include the partition type-id and type-uuid in the JSON -output. Also add the the command 'type' to set them. Remove -redundant flags from DosPartitionData and use only the system -variable. - -Signed-off-by: Brian C. Lane ---- - NEWS | 3 + - doc/C/parted.8 | 5 + - doc/parted.texi | 20 + - include/parted/disk.in.h | 23 +- - libparted/disk.c | 102 +++++ - libparted/labels/dasd.c | 4 + - libparted/labels/dos.c | 621 ++++++++++++-------------- - libparted/labels/gpt.c | 44 +- - parted/parted.c | 113 ++++- - tests/Makefile.am | 4 + - tests/t0800-json-gpt.sh | 2 + - tests/t0801-json-msdos.sh | 5 +- - tests/t0900-type-gpt.sh | 69 +++ - tests/t0901-type-gpt-invalid.sh | 35 ++ - tests/t0910-type-dos.sh | 69 +++ - tests/t0911-type-dos-invalid.sh | 35 ++ - tests/t2400-dos-hfs-partition-type.sh | 2 +- - tests/t3300-palo-prep.sh | 8 +- - tests/t3310-flags.sh | 4 + - 19 files changed, 825 insertions(+), 343 deletions(-) - create mode 100755 tests/t0900-type-gpt.sh - create mode 100755 tests/t0901-type-gpt-invalid.sh - create mode 100755 tests/t0910-type-dos.sh - create mode 100755 tests/t0911-type-dos-invalid.sh - -diff --git a/NEWS b/NEWS -index 2bd161f..099f8bd 100644 ---- a/NEWS -+++ b/NEWS -@@ -2,6 +2,9 @@ GNU parted NEWS -*- outline -*- - - * Noteworthy changes in release ?.? (????-??-??) [?] - -+** New Features -+ -+ 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 7895440..ab34be7 100644 ---- a/doc/C/parted.8 -+++ b/doc/C/parted.8 -@@ -134,6 +134,11 @@ human-friendly form for output). - .B toggle \fIpartition\fP \fIflag\fP - Toggle the state of \fIflag\fP on \fIpartition\fP. - .TP -+.B type \fIpartition\fP \fIid\fP or \fIuuid\fP -+On MS-DOS set the type aka. partition id of \fIpartition\fP to -+\fIid\fP. The \fIid\fP is a value between "0x01" and "0xff". On GPT -+the type-uuid of \fIpartition\fP to \fIuuid\fP. -+.TP - .B disk_set \fIflag\fP \fIstate\fP - Change a \fIflag\fP on the disk to \fIstate\fP. A flag can be either "on" or "off". - Some or all of these flags will be available, depending on what disk label you -diff --git a/doc/parted.texi b/doc/parted.texi -index 8a3978a..9c9d282 100644 ---- a/doc/parted.texi -+++ b/doc/parted.texi -@@ -466,6 +466,7 @@ GNU Parted provides the following commands: - * select:: - * set:: - * toggle:: -+* type:: - * unit:: - @end menu - -@@ -1034,6 +1035,25 @@ Toggle the state of @var{flag} on partition @var{number}. - - @end deffn - -+@node type -+@subsection type -+@cindex type, command description -+@cindex command description, type -+ -+@deffn Command type @var{number} @var{id} or @var{uuid} -+ -+On MS-DOS set the type-id aka partition id to @var{id} on partition -+@var{number}. The id is a value between 0x01 and 0xff, e.g. the ID for -+Linux is 0x83. A list with some IDs is available at -+@uref{https://en.wikipedia.org/wiki/Partition_type}. -+ -+On GPT set the type-uuid to @var{uuid} on partition -+@var{number}. E.g. the UUID for Linux is -+0fc63daf-8483-4772-8e79-3d69d8477de4. A list with some UUIDs is availabe -+at @uref{https://en.wikipedia.org/wiki/GUID_Partition_Table}. -+ -+@end deffn -+ - @node unit - @subsection unit - @cindex unit, command description -diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h -index 38e869d..672c4ee 100644 ---- a/include/parted/disk.in.h -+++ b/include/parted/disk.in.h -@@ -32,6 +32,7 @@ - */ - #include - #include -+#include - - /** - * Disk flags -@@ -91,11 +92,13 @@ enum _PedPartitionFlag { - #define PED_PARTITION_LAST_FLAG PED_PARTITION_LINUX_HOME - - enum _PedDiskTypeFeature { -- PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */ -- PED_DISK_TYPE_PARTITION_NAME=2 /**< supports partition names */ -+ PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */ -+ 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 */ - }; - #define PED_DISK_TYPE_FIRST_FEATURE PED_DISK_TYPE_EXTENDED --#define PED_DISK_TYPE_LAST_FEATURE PED_DISK_TYPE_PARTITION_NAME -+#define PED_DISK_TYPE_LAST_FEATURE PED_DISK_TYPE_PARTITION_TYPE_UUID - - struct _PedDisk; - struct _PedPartition; -@@ -247,6 +250,13 @@ struct _PedDiskOps { - PedPartitionFlag flag); - void (*partition_set_name) (PedPartition* part, const char* name); - const char* (*partition_get_name) (const PedPartition* part); -+ -+ int (*partition_set_type_id) (PedPartition* part, uint8_t id); -+ uint8_t (*partition_get_type_id) (const PedPartition* part); -+ -+ int (*partition_set_type_uuid) (PedPartition* part, const uint8_t* uuid); -+ uint8_t* (*partition_get_type_uuid) (const PedPartition* part); -+ - int (*partition_align) (PedPartition* part, - const PedConstraint* constraint); - int (*partition_enumerate) (PedPartition* part); -@@ -347,6 +357,13 @@ extern int ped_partition_set_system (PedPartition* part, - const PedFileSystemType* fs_type); - extern int ped_partition_set_name (PedPartition* part, const char* name); - extern const char* ped_partition_get_name (const PedPartition* part); -+ -+extern int ped_partition_set_type_id (PedPartition* part, uint8_t id); -+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 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 3bf7634..22dff36 100644 ---- a/libparted/disk.c -+++ b/libparted/disk.c -@@ -1458,6 +1458,36 @@ _assert_partition_name_feature (const PedDiskType* disk_type) - return 1; - } - -+static int -+_assert_partition_type_id_feature (const PedDiskType* disk_type) -+{ -+ if (!ped_disk_type_check_feature ( -+ disk_type, PED_DISK_TYPE_PARTITION_TYPE_ID)) { -+ ped_exception_throw ( -+ PED_EXCEPTION_ERROR, -+ PED_EXCEPTION_CANCEL, -+ "%s disk labels do not support partition type-ids.", -+ disk_type->name); -+ return 0; -+ } -+ return 1; -+} -+ -+static int -+_assert_partition_type_uuid_feature (const PedDiskType* disk_type) -+{ -+ if (!ped_disk_type_check_feature ( -+ disk_type, PED_DISK_TYPE_PARTITION_TYPE_UUID)) { -+ ped_exception_throw ( -+ PED_EXCEPTION_ERROR, -+ PED_EXCEPTION_CANCEL, -+ "%s disk labels do not support partition type-uuids.", -+ disk_type->name); -+ return 0; -+ } -+ return 1; -+} -+ - /** - * Sets the name of a partition. - * -@@ -1510,6 +1540,78 @@ ped_partition_get_name (const PedPartition* part) - return part->disk->type->ops->partition_get_name (part); - } - -+/** -+ * Set the type-id of the partition \p part. This will only work if the disk label -+ * supports it. -+ */ -+int -+ped_partition_set_type_id (PedPartition *part, uint8_t id) -+{ -+ PED_ASSERT (part != NULL); -+ PED_ASSERT (part->disk != NULL); -+ PED_ASSERT (ped_partition_is_active (part)); -+ -+ if (!_assert_partition_type_id_feature (part->disk->type)) -+ return 0; -+ -+ PED_ASSERT (part->disk->type->ops->partition_set_type_id != NULL); -+ return part->disk->type->ops->partition_set_type_id (part, id); -+} -+ -+/** -+ * Get the type-id of the partition \p part. This will only work if the disk label -+ * supports it. -+ */ -+uint8_t -+ped_partition_get_type_id (const PedPartition *part) -+{ -+ PED_ASSERT (part != NULL); -+ PED_ASSERT (part->disk != NULL); -+ PED_ASSERT (ped_partition_is_active (part)); -+ -+ if (!_assert_partition_type_id_feature (part->disk->type)) -+ return 0; -+ -+ PED_ASSERT (part->disk->type->ops->partition_set_type_id != NULL); -+ return part->disk->type->ops->partition_get_type_id (part); -+} -+ -+/** -+ * Set the type-uuid of the partition \p part. This will only work if the disk label -+ * supports it. -+ */ -+int -+ped_partition_set_type_uuid (PedPartition *part, const uint8_t* uuid) -+{ -+ PED_ASSERT (part != NULL); -+ PED_ASSERT (part->disk != NULL); -+ PED_ASSERT (ped_partition_is_active (part)); -+ -+ if (!_assert_partition_type_uuid_feature (part->disk->type)) -+ return 0; -+ -+ PED_ASSERT (part->disk->type->ops->partition_set_type_uuid != NULL); -+ return part->disk->type->ops->partition_set_type_uuid (part, uuid); -+} -+ -+/** -+ * Get the type-uuid of the partition \p part. This will only work if the disk label -+ * supports it. -+ */ -+uint8_t* -+ped_partition_get_type_uuid (const PedPartition *part) -+{ -+ PED_ASSERT (part != NULL); -+ PED_ASSERT (part->disk != NULL); -+ PED_ASSERT (ped_partition_is_active (part)); -+ -+ if (!_assert_partition_type_uuid_feature (part->disk->type)) -+ return NULL; -+ -+ PED_ASSERT (part->disk->type->ops->partition_set_type_uuid != NULL); -+ return part->disk->type->ops->partition_get_type_uuid (part); -+} -+ - /** @} */ - - /** -diff --git a/libparted/labels/dasd.c b/libparted/labels/dasd.c -index 38f2b00..0c00c4f 100644 ---- a/libparted/labels/dasd.c -+++ b/libparted/labels/dasd.c -@@ -117,6 +117,10 @@ static PedDiskOps dasd_disk_ops = { - - partition_set_name: NULL, - partition_get_name: NULL, -+ partition_set_type_id: NULL, -+ partition_get_type_id: NULL, -+ partition_set_type_uuid: NULL, -+ partition_get_type_uuid: NULL, - - get_partition_alignment: dasd_get_partition_alignment, - -diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c -index 26d8804..bd7465d 100644 ---- a/libparted/labels/dos.c -+++ b/libparted/labels/dos.c -@@ -100,6 +100,209 @@ static const char MBR_BOOT_CODE[] = { - #define PARTITION_LINUX_RAID 0xfd - #define PARTITION_LINUX_LVM_OLD 0xfe - -+struct flag_id_mapping_t -+{ -+ enum _PedPartitionFlag flag; -+ unsigned char type_id; -+ unsigned char alt_type_id; -+}; -+ -+static const struct flag_id_mapping_t flag_id_mapping[] = -+{ -+ { PED_PARTITION_BLS_BOOT, PARTITION_BLS_BOOT }, -+ { PED_PARTITION_DIAG, PARTITION_COMPAQ_DIAG, PARTITION_DELL_DIAG }, -+ { PED_PARTITION_ESP, PARTITION_ESP }, -+ { PED_PARTITION_IRST, PARTITION_IRST }, -+ { PED_PARTITION_LVM, PARTITION_LINUX_LVM, PARTITION_LINUX_LVM_OLD }, -+ { PED_PARTITION_MSFT_RESERVED, PARTITION_MSFT_RECOVERY }, -+ { PED_PARTITION_PALO, PARTITION_PALO }, -+ { PED_PARTITION_PREP, PARTITION_PREP }, -+ { PED_PARTITION_RAID, PARTITION_LINUX_RAID }, -+ { PED_PARTITION_SWAP, PARTITION_LINUX_SWAP }, -+}; -+ -+static const struct flag_id_mapping_t* _GL_ATTRIBUTE_CONST -+dos_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; -+} -+ -+/** -+ * Check whether the type_id supports the hidden flag. Returns true for both hidden and -+ * non-hidden id. -+ */ -+static bool -+dos_type_id_supports_hidden(unsigned char type_id) -+{ -+ switch (type_id) -+ { -+ case PARTITION_DOS_EXT: -+ case PARTITION_DOS_EXT_H: -+ case PARTITION_FAT12: -+ case PARTITION_FAT12_H: -+ case PARTITION_FAT16: -+ case PARTITION_FAT16_H: -+ case PARTITION_FAT16_LBA: -+ case PARTITION_FAT16_LBA_H: -+ case PARTITION_FAT16_SM: -+ case PARTITION_FAT16_SM_H: -+ case PARTITION_FAT32: -+ case PARTITION_FAT32_H: -+ case PARTITION_FAT32_LBA: -+ case PARTITION_FAT32_LBA_H: -+ case PARTITION_NTFS: -+ case PARTITION_NTFS_H: -+ return true; -+ -+ default: -+ return false; -+ } -+} -+ -+/** -+ * Check whether the type_id has the hidden flag set. -+ */ -+static bool -+dos_type_id_is_hidden(unsigned char type_id) -+{ -+ switch (type_id) -+ { -+ case PARTITION_DOS_EXT_H: -+ case PARTITION_FAT12_H: -+ case PARTITION_FAT16_H: -+ case PARTITION_FAT16_LBA_H: -+ case PARTITION_FAT16_SM_H: -+ case PARTITION_FAT32_H: -+ case PARTITION_FAT32_LBA_H: -+ case PARTITION_NTFS_H: -+ return true; -+ -+ default: -+ return false; -+ } -+} -+ -+/** -+ * Sets the hidden flag on type_id. -+ */ -+static bool -+dos_type_id_set_hidden(unsigned char* type_id, bool state) -+{ -+ PED_ASSERT (type_id); -+ -+ if (!dos_type_id_supports_hidden(*type_id)) -+ return false; -+ -+ if (state) -+ *type_id |= PART_FLAG_HIDDEN; -+ else -+ *type_id &= ~PART_FLAG_HIDDEN; -+ -+ return 1; -+} -+ -+/** -+ * Check whether the type_id supports the lba flag. Returns true for both lba and non-lba -+ * id. -+ */ -+static bool -+dos_type_id_supports_lba(unsigned char type_id) -+{ -+ switch (type_id) -+ { -+ case PARTITION_FAT16: -+ case PARTITION_FAT16_H: -+ case PARTITION_FAT16_LBA: -+ case PARTITION_FAT16_LBA_H: -+ case PARTITION_FAT32: -+ case PARTITION_FAT32_H: -+ case PARTITION_FAT32_LBA: -+ case PARTITION_FAT32_LBA_H: -+ case PARTITION_DOS_EXT: -+ case PARTITION_EXT_LBA: -+ return true; -+ -+ default: -+ return false; -+ } -+} -+ -+/** -+ * Check whether the type_id has the lba flag set. -+ */ -+static bool -+dos_type_id_is_lba(unsigned char type_id) -+{ -+ switch (type_id) -+ { -+ case PARTITION_FAT16_LBA: -+ case PARTITION_FAT16_LBA_H: -+ case PARTITION_FAT32_LBA: -+ case PARTITION_FAT32_LBA_H: -+ case PARTITION_EXT_LBA: -+ return true; -+ -+ default: -+ return false; -+ } -+} -+ -+/** -+ * Sets the lba flag on type_id. -+ */ -+static bool -+dos_type_id_set_lba(unsigned char* type_id, bool state) -+{ -+ PED_ASSERT (type_id); -+ -+ if (!dos_type_id_supports_lba(*type_id)) -+ return false; -+ -+ if (state) -+ { -+ switch (*type_id) -+ { -+ case PARTITION_FAT16: -+ *type_id = PARTITION_FAT16_LBA; -+ break; -+ -+ case PARTITION_FAT32: -+ *type_id = PARTITION_FAT32_LBA; -+ break; -+ -+ case PARTITION_DOS_EXT: -+ *type_id = PARTITION_EXT_LBA; -+ break; -+ } -+ } -+ else -+ { -+ switch (*type_id) -+ { -+ case PARTITION_FAT16_LBA: -+ *type_id = PARTITION_FAT16; -+ break; -+ -+ case PARTITION_FAT32_LBA: -+ *type_id = PARTITION_FAT32; -+ break; -+ -+ case PARTITION_EXT_LBA: -+ *type_id = PARTITION_DOS_EXT; -+ break; -+ } -+ } -+ -+ return true; -+} -+ -+ - /* This constant contains the maximum cylinder number that can be represented - * in (C,H,S) notation. Higher cylinder numbers are reserved for - * "too big" indicators (in which case only LBA addressing can be used). -@@ -156,18 +359,6 @@ typedef struct { - typedef struct { - unsigned char system; - int boot; -- int hidden; -- int msftres; -- int raid; -- int lvm; -- int swap; -- int lba; -- int palo; -- int prep; -- int diag; -- int irst; -- int esp; -- int bls_boot; - OrigState* orig; /* used for CHS stuff */ - } DosPartitionData; - -@@ -891,48 +1082,6 @@ raw_part_is_extended (const DosRawPartition* raw_part) - return 0; - } - --static int _GL_ATTRIBUTE_PURE --raw_part_is_hidden (const DosRawPartition* raw_part) --{ -- PED_ASSERT (raw_part != NULL); -- -- switch (raw_part->type) { -- case PARTITION_FAT12_H: -- case PARTITION_FAT16_SM_H: -- case PARTITION_FAT16_H: -- case PARTITION_FAT32_H: -- case PARTITION_NTFS_H: -- case PARTITION_FAT32_LBA_H: -- case PARTITION_FAT16_LBA_H: -- return 1; -- -- default: -- return 0; -- } -- -- return 0; --} -- --static int _GL_ATTRIBUTE_PURE --raw_part_is_lba (const DosRawPartition* raw_part) --{ -- PED_ASSERT (raw_part != NULL); -- -- switch (raw_part->type) { -- case PARTITION_FAT32_LBA: -- case PARTITION_FAT16_LBA: -- case PARTITION_EXT_LBA: -- case PARTITION_FAT32_LBA_H: -- case PARTITION_FAT16_LBA_H: -- return 1; -- -- default: -- return 0; -- } -- -- return 0; --} -- - static PedPartition* - raw_part_parse (const PedDisk* disk, const DosRawPartition* raw_part, - PedSector lba_offset, PedPartitionType type) -@@ -952,20 +1101,6 @@ raw_part_parse (const PedDisk* disk, const DosRawPartition* raw_part, - dos_data = part->disk_specific; - dos_data->system = raw_part->type; - dos_data->boot = raw_part->boot_ind != 0; -- dos_data->diag = raw_part->type == PARTITION_COMPAQ_DIAG || -- raw_part->type == PARTITION_DELL_DIAG; -- dos_data->msftres = raw_part->type == PARTITION_MSFT_RECOVERY; -- dos_data->hidden = raw_part_is_hidden (raw_part); -- dos_data->raid = raw_part->type == PARTITION_LINUX_RAID; -- dos_data->lvm = raw_part->type == PARTITION_LINUX_LVM_OLD -- || raw_part->type == PARTITION_LINUX_LVM; -- dos_data->swap = raw_part->type == PARTITION_LINUX_SWAP; -- dos_data->lba = raw_part_is_lba (raw_part); -- dos_data->palo = raw_part->type == PARTITION_PALO; -- dos_data->prep = raw_part->type == PARTITION_PREP; -- dos_data->irst = raw_part->type == PARTITION_IRST; -- dos_data->esp = raw_part->type == PARTITION_ESP; -- dos_data->bls_boot = raw_part->type == PARTITION_BLS_BOOT; - dos_data->orig = ped_malloc (sizeof (OrigState)); - if (!dos_data->orig) { - ped_partition_destroy (part); -@@ -1377,18 +1512,6 @@ msdos_partition_duplicate (const PedPartition* part) - new_dos_data = (DosPartitionData*) new_part->disk_specific; - new_dos_data->system = old_dos_data->system; - new_dos_data->boot = old_dos_data->boot; -- new_dos_data->diag = old_dos_data->diag; -- new_dos_data->hidden = old_dos_data->hidden; -- new_dos_data->msftres = old_dos_data->msftres; -- new_dos_data->raid = old_dos_data->raid; -- new_dos_data->lvm = old_dos_data->lvm; -- new_dos_data->swap = old_dos_data->swap; -- new_dos_data->lba = old_dos_data->lba; -- new_dos_data->palo = old_dos_data->palo; -- new_dos_data->prep = old_dos_data->prep; -- new_dos_data->irst = old_dos_data->irst; -- new_dos_data->esp = old_dos_data->esp; -- new_dos_data->bls_boot = old_dos_data->bls_boot; - - if (old_dos_data->orig) { - new_dos_data->orig = ped_malloc (sizeof (OrigState)); -@@ -1425,234 +1548,87 @@ msdos_partition_set_system (PedPartition* part, - - part->fs_type = fs_type; - -- if (dos_data->hidden -- && fs_type -- && strncmp (fs_type->name, "fat", 3) != 0 -- && strcmp (fs_type->name, "ntfs") != 0) -- dos_data->hidden = 0; -- -- if (dos_data->msftres -- && fs_type -- && strcmp (fs_type->name, "ntfs") != 0) -- dos_data->msftres = 0; -- - if (part->type & PED_PARTITION_EXTENDED) { -- dos_data->diag = 0; -- dos_data->raid = 0; -- dos_data->lvm = 0; -- dos_data->swap = 0; -- dos_data->palo = 0; -- dos_data->prep = 0; -- dos_data->irst = 0; -- dos_data->esp = 0; -- if (dos_data->lba) -- dos_data->system = PARTITION_EXT_LBA; -- else -- dos_data->system = PARTITION_DOS_EXT; -- return 1; -- } -- -- if (dos_data->diag) { -- /* Don't change the system if it already is a diag type, -- otherwise use Compaq as almost all vendors use that. */ -- if (dos_data->system != PARTITION_COMPAQ_DIAG && -- dos_data->system != PARTITION_DELL_DIAG) -- dos_data->system = PARTITION_COMPAQ_DIAG; -- return 1; -- } -- if (dos_data->msftres) { -- dos_data->system = PARTITION_MSFT_RECOVERY; -- return 1; -- } -- if (dos_data->lvm) { -- dos_data->system = PARTITION_LINUX_LVM; -- return 1; -- } -- if (dos_data->swap) { -- dos_data->system = PARTITION_LINUX_SWAP; -- return 1; -- } -- if (dos_data->raid) { -- dos_data->system = PARTITION_LINUX_RAID; -- return 1; -- } -- if (dos_data->palo) { -- dos_data->system = PARTITION_PALO; -- return 1; -- } -- if (dos_data->prep) { -- dos_data->system = PARTITION_PREP; -- return 1; -- } -- if (dos_data->irst) { -- dos_data->system = PARTITION_IRST; -- return 1; -- } -- if (dos_data->esp) { -- dos_data->system = PARTITION_ESP; -- return 1; -- } -- if (dos_data->bls_boot) { -- dos_data->system = PARTITION_BLS_BOOT; -+ dos_data->system = PARTITION_EXT_LBA; - return 1; - } - - if (!fs_type) - dos_data->system = PARTITION_LINUX; -- else if (!strcmp (fs_type->name, "fat16")) { -- dos_data->system = dos_data->lba -- ? PARTITION_FAT16_LBA : PARTITION_FAT16; -- dos_data->system |= dos_data->hidden ? PART_FLAG_HIDDEN : 0; -- } else if (!strcmp (fs_type->name, "fat32")) { -- dos_data->system = dos_data->lba -- ? PARTITION_FAT32_LBA : PARTITION_FAT32; -- dos_data->system |= dos_data->hidden ? PART_FLAG_HIDDEN : 0; -- } else if (!strcmp (fs_type->name, "ntfs") -- || !strcmp (fs_type->name, "hpfs")) { -+ else if (!strcmp (fs_type->name, "fat16")) -+ dos_data->system = PARTITION_FAT16; -+ else if (!strcmp (fs_type->name, "fat32")) -+ dos_data->system = PARTITION_FAT32; -+ else if (!strcmp (fs_type->name, "ntfs") -+ || !strcmp (fs_type->name, "hpfs")) - dos_data->system = PARTITION_NTFS; -- dos_data->system |= dos_data->hidden ? PART_FLAG_HIDDEN : 0; -- } else if (!strcmp (fs_type->name, "hfs") -+ else if (!strcmp (fs_type->name, "hfs") - || !strcmp (fs_type->name, "hfs+")) - dos_data->system = PARTITION_HFS; - else if (!strcmp (fs_type->name, "udf")) - dos_data->system = PARTITION_UDF; - else if (!strcmp (fs_type->name, "sun-ufs")) - dos_data->system = PARTITION_SUN_UFS; -- else if (is_linux_swap (fs_type->name)) { -+ else if (is_linux_swap (fs_type->name)) - dos_data->system = PARTITION_LINUX_SWAP; -- dos_data->swap = 1; -- } else -+ else - dos_data->system = PARTITION_LINUX; - - return 1; - } - --static void --clear_flags (DosPartitionData *dos_data) --{ -- dos_data->diag = 0; -- dos_data->hidden = 0; -- dos_data->msftres = 0; -- dos_data->lvm = 0; -- dos_data->swap = 0; -- dos_data->palo = 0; -- dos_data->prep = 0; -- dos_data->irst = 0; -- dos_data->esp = 0; -- dos_data->raid = 0; -- dos_data->bls_boot = 0; --} -- - static int - msdos_partition_set_flag (PedPartition* part, - PedPartitionFlag flag, int state) - { -- PedDisk* disk; -- PedPartition* walk; -- DosPartitionData* dos_data; -- - PED_ASSERT (part != NULL); - PED_ASSERT (part->disk_specific != NULL); - PED_ASSERT (part->disk != NULL); - -- dos_data = part->disk_specific; -- disk = part->disk; -- -- switch (flag) { -- case PED_PARTITION_HIDDEN: -- if (part->type == PED_PARTITION_EXTENDED) { -- ped_exception_throw ( -- PED_EXCEPTION_ERROR, -- PED_EXCEPTION_CANCEL, -- _("Extended partitions cannot be hidden on " -- "msdos disk labels.")); -- return 0; -- } -- dos_data->hidden = state; -- return ped_partition_set_system (part, part->fs_type); -- -- case PED_PARTITION_MSFT_RESERVED: -- if (part->type == PED_PARTITION_EXTENDED) { -- ped_exception_throw ( -- PED_EXCEPTION_ERROR, -- PED_EXCEPTION_CANCEL, -- _("Extended partitions cannot be recovery partitions on " -- "msdos disk labels.")); -- return 0; -- } -- dos_data->msftres = state; -- return ped_partition_set_system (part, part->fs_type); -- -- case PED_PARTITION_BOOT: -- dos_data->boot = state; -- if (!state) -- return 1; -- -- walk = ped_disk_next_partition (disk, NULL); -- for (; walk; walk = ped_disk_next_partition (disk, walk)) { -- if (walk == part || !ped_partition_is_active (walk)) -- continue; -- msdos_partition_set_flag (walk, PED_PARTITION_BOOT, 0); -- } -- return 1; -+ DosPartitionData* dos_data = part->disk_specific; - -- case PED_PARTITION_DIAG: -- if (state) -- clear_flags (dos_data); -- dos_data->diag = state; -- return ped_partition_set_system (part, part->fs_type); -+ const struct flag_id_mapping_t* p = dos_find_flag_id_mapping (flag); -+ if (p) -+ { -+ if (part->type & PED_PARTITION_EXTENDED) -+ return 0; - -- case PED_PARTITION_RAID: -- if (state) -- clear_flags (dos_data); -- dos_data->raid = state; -+ 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); - -- case PED_PARTITION_LVM: -- if (state) -- clear_flags (dos_data); -- dos_data->lvm = state; -- return ped_partition_set_system (part, part->fs_type); -+ return 1; -+ } - -- case PED_PARTITION_SWAP: -- if (state) -- clear_flags (dos_data); -- dos_data->swap = state; -- return ped_partition_set_system (part, part->fs_type); -+ switch (flag) { -+ case PED_PARTITION_HIDDEN: -+ { -+ return dos_type_id_set_hidden(&dos_data->system, state); -+ } - - case PED_PARTITION_LBA: -- dos_data->lba = state; -- return ped_partition_set_system (part, part->fs_type); -- -- case PED_PARTITION_PALO: -- if (state) -- clear_flags (dos_data); -- dos_data->palo = state; -- return ped_partition_set_system (part, part->fs_type); -- -- case PED_PARTITION_PREP: -- if (state) -- clear_flags (dos_data); -- dos_data->prep = state; -- return ped_partition_set_system (part, part->fs_type); -+ { -+ return dos_type_id_set_lba(&dos_data->system, state); -+ } - -- case PED_PARTITION_IRST: -- if (state) -- clear_flags (dos_data); -- dos_data->irst = state; -- return ped_partition_set_system (part, part->fs_type); -+ case PED_PARTITION_BOOT: -+ { -+ dos_data->boot = state; - -- case PED_PARTITION_ESP: - if (state) -- clear_flags (dos_data); -- dos_data->esp = state; -- return ped_partition_set_system (part, part->fs_type); -+ { -+ PedDisk* disk = part->disk; -+ PedPartition* walk = ped_disk_next_partition (disk, NULL); -+ for (; walk; walk = ped_disk_next_partition (disk, walk)) { -+ if (walk == part || !ped_partition_is_active (walk)) -+ continue; -+ msdos_partition_set_flag (walk, PED_PARTITION_BOOT, 0); -+ } -+ } - -- case PED_PARTITION_BLS_BOOT: -- if (state) -- clear_flags (dos_data); -- dos_data->bls_boot = state; -- return ped_partition_set_system (part, part->fs_type); -+ return 1; -+ } - - default: - return 0; -@@ -1662,58 +1638,25 @@ msdos_partition_set_flag (PedPartition* part, - static int _GL_ATTRIBUTE_PURE - msdos_partition_get_flag (const PedPartition* part, PedPartitionFlag flag) - { -- DosPartitionData* dos_data; -- - PED_ASSERT (part != NULL); - PED_ASSERT (part->disk_specific != NULL); - -- dos_data = part->disk_specific; -+ DosPartitionData* dos_data = part->disk_specific; -+ -+ const struct flag_id_mapping_t* p = dos_find_flag_id_mapping (flag); -+ if (p) -+ return dos_data->system == p->type_id || dos_data->system == p->alt_type_id; -+ - switch (flag) { - case PED_PARTITION_HIDDEN: -- if (part->type == PED_PARTITION_EXTENDED) -- return 0; -- else -- return dos_data->hidden; -+ return dos_type_id_is_hidden(dos_data->system); - -- case PED_PARTITION_MSFT_RESERVED: -- if (part->type == PED_PARTITION_EXTENDED) -- return 0; -- else -- return dos_data->msftres; -+ case PED_PARTITION_LBA: -+ return dos_type_id_is_lba(dos_data->system); - - case PED_PARTITION_BOOT: - return dos_data->boot; - -- case PED_PARTITION_DIAG: -- return dos_data->diag; -- -- case PED_PARTITION_RAID: -- return dos_data->raid; -- -- case PED_PARTITION_LVM: -- return dos_data->lvm; -- -- case PED_PARTITION_SWAP: -- return dos_data->swap; -- -- case PED_PARTITION_LBA: -- return dos_data->lba; -- -- case PED_PARTITION_PALO: -- return dos_data->palo; -- -- case PED_PARTITION_PREP: -- return dos_data->prep; -- -- case PED_PARTITION_IRST: -- return dos_data->irst; -- -- case PED_PARTITION_ESP: -- return dos_data->esp; -- -- case PED_PARTITION_BLS_BOOT: -- return dos_data->bls_boot; -- - default: - return 0; - } -@@ -1723,30 +1666,19 @@ static int - msdos_partition_is_flag_available (const PedPartition* part, - PedPartitionFlag flag) - { -+ if (dos_find_flag_id_mapping (flag)) -+ return part->type != PED_PARTITION_EXTENDED; -+ -+ DosPartitionData* dos_data = part->disk_specific; -+ - switch (flag) { - case PED_PARTITION_HIDDEN: -- if (part->type == PED_PARTITION_EXTENDED) -- return 0; -- else -- return 1; -+ return dos_type_id_supports_hidden(dos_data->system); - -- case PED_PARTITION_MSFT_RESERVED: -- if (part->type == PED_PARTITION_EXTENDED) -- return 0; -- else -- return 1; -+ case PED_PARTITION_LBA: -+ return dos_type_id_supports_lba(dos_data->system); - - case PED_PARTITION_BOOT: -- case PED_PARTITION_RAID: -- case PED_PARTITION_LVM: -- case PED_PARTITION_SWAP: -- case PED_PARTITION_LBA: -- case PED_PARTITION_PALO: -- case PED_PARTITION_PREP: -- case PED_PARTITION_IRST: -- case PED_PARTITION_ESP: -- case PED_PARTITION_BLS_BOOT: -- case PED_PARTITION_DIAG: - return 1; - - default: -@@ -1754,6 +1686,27 @@ msdos_partition_is_flag_available (const PedPartition* part, - } - } - -+ -+int -+msdos_partition_set_type_id (PedPartition* part, uint8_t id) -+{ -+ DosPartitionData* dos_data = part->disk_specific; -+ -+ dos_data->system = id; -+ -+ return 1; -+} -+ -+ -+uint8_t _GL_ATTRIBUTE_PURE -+msdos_partition_get_type_id (const PedPartition* part) -+{ -+ const DosPartitionData* dos_data = part->disk_specific; -+ -+ return dos_data->system; -+} -+ -+ - static PedGeometry* - _try_constraint (const PedPartition* part, const PedConstraint* external, - PedConstraint* internal) -@@ -2590,6 +2543,10 @@ static PedDiskOps msdos_disk_ops = { - - partition_set_name: NULL, - partition_get_name: NULL, -+ partition_set_type_id: msdos_partition_set_type_id, -+ partition_get_type_id: msdos_partition_get_type_id, -+ partition_set_type_uuid: NULL, -+ partition_get_type_uuid: NULL, - - PT_op_function_initializers (msdos) - }; -@@ -2598,7 +2555,7 @@ static PedDiskType msdos_disk_type = { - next: NULL, - name: "msdos", - ops: &msdos_disk_ops, -- features: PED_DISK_TYPE_EXTENDED -+ features: PED_DISK_TYPE_EXTENDED | PED_DISK_TYPE_PARTITION_TYPE_ID - }; - - void -diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c -index 037d021..0e9e060 100644 ---- a/libparted/labels/gpt.c -+++ b/libparted/labels/gpt.c -@@ -1686,6 +1686,44 @@ gpt_partition_get_name (const PedPartition *part) - return gpt_part_data->translated_name; - } - -+ -+static int -+gpt_partition_set_type_uuid (PedPartition *part, const uint8_t *uuid) -+{ -+ GPTPartitionData *gpt_part_data = part->disk_specific; -+ -+ efi_guid_t* type_uuid = &gpt_part_data->type; -+ memcpy(type_uuid, uuid, sizeof (efi_guid_t)); -+ -+ /* type_uuid is always LE, while uint8_t is always kind of BE */ -+ -+ type_uuid->time_low = PED_SWAP32(type_uuid->time_low); -+ type_uuid->time_mid = PED_SWAP16(type_uuid->time_mid); -+ type_uuid->time_hi_and_version = PED_SWAP16(type_uuid->time_hi_and_version); -+ -+ return 1; -+} -+ -+ -+static uint8_t* -+gpt_partition_get_type_uuid (const PedPartition *part) -+{ -+ const GPTPartitionData *gpt_part_data = part->disk_specific; -+ -+ efi_guid_t type_uuid = gpt_part_data->type; -+ -+ /* type_uuid is always LE, while uint8_t is always kind of BE */ -+ -+ type_uuid.time_low = PED_SWAP32(type_uuid.time_low); -+ type_uuid.time_mid = PED_SWAP16(type_uuid.time_mid); -+ type_uuid.time_hi_and_version = PED_SWAP16(type_uuid.time_hi_and_version); -+ -+ uint8_t *buf = ped_malloc(sizeof (uuid_t)); -+ memcpy(buf, &type_uuid, sizeof (uuid_t)); -+ return buf; -+} -+ -+ - static int - gpt_get_max_primary_partition_count (const PedDisk *disk) - { -@@ -1781,6 +1819,10 @@ static PedDiskOps gpt_disk_ops = - - partition_set_name: gpt_partition_set_name, - partition_get_name: gpt_partition_get_name, -+ partition_set_type_id: NULL, -+ partition_get_type_id: NULL, -+ partition_set_type_uuid: gpt_partition_set_type_uuid, -+ partition_get_type_uuid: gpt_partition_get_type_uuid, - disk_set_flag: gpt_disk_set_flag, - disk_get_flag: gpt_disk_get_flag, - disk_is_flag_available: gpt_disk_is_flag_available, -@@ -1793,7 +1835,7 @@ static PedDiskType gpt_disk_type = - next: NULL, - name: "gpt", - ops: &gpt_disk_ops, -- features: PED_DISK_TYPE_PARTITION_NAME -+ features: PED_DISK_TYPE_PARTITION_NAME | PED_DISK_TYPE_PARTITION_TYPE_UUID - }; - - void -diff --git a/parted/parted.c b/parted/parted.c -index 5c7c270..b8a4acf 100644 ---- a/parted/parted.c -+++ b/parted/parted.c -@@ -19,6 +19,7 @@ - - #include - #include -+#include - - #include "argmatch.h" - #include "closeout.h" -@@ -174,6 +175,8 @@ static const char* end_msg = N_("END is disk location, such as " - static const char* state_msg = N_("STATE is one of: on, off\n"); - static const char* device_msg = N_("DEVICE is usually /dev/hda or /dev/sda\n"); - static const char* name_msg = N_("NAME is any word you want\n"); -+static const char* type_msg = N_("TYPE_ID is a value between 0x01 and 0xff, " -+ "TYPE_UUID is a UUID\n"); - - static const char* copyright_msg = N_( - "Copyright (C) 1998 - 2006 Free Software Foundation, Inc.\n" -@@ -917,6 +920,87 @@ error: - return 0; - } - -+static int -+do_type (PedDevice** dev, PedDisk** diskp) -+{ -+ if (!*diskp) -+ *diskp = ped_disk_new (*dev); -+ if (!*diskp) -+ goto error; -+ -+ bool has_type_id = ped_disk_type_check_feature ((*diskp)->type, -+ PED_DISK_TYPE_PARTITION_TYPE_ID); -+ bool has_type_uuid = ped_disk_type_check_feature ((*diskp)->type, -+ PED_DISK_TYPE_PARTITION_TYPE_UUID); -+ -+ PED_ASSERT (!(has_type_id && has_type_uuid)); -+ -+ if (!has_type_id && !has_type_uuid) { -+ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, -+ _("%s disk labels do not support partition type."), -+ (*diskp)->type->name); -+ goto error; -+ } -+ -+ PedPartition* part = NULL; -+ if (!command_line_get_partition (_("Partition number?"), *diskp, &part)) -+ goto error; -+ -+ char* input = NULL; -+ -+ if (has_type_id) { -+ uint8_t type_id = ped_partition_get_type_id (part); -+ static char buf[8]; -+ snprintf(buf, 8, "0x%02x", type_id); -+ -+ input = command_line_get_word (_("Partition type-id?"), buf, NULL, 0); -+ if (!input) -+ goto error; -+ -+ unsigned int tmp = strtol (input, (char**) NULL, 16); -+ if (tmp < 0x01 || tmp > 0xff) { -+ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, -+ _("Invalid type-id.")); -+ goto error_free_input; -+ } -+ -+ if (!ped_partition_set_type_id (part, tmp)) -+ goto error_free_input; -+ } -+ -+ if (has_type_uuid) { -+ uint8_t* type_uuid = ped_partition_get_type_uuid (part); -+ static char buf[UUID_STR_LEN]; -+ uuid_unparse_lower (type_uuid, buf); -+ free (type_uuid); -+ -+ input = command_line_get_word (_("Partition type-uuid?"), buf, NULL, 0); -+ if (!input) -+ goto error; -+ -+ uuid_t tmp; -+ if (uuid_parse (input, tmp) != 0 || uuid_is_null (tmp)) { -+ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL, -+ _("Invalid type-uuid.")); -+ goto error_free_input; -+ } -+ -+ if (!ped_partition_set_type_uuid (part, tmp)) -+ goto error_free_input; -+ } -+ -+ free (input); -+ -+ if (!ped_disk_commit (*diskp)) -+ goto error; -+ return 1; -+ -+error_free_input: -+ free (input); -+error: -+ return 0; -+} -+ - static char* - partition_print_flags (PedPartition const *part) - { -@@ -1270,6 +1354,10 @@ do_print (PedDevice** dev, PedDisk** diskp) - PED_DISK_TYPE_EXTENDED); - has_name = ped_disk_type_check_feature ((*diskp)->type, - PED_DISK_TYPE_PARTITION_NAME); -+ bool has_type_id = ped_disk_type_check_feature ((*diskp)->type, -+ PED_DISK_TYPE_PARTITION_TYPE_ID); -+ bool has_type_uuid = ped_disk_type_check_feature ((*diskp)->type, -+ PED_DISK_TYPE_PARTITION_TYPE_UUID); - - PedPartition* part; - if (opt_output_mode == HUMAN) { -@@ -1407,10 +1495,25 @@ do_print (PedDevice** dev, PedDisk** diskp) - - if (!(part->type & PED_PARTITION_FREESPACE)) { - -+ if (has_type_id) { -+ uint8_t type_id = ped_partition_get_type_id (part); -+ static char buf[8]; -+ snprintf(buf, 8, "0x%02x", type_id); -+ ul_jsonwrt_value_s (&json, "type-id", buf); -+ } -+ -+ if (has_type_uuid) { -+ uint8_t* type_uuid = ped_partition_get_type_uuid (part); -+ static char buf[UUID_STR_LEN]; -+ uuid_unparse_lower (type_uuid, buf); -+ ul_jsonwrt_value_s (&json, "type-uuid", buf); -+ free (type_uuid); -+ } -+ - if (has_name) { - name = ped_partition_get_name (part); - if (strcmp (name, "") != 0) -- ul_jsonwrt_value_s (&json, "name", ped_partition_get_name (part)); -+ ul_jsonwrt_value_s (&json, "name", name); - } - - if (part->fs_type) -@@ -2316,6 +2419,14 @@ _("toggle [NUMBER [FLAG]] toggle the state of FLAG on " - NULL), - str_list_create (_(number_msg), flag_msg, NULL), 1)); - -+command_register (commands, command_create ( -+ str_list_create_unique ("type", _("type"), NULL), -+ do_type, -+ str_list_create ( -+_("type NUMBER TYPE-ID or TYPE-UUID type set TYPE-ID or TYPE-UUID of partition NUMBER"), -+NULL), -+ str_list_create (_(number_msg), _(type_msg), NULL), 1)); -+ - command_register (commands, command_create ( - str_list_create_unique ("unit", _("unit"), NULL), - do_unit, -diff --git a/tests/Makefile.am b/tests/Makefile.am -index 5cb7aa3..2da653b 100644 ---- a/tests/Makefile.am -+++ b/tests/Makefile.am -@@ -43,6 +43,10 @@ TESTS = \ - t0501-duplicate.sh \ - t0800-json-gpt.sh \ - t0801-json-msdos.sh \ -+ t0900-type-gpt.sh \ -+ t0901-type-gpt-invalid.sh \ -+ t0910-type-dos.sh \ -+ t0911-type-dos-invalid.sh \ - t1100-busy-label.sh \ - t1101-busy-partition.sh \ - t1102-loop-label.sh \ -diff --git a/tests/t0800-json-gpt.sh b/tests/t0800-json-gpt.sh -index 8dd1862..354c0bd 100755 ---- a/tests/t0800-json-gpt.sh -+++ b/tests/t0800-json-gpt.sh -@@ -62,6 +62,7 @@ cat < exp || fail=1 - "end": "20479s", - "size": "10240s", - "type": "primary", -+ "type-uuid": "0fc63daf-8483-4772-8e79-3d69d8477de4", - "name": "test1" - },{ - "number": 2, -@@ -69,6 +70,7 @@ cat < exp || fail=1 - "end": "61439s", - "size": "40960s", - "type": "primary", -+ "type-uuid": "a19d880f-05fc-4d3b-a006-743f0f84911e", - "name": "test2", - "flags": [ - "raid" -diff --git a/tests/t0801-json-msdos.sh b/tests/t0801-json-msdos.sh -index a14a5af..c5446d8 100755 ---- a/tests/t0801-json-msdos.sh -+++ b/tests/t0801-json-msdos.sh -@@ -52,13 +52,15 @@ cat < exp || fail=1 - "start": "5.00MiB", - "end": "10.0MiB", - "size": "5.00MiB", -- "type": "primary" -+ "type": "primary", -+ "type-id": "0x83" - },{ - "number": 2, - "start": "10.0MiB", - "end": "30.0MiB", - "size": "20.0MiB", - "type": "extended", -+ "type-id": "0x0f", - "flags": [ - "lba" - ] -@@ -68,6 +70,7 @@ cat < exp || fail=1 - "end": "20.0MiB", - "size": "10.0MiB", - "type": "logical", -+ "type-id": "0x8e", - "flags": [ - "lvm" - ] -diff --git a/tests/t0900-type-gpt.sh b/tests/t0900-type-gpt.sh -new file mode 100755 -index 0000000..2014820 ---- /dev/null -+++ b/tests/t0900-type-gpt.sh -@@ -0,0 +1,69 @@ -+#!/bin/sh -+ -+# Test type command with GPT label -+ -+# Copyright (C) 2022 SUSE LLC -+ -+# 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 . -+ -+. "${srcdir=.}/init.sh"; path_prepend_ ../parted -+require_512_byte_sector_size_ -+ -+dev=loop-file -+ -+# create device -+truncate --size 50MiB "$dev" || fail=1 -+ -+# create gpt label and one partition -+parted --script "$dev" mklabel gpt > out 2>&1 || fail=1 -+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 -+ -+cat < exp || fail=1 -+{ -+ "disk": { -+ "path": "loop-file", -+ "size": "102400s", -+ "model": "", -+ "transport": "file", -+ "logical-sector-size": 512, -+ "physical-sector-size": 512, -+ "label": "gpt", -+ "max-partitions": 128, -+ "partitions": [ -+ { -+ "number": 1, -+ "start": "10240s", -+ "end": "20479s", -+ "size": "10240s", -+ "type": "primary", -+ "type-uuid": "deadfd6d-a4ab-43c4-84e5-0933c84b4f4f" -+ } -+ ] -+ } -+} -+EOF -+ -+# remove full path of device from actual output -+mv out o2 && sed "s,\"/.*/$dev\",\"$dev\"," o2 > out || fail=1 -+ -+# check for expected output -+compare exp out || fail=1 -+ -+Exit $fail -diff --git a/tests/t0901-type-gpt-invalid.sh b/tests/t0901-type-gpt-invalid.sh -new file mode 100755 -index 0000000..681df3a ---- /dev/null -+++ b/tests/t0901-type-gpt-invalid.sh -@@ -0,0 +1,35 @@ -+#!/bin/sh -+ -+# Test type command with GPT label -+ -+# Copyright (C) 2022 SUSE LLC -+ -+# 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 . -+ -+. "${srcdir=.}/init.sh"; path_prepend_ ../parted -+require_512_byte_sector_size_ -+ -+dev=loop-file -+ -+# create device -+truncate --size 50MiB "$dev" || fail=1 -+ -+# create gpt label and one partition -+parted --script "$dev" mklabel gpt > out 2>&1 || fail=1 -+parted --script "$dev" mkpart "''" "linux-swap" 10% 20% > out 2>&1 || fail=1 -+ -+# set type-uuid -+parted --script "$dev" type 1 "invalidd-a4ab-43c4-84e5-0933c84b4f4f" && fail=1 -+ -+Exit $fail -diff --git a/tests/t0910-type-dos.sh b/tests/t0910-type-dos.sh -new file mode 100755 -index 0000000..d7cc37f ---- /dev/null -+++ b/tests/t0910-type-dos.sh -@@ -0,0 +1,69 @@ -+#!/bin/sh -+ -+# Test type command with MS-DOS label -+ -+# Copyright (C) 2022 SUSE LLC -+ -+# 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 . -+ -+. "${srcdir=.}/init.sh"; path_prepend_ ../parted -+require_512_byte_sector_size_ -+ -+dev=loop-file -+ -+# create device -+truncate --size 50MiB "$dev" || fail=1 -+ -+# create msdos label and one partition -+parted --script "$dev" mklabel msdos > out 2>&1 || fail=1 -+parted --script "$dev" mkpart primary "linux-swap" 10% 20% > out 2>&1 || fail=1 -+ -+# set type-id -+parted --script "$dev" type 1 "0x83" || fail=1 -+ -+# print with json format -+parted --script --json "$dev" unit s print > out 2>&1 || fail=1 -+ -+cat < exp || fail=1 -+{ -+ "disk": { -+ "path": "loop-file", -+ "size": "102400s", -+ "model": "", -+ "transport": "file", -+ "logical-sector-size": 512, -+ "physical-sector-size": 512, -+ "label": "msdos", -+ "max-partitions": 4, -+ "partitions": [ -+ { -+ "number": 1, -+ "start": "10240s", -+ "end": "20479s", -+ "size": "10240s", -+ "type": "primary", -+ "type-id": "0x83" -+ } -+ ] -+ } -+} -+EOF -+ -+# remove full path of device from actual output -+mv out o2 && sed "s,\"/.*/$dev\",\"$dev\"," o2 > out || fail=1 -+ -+# check for expected output -+compare exp out || fail=1 -+ -+Exit $fail -diff --git a/tests/t0911-type-dos-invalid.sh b/tests/t0911-type-dos-invalid.sh -new file mode 100755 -index 0000000..f1036d1 ---- /dev/null -+++ b/tests/t0911-type-dos-invalid.sh -@@ -0,0 +1,35 @@ -+#!/bin/sh -+ -+# Test type command with MS-DOS label -+ -+# Copyright (C) 2022 SUSE LLC -+ -+# 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 . -+ -+. "${srcdir=.}/init.sh"; path_prepend_ ../parted -+require_512_byte_sector_size_ -+ -+dev=loop-file -+ -+# create device -+truncate --size 50MiB "$dev" || fail=1 -+ -+# create msdos label and one partition -+parted --script "$dev" mklabel msdos > out 2>&1 || fail=1 -+parted --script "$dev" mkpart primary "linux-swap" 10% 20% > out 2>&1 || fail=1 -+ -+# set type-id -+parted --script "$dev" type 1 "0x101" && fail=1 -+ -+Exit $fail -diff --git a/tests/t2400-dos-hfs-partition-type.sh b/tests/t2400-dos-hfs-partition-type.sh -index 6733683..8c54ec4 100644 ---- a/tests/t2400-dos-hfs-partition-type.sh -+++ b/tests/t2400-dos-hfs-partition-type.sh -@@ -24,7 +24,7 @@ n_sectors=8000 - - dd if=/dev/null of=$dev bs=$ss seek=$n_sectors || framework_failure - --# create a GPT partition table -+# create a MS-DOS partition table - parted -s $dev mklabel msdos \ - mkpart pri hfs 2048s 4095s \ - mkpart pri hfs+ 4096s 6143s > out 2>&1 || fail=1 -diff --git a/tests/t3300-palo-prep.sh b/tests/t3300-palo-prep.sh -index 5005e0e..efe54db 100755 ---- a/tests/t3300-palo-prep.sh -+++ b/tests/t3300-palo-prep.sh -@@ -20,9 +20,9 @@ - ss=$sector_size_ - - cat > exp < out 2> err || fail=1 - --grep -E '^1:2048s:4095s:2048s:ext2::lba, p...;$' out > k; mv k out -+grep -E '^1:2048s:4095s:2048s:ext2::p...;$' out > k; mv k out - - compare exp out || fail=1 - -diff --git a/tests/t3310-flags.sh b/tests/t3310-flags.sh -index f2001c5..b35d443 100644 ---- a/tests/t3310-flags.sh -+++ b/tests/t3310-flags.sh -@@ -91,6 +91,10 @@ for table_type in aix amiga atari bsd dvh gpt mac msdos pc98 sun loop; do - # test to fail. - flags=`echo "$flags" | egrep -v 'lvm|raid'` - ;; -+ msdos) # FIXME: Exclude flags that can only be set in combination -+ # with certain other flags. -+ flags=`echo "$flags" | egrep -v 'hidden|lba'` -+ ;; - esac - - for mode in on_only on_and_off ; do --- -2.37.3 - diff --git a/0003-libparted-add-swap-flag-for-DASD-label.patch b/0003-libparted-add-swap-flag-for-DASD-label.patch deleted file mode 100644 index 424ddc7..0000000 --- a/0003-libparted-add-swap-flag-for-DASD-label.patch +++ /dev/null @@ -1,228 +0,0 @@ -From 29ffc6a1f285f48ac0b9efa7299373e486c486e8 Mon Sep 17 00:00:00 2001 -From: Arvin Schnell -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 ---- - 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 - diff --git a/0004-parted-Reset-the-filesystem-type-when-changing-the-i.patch b/0004-parted-Reset-the-filesystem-type-when-changing-the-i.patch deleted file mode 100644 index 2060b77..0000000 --- a/0004-parted-Reset-the-filesystem-type-when-changing-the-i.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 9b0a83a747b28bd1b778bdd32616e6f7ea88c84d Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0005-tests-t3200-type-change-now-passes.patch b/0005-tests-t3200-type-change-now-passes.patch deleted file mode 100644 index a61d327..0000000 --- a/0005-tests-t3200-type-change-now-passes.patch +++ /dev/null @@ -1,23 +0,0 @@ -From ac2a35c2214ef42352d0ddb4f7f4cb77d116e92e Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0006-libparted-Fix-check-for-availability-of-_type_id-fun.patch b/0006-libparted-Fix-check-for-availability-of-_type_id-fun.patch deleted file mode 100644 index afa6bc2..0000000 --- a/0006-libparted-Fix-check-for-availability-of-_type_id-fun.patch +++ /dev/null @@ -1,40 +0,0 @@ -From bafa84b25a265ef9eed3872790d52bf56ac42998 Mon Sep 17 00:00:00 2001 -From: Arvin Schnell -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 ---- - 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 - diff --git a/0007-parted-Simplify-code-for-json-output.patch b/0007-parted-Simplify-code-for-json-output.patch deleted file mode 100644 index 50a600d..0000000 --- a/0007-parted-Simplify-code-for-json-output.patch +++ /dev/null @@ -1,34 +0,0 @@ -From b16be5ffc8e700df2b6b2545c4b6794cea71b8e7 Mon Sep 17 00:00:00 2001 -From: Arvin Schnell -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 ---- - 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 - diff --git a/0008-disk.in.h-Remove-use-of-enums-with-define.patch b/0008-disk.in.h-Remove-use-of-enums-with-define.patch deleted file mode 100644 index bb56d68..0000000 --- a/0008-disk.in.h-Remove-use-of-enums-with-define.patch +++ /dev/null @@ -1,59 +0,0 @@ -From aa690ee275db86d1edb2468bcf31c3d7cf81228e Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0009-libparted-Fix-handling-of-gpt-partition-types.patch b/0009-libparted-Fix-handling-of-gpt-partition-types.patch deleted file mode 100644 index bfe30cb..0000000 --- a/0009-libparted-Fix-handling-of-gpt-partition-types.patch +++ /dev/null @@ -1,101 +0,0 @@ -From 8957382b98fd79bc06dad132ef28a0be8b46ea16 Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch b/0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch deleted file mode 100644 index b905115..0000000 --- a/0010-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch +++ /dev/null @@ -1,160 +0,0 @@ -From d50b7bf2b66b7b67ee332c1af63bc1f5fdfba7ad Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 -+#include -+ -+#include -+ -+#include -+ -+#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 . -+ -+. "${top_srcdir=../..}/tests/init.sh"; path_prepend_ . -+ -+flags || fail=1 -+ -+Exit $fail --- -2.37.3 - diff --git a/0011-libparted-Fix-handling-of-msdos-partition-types.patch b/0011-libparted-Fix-handling-of-msdos-partition-types.patch deleted file mode 100644 index bcbb062..0000000 --- a/0011-libparted-Fix-handling-of-msdos-partition-types.patch +++ /dev/null @@ -1,109 +0,0 @@ -From 4a0e468ed63fff85a1f9b923189f20945b32f4f1 Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0012-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch b/0012-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch deleted file mode 100644 index 0628463..0000000 --- a/0012-tests-Add-a-libparted-test-for-ped_partition_set_sys.patch +++ /dev/null @@ -1,75 +0,0 @@ -From 8f37b28825933af9bbbac7f00cc7e23f916c7018 Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0013-show-GPT-UUIDs-in-JSON-output.patch b/0013-show-GPT-UUIDs-in-JSON-output.patch deleted file mode 100644 index 31518b5..0000000 --- a/0013-show-GPT-UUIDs-in-JSON-output.patch +++ /dev/null @@ -1,351 +0,0 @@ -From 2194035fc0fe678472d279676a13511769f7ef20 Mon Sep 17 00:00:00 2001 -From: Arvin Schnell -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": ""/' > out 2>&1 || fail=1 - - cat < exp || fail=1 - { -@@ -45,6 +45,7 @@ cat < exp || fail=1 - "logical-sector-size": 512, - "physical-sector-size": 512, - "label": "gpt", -+ "uuid": "", - "max-partitions": 128, - "flags": [ - "pmbr_boot" -@@ -63,6 +64,7 @@ cat < exp || fail=1 - "size": "10240s", - "type": "primary", - "type-uuid": "0fc63daf-8483-4772-8e79-3d69d8477de4", -+ "uuid": "", - "name": "test1" - },{ - "number": 2, -@@ -71,6 +73,7 @@ cat < exp || fail=1 - "size": "40960s", - "type": "primary", - "type-uuid": "a19d880f-05fc-4d3b-a006-743f0f84911e", -+ "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": ""/' > out 2>&1 || fail=1 - - cat < exp || fail=1 - { -@@ -45,6 +45,7 @@ cat < exp || fail=1 - "logical-sector-size": 512, - "physical-sector-size": 512, - "label": "gpt", -+ "uuid": "", - "max-partitions": 128, - "partitions": [ - { -@@ -53,7 +54,8 @@ cat < exp || fail=1 - "end": "20479s", - "size": "10240s", - "type": "primary", -- "type-uuid": "deadfd6d-a4ab-43c4-84e5-0933c84b4f4f" -+ "type-uuid": "deadfd6d-a4ab-43c4-84e5-0933c84b4f4f", -+ "uuid": "" - } - ] - } --- -2.37.3 - diff --git a/0014-gpt-Add-no_automount-partition-flag.patch b/0014-gpt-Add-no_automount-partition-flag.patch deleted file mode 100644 index 66d16eb..0000000 --- a/0014-gpt-Add-no_automount-partition-flag.patch +++ /dev/null @@ -1,145 +0,0 @@ -From 55e4775c989af42d629401b9aa22c60ba2993e7d Mon Sep 17 00:00:00 2001 -From: Mike Fleetwood -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 -Signed-off-by: Brian C. Lane ---- - 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 - diff --git a/0015-tests-XFS-requires-a-minimum-size-of-300M.patch b/0015-tests-XFS-requires-a-minimum-size-of-300M.patch deleted file mode 100644 index 48e0e87..0000000 --- a/0015-tests-XFS-requires-a-minimum-size-of-300M.patch +++ /dev/null @@ -1,54 +0,0 @@ -From caa588269709659d5cf51bf64c559e193f371de4 Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0016-libparted-Fix-problem-with-creating-1s-partitions.patch b/0016-libparted-Fix-problem-with-creating-1s-partitions.patch deleted file mode 100644 index 1cab2e6..0000000 --- a/0016-libparted-Fix-problem-with-creating-1s-partitions.patch +++ /dev/null @@ -1,133 +0,0 @@ -From 9b009985da2e5eee5b5c179acfafab3aa1624f8b Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 . -+ -+. "${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 . -+ -+. "${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 - diff --git a/0017-tests-Fixing-libparted-test-framework-usage.patch b/0017-tests-Fixing-libparted-test-framework-usage.patch deleted file mode 100644 index 86f0705..0000000 --- a/0017-tests-Fixing-libparted-test-framework-usage.patch +++ /dev/null @@ -1,262 +0,0 @@ -From 7b555132be63172a2d621afcdedfa7797185d3b5 Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0018-filesys-Check-for-null-from-close_fn.patch b/0018-filesys-Check-for-null-from-close_fn.patch deleted file mode 100644 index 1793509..0000000 --- a/0018-filesys-Check-for-null-from-close_fn.patch +++ /dev/null @@ -1,28 +0,0 @@ -From c409dbf423d870ab26684cd6a6953c76c4a08d7f Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0019-libparted-Fix-potential-NULL-dereference-in-ped_disk.patch b/0019-libparted-Fix-potential-NULL-dereference-in-ped_disk.patch deleted file mode 100644 index 7fb9647..0000000 --- a/0019-libparted-Fix-potential-NULL-dereference-in-ped_disk.patch +++ /dev/null @@ -1,30 +0,0 @@ -From 31db44c74a96f8e2b495205d18525449e9b29543 Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0020-strlist-Handle-realloc-error-in-wchar_to_str.patch b/0020-strlist-Handle-realloc-error-in-wchar_to_str.patch deleted file mode 100644 index b2f9ca4..0000000 --- a/0020-strlist-Handle-realloc-error-in-wchar_to_str.patch +++ /dev/null @@ -1,28 +0,0 @@ -From 9cb38a7444d02023d112ae8e9e38436104f75f64 Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0021-ui-Add-checks-for-prompt-being-NULL.patch b/0021-ui-Add-checks-for-prompt-being-NULL.patch deleted file mode 100644 index 4f342a2..0000000 --- a/0021-ui-Add-checks-for-prompt-being-NULL.patch +++ /dev/null @@ -1,50 +0,0 @@ -From 09c95d2feab0c087339886134dfe2dc04094348a Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0022-tests-Fix-formatting-and-snprintf-warnings-in-tests.patch b/0022-tests-Fix-formatting-and-snprintf-warnings-in-tests.patch deleted file mode 100644 index 12b403c..0000000 --- a/0022-tests-Fix-formatting-and-snprintf-warnings-in-tests.patch +++ /dev/null @@ -1,46 +0,0 @@ -From d272bb5b5343fd288a204314654a7fbaea84528d Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/0023-parted-Fix-ending-sector-location-when-using-kibi-IE.patch b/0023-parted-Fix-ending-sector-location-when-using-kibi-IE.patch deleted file mode 100644 index dca568c..0000000 --- a/0023-parted-Fix-ending-sector-location-when-using-kibi-IE.patch +++ /dev/null @@ -1,146 +0,0 @@ -From 3f6b723a7d610d98afb0c9d0cfefe4700712e4db Mon Sep 17 00:00:00 2001 -From: "Brian C. Lane" -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 - diff --git a/parted.spec b/parted.spec index f474be6..221a8a9 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted -Version: 3.5 -Release: 11%{?dist} +Version: 3.5.28 +Release: 1%{?dist} License: GPL-3.0-or-later 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 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: e2fsprogs-devel BuildRequires: readline-devel @@ -123,9 +98,9 @@ make check %{_mandir}/man8/parted.8* %{_mandir}/man8/partprobe.8* %{_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.0.4 +%{_libdir}/libparted-fs-resize.so.0.0.5 %{_infodir}/parted.info* %files devel @@ -138,6 +113,11 @@ make check %changelog +* Mon Mar 27 2023 Brian C. Lane - 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 - 3.5-11 - parted: Fix ending sector location when using kibi IEC suffix (bcl) - tests: Fix formatting and snprintf warnings in tests. (bcl) diff --git a/sources b/sources index eaab8bf..5487849 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (parted-3.5.tar.xz) = 87fc69e947de5f0b670ee5373a7cdf86180cd782f6d7280f970f217f73f55ee1b1b018563f48954f3a54fdde5974b33e07eee68c9ccdf08e621d3dc0e3ce126a -SHA512 (parted-3.5.tar.xz.sig) = 2ea1209325595416aa9ee27a0e85ca38bce50ca885d3b52ab1c1fb1b68b78d7887386ea3120274648056d2f1d9dca00b77236991765d84ad226c1b1f5a3f5c62 +SHA512 (parted-3.5.28.tar.xz) = 6cbd280a47b6c8e3beac9db689f505f2f71aaaa62eb1c20cd23e5c4a2dc56841d5bfaa45bf661ac6fe3bb45441bc07f7d0b51e4673fa2c05f968e0a6b3bd4ee6 +SHA512 (parted-3.5.28.tar.xz.sig) = bf806d682ea4fa5f34c6fdcd7bb967c9278e164ba8167ef17e1ba83a4acf5a32355adf4468a457436a85e5ad6a223d2a79a61043728f0d269c69f89775a2e9af From 5243164589992bdb7e028ccd12dafe537495b422 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Mon, 10 Apr 2023 17:00:48 -0700 Subject: [PATCH 09/23] - Upstream 3.6 stable release --- .gitignore | 3 ++ parted.spec | 121 +++------------------------------------------------- sources | 4 +- 3 files changed, 10 insertions(+), 118 deletions(-) diff --git a/.gitignore b/.gitignore index fdd046b..ad40058 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,6 @@ clog /parted-3.5.tar.xz.sig /parted-3.5.28.tar.xz /parted-3.5.28.tar.xz.sig +/parted-3.6.tar.xz +/parted-3.6.tar.xz.sig +/parted-3.6.tar.xz.sug diff --git a/parted.spec b/parted.spec index 221a8a9..cae985c 100644 --- a/parted.spec +++ b/parted.spec @@ -1,6 +1,6 @@ Summary: The GNU disk partition manipulation program Name: parted -Version: 3.5.28 +Version: 3.6 Release: 1%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -113,6 +113,10 @@ make check %changelog +* Mon Apr 10 2023 Brian C. Lane - 3.6-1 +- Upstream 3.6 stable release +- Dropping pre-3.5 changelog entries + * Mon Mar 27 2023 Brian C. Lane - 3.5.28-1 - Upstream 3.5.28 Alpha release - Dropped all patches included in new upstream release @@ -164,118 +168,3 @@ make check * Mon Apr 18 2022 Brian C. Lane - 3.5-1 - Upstream 3.5 stable release - -* Wed Mar 30 2022 Brian C. Lane - 3.4.64-1 -- Upstream 3.4.64 Alpha release -- Dropped all patches included in new upstream release -- Bumped minor version on libparted.so and libparted-fs-resize.so - -* Thu Feb 17 2022 Brian C. Lane - 3.4-12 -- gnulib: Use newer cdefs.h from gnulib (bcl) -- Update parted.spec to allow flatpak builds - -* Thu Jan 20 2022 Fedora Release Engineering - 3.4-11 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_36_Mass_Rebuild - -* Wed Oct 06 2021 Brian C. Lane - 3.4-11 -- docs: Update documentation to be consistent - -* Wed Oct 06 2021 Brian C. Lane - 3.4-10 -- gpt: Revert to filesystem GUID when setting flag to off (bcl) -- tests: Add a test to make sure GPT GUIDs default to filesystem (bcl) -- doc: Document gpt linux-home flag (bcl) -- gpt: Add linux-home flag (aschnell) -- gpt: Map PED_PARTITON_ flags to GUID values (aschnell) - -* Thu Sep 23 2021 Brian C. Lane - 3.4-9 -- keep GUID specific attributes (aschnell) -- hurd: Implement partition table rereading (cjwatson) -- hurd: Support rumpdisk-based device names (samuel.thibault) -- hurd: Fix partition paths (cjwatson) - -* Wed Aug 25 2021 Brian C. Lane - 3.4-8 -- parted: Add --json cmdline switch to output JSON (aschnell) -- parted: Allow empty string for partition name (aschnell) -- libparted: Check devpath before passing to strlen (bcl) - -* Tue Aug 10 2021 Brian C. Lane - 3.4-7 -- libparted: Tell libdevmapper to retry remove when BUSY (bcl) - Resolves: rhbz#1980697 -- parted: Escape colons and backslashes in machine output (bcl) -- tests: check for vfat kernel support and tools (ross.burton) -- tests: add a helper to check the kernel knows about a file system (ross.burton) -- tests: add aarch64 and mips64 as a valid 64-bit machines (ross.burton) -- libparted: Add swap flag to msdos disklabel (bcl) -- Move Exception Option values into enum (bcl) - -* Tue Aug 03 2021 Brian C. Lane - 3.4-6 -- spec: Use the %%gpgverify macro for the signature check -- tests/t3000: Use mkfs.hfsplus and fsck.hfsplus for resize tests (bcl) -- tests/t3000: Check for hfs and vfat support separately (bcl) -- tests: Reduce memory usage for tests using scsi_debug module (bcl) -- spec: Install to /usr/sbin and /usr/lib64 (bcl) - -* Thu Jul 22 2021 Fedora Release Engineering - 3.4-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_35_Mass_Rebuild - -* Mon Jun 14 2021 Brian C. Lane - 3.4-4 -- Fix issues that covscan classifies as important - Resolves: rhbz#1938836 -- Update gpg key for bcl@redhat.com -- Work around a mkswap bug - -* Wed Mar 10 2021 Brian C. Lane - 3.4-3 -- Use autoreconf -fiv for autoconf 2.71 support - Works with both 2.69 and 2.71 - -* Wed Feb 03 2021 Brian C. Lane - 3.4-2 -- Add --fix support from upstream - -* Wed Jan 27 2021 Brian C. Lane - 3.4-1 -- New stable upstream release v3.4 - -* Tue Jan 26 2021 Fedora Release Engineering - 3.3.52-2 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_34_Mass_Rebuild - -* Mon Dec 14 2020 Brian C. Lane - 3.3.52-1 -- New upstream ALPHA release v3.3.52 -- Includes all patches - -* Mon Nov 30 2020 Brian C. Lane - 3.3-8 -- Add upstream commits to fix various gcc 10 warnings (bcl) - -* Thu Nov 05 2020 Brian C. Lane - 3.3-7 -- Do not link to libselinux - -* Fri Sep 25 2020 Brian C. Lane - 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 - 3.3-5 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_33_Mass_Rebuild - -* Tue Jul 14 2020 Tom Stellard - 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 - 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 - 3.3-3 -- Rebuilt for https://fedoraproject.org/wiki/Fedora_32_Mass_Rebuild - -* Mon Dec 16 2019 Brian C. Lane - 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 - 3.3-1 -- New upstream release v3.3 - Includes the DASD virtio-blk fix. -- Dropping pre-3.2 changelog entries diff --git a/sources b/sources index 5487849..aed1bd4 100644 --- a/sources +++ b/sources @@ -1,2 +1,2 @@ -SHA512 (parted-3.5.28.tar.xz) = 6cbd280a47b6c8e3beac9db689f505f2f71aaaa62eb1c20cd23e5c4a2dc56841d5bfaa45bf661ac6fe3bb45441bc07f7d0b51e4673fa2c05f968e0a6b3bd4ee6 -SHA512 (parted-3.5.28.tar.xz.sig) = bf806d682ea4fa5f34c6fdcd7bb967c9278e164ba8167ef17e1ba83a4acf5a32355adf4468a457436a85e5ad6a223d2a79a61043728f0d269c69f89775a2e9af +SHA512 (parted-3.6.tar.xz) = 034a44b25718acba175212019d24f092972a791c5bd1d921ae91e17478657a77c5c5dd0c832bed7968c3a07ec6c65c0785acfac2f90c1ca5e1692f3c141693ef +SHA512 (parted-3.6.tar.xz.sig) = 7c845026937b29fb49085ef9e3354226b73a1c3b5f9082d440d9a8ac13d76b1d07dae0bc10d8c974d4e57bc582f38c0a908e80718dd1ff1adfad3b04699c672c From e932a887a13f44ffe348e33adbebbca802ff2ae2 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 20 Jul 2023 18:42:01 +0000 Subject: [PATCH 10/23] Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild Signed-off-by: Fedora Release Engineering --- parted.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parted.spec b/parted.spec index cae985c..798602e 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 1%{?dist} +Release: 2%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -113,6 +113,9 @@ make check %changelog +* Thu Jul 20 2023 Fedora Release Engineering - 3.6-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild + * Mon Apr 10 2023 Brian C. Lane - 3.6-1 - Upstream 3.6 stable release - Dropping pre-3.5 changelog entries From dd51fedd16aa86ae32831de44d69ef698bcab8f1 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Sun, 21 Jan 2024 11:54:19 +0000 Subject: [PATCH 11/23] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild --- parted.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parted.spec b/parted.spec index 798602e..a3b392f 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 2%{?dist} +Release: 3%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -113,6 +113,9 @@ make check %changelog +* Sun Jan 21 2024 Fedora Release Engineering - 3.6-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + * Thu Jul 20 2023 Fedora Release Engineering - 3.6-2 - Rebuilt for https://fedoraproject.org/wiki/Fedora_39_Mass_Rebuild From 33a7d91cd031a9bdd577ef0d0085976884bc7c58 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 25 Jan 2024 12:04:58 +0000 Subject: [PATCH 12/23] Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild --- parted.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parted.spec b/parted.spec index a3b392f..0712f44 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 3%{?dist} +Release: 4%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -113,6 +113,9 @@ make check %changelog +* Thu Jan 25 2024 Fedora Release Engineering - 3.6-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild + * Sun Jan 21 2024 Fedora Release Engineering - 3.6-3 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From 92a16b9fb1fe7fb7e7f10219fdb94abeb995dfce Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Tue, 16 Jul 2024 17:33:24 -0700 Subject: [PATCH 13/23] - doc: Document IEC unit behavior in the manpage (bcl) - parted: Print the Fixing... message to stderr (bcl) --- ...-Print-the-Fixing.-message-to-stderr.patch | 28 ++++++++++++++ ...ent-IEC-unit-behavior-in-the-manpage.patch | 37 +++++++++++++++++++ parted.spec | 9 ++++- 3 files changed, 73 insertions(+), 1 deletion(-) create mode 100644 0001-parted-Print-the-Fixing.-message-to-stderr.patch create mode 100644 0002-doc-Document-IEC-unit-behavior-in-the-manpage.patch diff --git a/0001-parted-Print-the-Fixing.-message-to-stderr.patch b/0001-parted-Print-the-Fixing.-message-to-stderr.patch new file mode 100644 index 0000000..bfc90de --- /dev/null +++ b/0001-parted-Print-the-Fixing.-message-to-stderr.patch @@ -0,0 +1,28 @@ +From fc16e90a9fd64e2db12a815417b538b193fe48db Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 10 Jul 2024 15:41:16 -0700 +Subject: [PATCH 1/2] parted: Print the Fixing... message to stderr + +Otherwise it messes up stdout of things like --json + +Thanks to Mikael Q for reporting this. +--- + parted/ui.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/parted/ui.c b/parted/ui.c +index 33a1808..d6d1da4 100644 +--- a/parted/ui.c ++++ b/parted/ui.c +@@ -645,7 +645,7 @@ exception_handler (PedException* ex) + /* script-mode and fix? */ + int fix_is_an_option = (ex->options & PED_EXCEPTION_FIX); + if (opt_script_mode && opt_fix_mode && fix_is_an_option) { +- printf ("Fixing, due to --fix\n"); ++ fprintf (stderr, "Fixing, due to --fix\n"); + return PED_EXCEPTION_FIX; + } + +-- +2.45.2 + diff --git a/0002-doc-Document-IEC-unit-behavior-in-the-manpage.patch b/0002-doc-Document-IEC-unit-behavior-in-the-manpage.patch new file mode 100644 index 0000000..09f116f --- /dev/null +++ b/0002-doc-Document-IEC-unit-behavior-in-the-manpage.patch @@ -0,0 +1,37 @@ +From e34c1477cfa446f1b44287b10425a9e69602b519 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Fri, 12 Jul 2024 16:24:58 -0700 +Subject: [PATCH 2/2] doc: Document IEC unit behavior in the manpage + +Previously this has only been documented in the info page. +--- + doc/C/parted.8 | 13 +++++++++++++ + 1 file changed, 13 insertions(+) + +diff --git a/doc/C/parted.8 b/doc/C/parted.8 +index 3069c33..171269c 100644 +--- a/doc/C/parted.8 ++++ b/doc/C/parted.8 +@@ -151,6 +151,19 @@ Toggle the state of the disk \fIflag\fP. + .B version + Display version information and a copyright message. + .RE ++.SH UNITS ++\fBparted\fP will compute sensible ranges for the locations you specify when using ++units like "GB", "MB", etc. Use the sector unit "s" or IEC binary units like ++"GiB", "MiB", to specify exact locations. ++ ++When you specify start or end values using IEC binary units like "MiB", ++"GiB", "TiB", etc., \fBparted\fP treats those values as exact, and equivalent to ++the same number specified in bytes (i.e., with the "B" suffix), in that it ++provides no helpful range of sloppiness. Contrast that with a partition ++start request of "4GB", which may actually resolve to some sector up to 500MB ++before or after that point. Thus, when creating a partition in an exact location ++you should use units of bytes ("B"), sectors ("s"), or IEC binary units like ++"MiB", "GiB", but not "MB", "GB", etc. + .SH REPORTING BUGS + Report bugs to + .SH SEE ALSO +-- +2.45.2 + diff --git a/parted.spec b/parted.spec index 0712f44..e68edf4 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 4%{?dist} +Release: 5%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -10,6 +10,9 @@ Source1: https://ftp.gnu.org/gnu/%{name}/%{name}-%{version}.tar.xz.sig Source2: pubkey.phillip.susi Source3: pubkey.brian.lane +Patch0001: 0001-parted-Print-the-Fixing.-message-to-stderr.patch +Patch0002: 0002-doc-Document-IEC-unit-behavior-in-the-manpage.patch + BuildRequires: gcc BuildRequires: e2fsprogs-devel BuildRequires: readline-devel @@ -113,6 +116,10 @@ make check %changelog +* Tue Jul 16 2024 Brian C. Lane - 3.6-5 +- doc: Document IEC unit behavior in the manpage (bcl) +- parted: Print the Fixing... message to stderr (bcl) + * Thu Jan 25 2024 Fedora Release Engineering - 3.6-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild From 7a70ad0b824134c8e50a6500f7e1bf5418dc6613 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 18 Jul 2024 21:31:19 +0000 Subject: [PATCH 14/23] Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild --- parted.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parted.spec b/parted.spec index e68edf4..eeca1ef 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 5%{?dist} +Release: 6%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -116,6 +116,9 @@ make check %changelog +* Thu Jul 18 2024 Fedora Release Engineering - 3.6-6 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild + * Tue Jul 16 2024 Brian C. Lane - 3.6-5 - doc: Document IEC unit behavior in the manpage (bcl) - parted: Print the Fixing... message to stderr (bcl) From c43802428646dd0aadee34b5ff16f083932e4520 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 31 Jul 2024 08:54:08 -0700 Subject: [PATCH 15/23] tests: Move to tmt tests and switch to a functional test Instead of repeating the build unit testing, this tests the installed parted with a simple disk image partitioning scheme to verify basic functionality. --- .fmf/version | 1 + plans/test-parted.fmf | 8 ++++++++ tests/provision.fmf | 5 ----- tests/scripts/run_tests.sh | 30 ++++++++++++++++++++++++++++++ tests/simple/run_tests.sh | 29 ----------------------------- tests/tests.yml | 14 -------------- 6 files changed, 39 insertions(+), 48 deletions(-) create mode 100644 .fmf/version create mode 100644 plans/test-parted.fmf delete mode 100644 tests/provision.fmf create mode 100755 tests/scripts/run_tests.sh delete mode 100755 tests/simple/run_tests.sh delete mode 100644 tests/tests.yml diff --git a/.fmf/version b/.fmf/version new file mode 100644 index 0000000..d00491f --- /dev/null +++ b/.fmf/version @@ -0,0 +1 @@ +1 diff --git a/plans/test-parted.fmf b/plans/test-parted.fmf new file mode 100644 index 0000000..2b22c58 --- /dev/null +++ b/plans/test-parted.fmf @@ -0,0 +1,8 @@ +summary: Run a basic parted test +prepare: + how: install + package: + - parted + - jq +execute: + script: ./tests/scripts/run_tests.sh diff --git a/tests/provision.fmf b/tests/provision.fmf deleted file mode 100644 index dd69f34..0000000 --- a/tests/provision.fmf +++ /dev/null @@ -1,5 +0,0 @@ ---- - -standard-inventory-qcow2: - qemu: - m: 4G diff --git a/tests/scripts/run_tests.sh b/tests/scripts/run_tests.sh new file mode 100755 index 0000000..0161a84 --- /dev/null +++ b/tests/scripts/run_tests.sh @@ -0,0 +1,30 @@ +#!/usr/bin/bash +set -eux + +DISK=/var/tmp/parted-disk.img + +# Make a temporary disk image to use for tests +fallocate -l 100MiB $DISK + +# Make a disklabel and a couple of partitions +parted -s $DISK mklabel gpt +parted -s $DISK mkpart vfat 1MiB 10MiB +parted -s $DISK mkpart ext4 10MiB 50MiB +parted -s $DISK mkpart ext4 50MiB 75MiB +parted -s $DISK set 1 boot +parted -s $DISK set 3 linux-home + +# Check p1 for ESP UUID c12a7328-f81f-11d2-ba4b-00a0c93ec93b +P1_TYPE=$(parted -s $DISK --json u MiB p | jq -r '.disk.partitions[0]."type-uuid"') +[ "$P1_TYPE" == "c12a7328-f81f-11d2-ba4b-00a0c93ec93b" ] || exit 1 + +# Check p2 for linux data type 0fc63daf-8483-4772-8e79-3d69d8477de4 +P2_TYPE=$(parted -s $DISK --json u MiB p | jq -r '.disk.partitions[1]."type-uuid"') +[ "$P2_TYPE" == "0fc63daf-8483-4772-8e79-3d69d8477de4" ] || exit 1 + +# Check p3 for linux home type 933ac7e1-2eb4-4f13-b844-0e14e2aef915 +P3_TYPE=$(parted -s $DISK --json u MiB p | jq -r '.disk.partitions[2]."type-uuid"') +[ "$P3_TYPE" == "933ac7e1-2eb4-4f13-b844-0e14e2aef915" ] || exit 1 + +echo "PASS" +exit 0 diff --git a/tests/simple/run_tests.sh b/tests/simple/run_tests.sh deleted file mode 100755 index 9d40419..0000000 --- a/tests/simple/run_tests.sh +++ /dev/null @@ -1,29 +0,0 @@ -#!/bin/sh -set -eux - -: ${1?"Usage: $0 TESTSDIR"} - -TESTSDIR="$1" -SOURCEDIR="${TESTSDIR}/source/" -PACKAGE=parted - -cd "${TESTSDIR}" -if [ ! -e ${PACKAGE}.spec ]; then - echo "Missing ${PACKAGE}.spec" - pwd - ls - exit 1 -fi - -# This runs from the ./tests/ directory -# Install the dependencies from the spec which MUST be copied over by tests.yml -dnf -y build-dep ${PACKAGE}.spec - -# Flattened sources from standard-role-sources -cd "${SOURCEDIR}" || exit - -# Rebuild the package in place, also runs the %check -# skip %prep, it was already run on the source before it was copied over -rpmbuild --noprep --nodeps -bb --build-in-place "${TESTSDIR}/${PACKAGE}.spec" -RET=$? -exit ${RET} diff --git a/tests/tests.yml b/tests/tests.yml deleted file mode 100644 index 5fde476..0000000 --- a/tests/tests.yml +++ /dev/null @@ -1,14 +0,0 @@ ---- -- hosts: localhost - tags: - - classic - roles: - - role: standard-test-source - required_packages: - - dnf - - rpm-build - - git - - role: standard-test-basic - tests: - - simple: - run: "./run_tests.sh {{ tenv_workdir }}" From b8c84c998296df51e16ab3d7df3079e452626cf0 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 23 Aug 2024 08:17:29 -0700 Subject: [PATCH 16/23] - tests: Move to tmt tests and switch to a functional test (bcl) --- parted.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parted.spec b/parted.spec index eeca1ef..7448a3f 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 6%{?dist} +Release: 7%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -116,6 +116,9 @@ make check %changelog +* Fri Aug 23 2024 Brian C. Lane - 3.6-7 +- tests: Move to tmt tests and switch to a functional test (bcl) + * Thu Jul 18 2024 Fedora Release Engineering - 3.6-6 - Rebuilt for https://fedoraproject.org/wiki/Fedora_41_Mass_Rebuild From ff0683d294963f0582bd91dd43f0832e3d1fc15d Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 17 Oct 2024 16:57:17 -0700 Subject: [PATCH 17/23] - libparted: Fail early when detecting nilfs2 (oldium.pro) --- ...ted-Fail-early-when-detecting-nilfs2.patch | 55 +++++++++++++++++++ parted.spec | 4 ++ 2 files changed, 59 insertions(+) create mode 100644 0003-libparted-Fail-early-when-detecting-nilfs2.patch diff --git a/0003-libparted-Fail-early-when-detecting-nilfs2.patch b/0003-libparted-Fail-early-when-detecting-nilfs2.patch new file mode 100644 index 0000000..b9675bb --- /dev/null +++ b/0003-libparted-Fail-early-when-detecting-nilfs2.patch @@ -0,0 +1,55 @@ +From 8623f65e1fd064a679f75e3e075dff86f30282a7 Mon Sep 17 00:00:00 2001 +From: =?UTF-8?q?Old=C5=99ich=20Jedli=C4=8Dka?= +Date: Sat, 6 Apr 2024 19:21:11 +0200 +Subject: [PATCH] libparted: Fail early when detecting nilfs2 +MIME-Version: 1.0 +Content-Type: text/plain; charset=UTF-8 +Content-Transfer-Encoding: 8bit + +When the disk is encrypted with TCG Opal HW encryption (supported by +cryptsetup 2.7.0+), the partition initially contains locked area, which +shows reading errors in kernel logs and may lead to configuring the disk +to work with lower reading speed. When the disk area is unlocked with +password, the reading succeeds. The beginning of the protected partition is +not locked and contains LUKS header, this is always readable. + +To work around the errors when reading from the locked area, try first +detecting nilfs2 at the beginning (may be an unprotected LUKS header area) +and only check the second superblock that is at the end of the area (and +possibly locked) if the first one is valid (meaning the partition is not +LUKS-protected). + +This is a change in behavior, but is consistent with the nilfs2 code, which +considers both superblocks mandatory, see [1]. + +[1] https://github.com/nilfs-dev/nilfs-utils/blob/master/lib/sb.c#L135-L158 + +Signed-off-by: Oldřich Jedlička +Signed-off-by: Brian C. Lane +--- + libparted/fs/nilfs2/nilfs2.c | 7 ++++--- + 1 file changed, 4 insertions(+), 3 deletions(-) + +diff --git a/libparted/fs/nilfs2/nilfs2.c b/libparted/fs/nilfs2/nilfs2.c +index 6204542..40f8567 100644 +--- a/libparted/fs/nilfs2/nilfs2.c ++++ b/libparted/fs/nilfs2/nilfs2.c +@@ -118,11 +118,12 @@ nilfs2_probe (PedGeometry* geom) + + if (ped_geometry_read(geom, buf, 0, sectors)) + sb = (struct nilfs2_super_block*)(buf + 1024); ++ if (!sb || !is_valid_nilfs_sb(sb)) ++ return NULL; ++ + if (ped_geometry_read(geom, buff2, sb2off, sectors2)) + sb2 = (struct nilfs2_super_block*)buff2; +- +- if ((!sb || !is_valid_nilfs_sb(sb)) && +- (!sb2 || !is_valid_nilfs_sb(sb2))) ++ if (!sb2 || !is_valid_nilfs_sb(sb2)) + return NULL; + + /* reserve 4k bytes for secondary superblock */ +-- +2.47.0 + diff --git a/parted.spec b/parted.spec index 7448a3f..570a0ba 100644 --- a/parted.spec +++ b/parted.spec @@ -12,6 +12,7 @@ Source3: pubkey.brian.lane Patch0001: 0001-parted-Print-the-Fixing.-message-to-stderr.patch Patch0002: 0002-doc-Document-IEC-unit-behavior-in-the-manpage.patch +Patch0003: 0003-libparted-Fail-early-when-detecting-nilfs2.patch BuildRequires: gcc BuildRequires: e2fsprogs-devel @@ -116,6 +117,9 @@ make check %changelog +* Thu Oct 17 2024 Brian C. Lane - 3.6-7 +- libparted: Fail early when detecting nilfs2 (oldium.pro) + * Fri Aug 23 2024 Brian C. Lane - 3.6-7 - tests: Move to tmt tests and switch to a functional test (bcl) From b58c412aedf8334506cf58ab66cc6c58630414ea Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 17 Oct 2024 16:59:43 -0700 Subject: [PATCH 18/23] Properly bump the release number --- parted.spec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/parted.spec b/parted.spec index 570a0ba..991599e 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 7%{?dist} +Release: 8%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -117,7 +117,7 @@ make check %changelog -* Thu Oct 17 2024 Brian C. Lane - 3.6-7 +* Thu Oct 17 2024 Brian C. Lane - 3.6-8 - libparted: Fail early when detecting nilfs2 (oldium.pro) * Fri Aug 23 2024 Brian C. Lane - 3.6-7 From b1522a97110c5f2fd7a47f18d5d21b5dfe746f43 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 20 Nov 2024 09:35:26 -0800 Subject: [PATCH 19/23] - parted: Fix do_version declaration (rudi) --- ...CH-parted-fix-do_version-declaration.patch | 41 +++++++++++++++++++ parted.spec | 6 ++- 2 files changed, 46 insertions(+), 1 deletion(-) create mode 100644 0004-bug-74444-PATCH-parted-fix-do_version-declaration.patch diff --git a/0004-bug-74444-PATCH-parted-fix-do_version-declaration.patch b/0004-bug-74444-PATCH-parted-fix-do_version-declaration.patch new file mode 100644 index 0000000..187e4c4 --- /dev/null +++ b/0004-bug-74444-PATCH-parted-fix-do_version-declaration.patch @@ -0,0 +1,41 @@ +From 16343bda6ce0d41edf43f8dac368db3bbb63d271 Mon Sep 17 00:00:00 2001 +From: Rudi Heitbaum +Date: Wed, 20 Nov 2024 12:22:22 +0000 +Subject: [PATCH] bug#74444: [PATCH] parted: fix do_version declaration + +With gcc 15-20241117 compile fails with the below error, update the +do_version declaration to match the header in command.h + +../../parted/parted.c: In function '_init_commands': +../../parted/parted.c:2469:9: error: passing argument 2 of 'command_create' from incompatible pointer type [-Wincompatible-pointer-types] + 2469 | do_version, + | ^~~~~~~~~~ + | | + | int (*)(void) +In file included from ../../parted/parted.c:28: +../../parted/command.h:35:39: note: expected 'int (*)(PedDevice **, PedDisk **)' {aka 'int (*)(struct _PedDevice **, struct _PedDisk **)'} but argument is of type 'int (*)(void)' + 35 | int (*method) (PedDevice** dev, PedDisk** diskp), + | ~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Signed-off-by: Rudi Heitbaum +Signed-off-by: Brian C. Lane +--- + parted/parted.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/parted/parted.c b/parted/parted.c +index 3abb52f..fc2aeba 100644 +--- a/parted/parted.c ++++ b/parted/parted.c +@@ -2172,7 +2172,7 @@ do_unit (PedDevice** dev, PedDisk** diskp) + } + + static int +-do_version () ++do_version (PedDevice** dev, PedDisk** diskp) + { + printf ("\n%s\n%s", + prog_name, +-- +2.47.0 + diff --git a/parted.spec b/parted.spec index 991599e..fc4362f 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 8%{?dist} +Release: 9%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -13,6 +13,7 @@ Source3: pubkey.brian.lane Patch0001: 0001-parted-Print-the-Fixing.-message-to-stderr.patch Patch0002: 0002-doc-Document-IEC-unit-behavior-in-the-manpage.patch Patch0003: 0003-libparted-Fail-early-when-detecting-nilfs2.patch +Patch0004: 0004-bug-74444-PATCH-parted-fix-do_version-declaration.patch BuildRequires: gcc BuildRequires: e2fsprogs-devel @@ -117,6 +118,9 @@ make check %changelog +* Wed Nov 20 2024 Brian C. Lane - 3.6-9 +- parted: Fix do_version declaration (rudi) + * Thu Oct 17 2024 Brian C. Lane - 3.6-8 - libparted: Fail early when detecting nilfs2 (oldium.pro) From c89e7cb3be6ef3b491388f3fdc00e3170708eb8f Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Wed, 15 Jan 2025 10:19:36 -0800 Subject: [PATCH 20/23] - tests: Add test for dvh with a bad checksum (bcl) - libparted: Fix dvh disklabel unhandled exception (bcl) - tests: Add test for SUN disklabel handling (bcl) - libparted: Fix sun disklabel unhandled exception (bcl) --- ...ix-sun-disklabel-unhandled-exception.patch | 31 +++++ ...-Add-test-for-SUN-disklabel-handling.patch | 116 ++++++++++++++++++ ...ix-dvh-disklabel-unhandled-exception.patch | 29 +++++ ...Add-test-for-dvh-with-a-bad-checksum.patch | 57 +++++++++ parted.spec | 12 +- 5 files changed, 244 insertions(+), 1 deletion(-) create mode 100644 0005-libparted-Fix-sun-disklabel-unhandled-exception.patch create mode 100644 0006-tests-Add-test-for-SUN-disklabel-handling.patch create mode 100644 0007-libparted-Fix-dvh-disklabel-unhandled-exception.patch create mode 100644 0008-tests-Add-test-for-dvh-with-a-bad-checksum.patch diff --git a/0005-libparted-Fix-sun-disklabel-unhandled-exception.patch b/0005-libparted-Fix-sun-disklabel-unhandled-exception.patch new file mode 100644 index 0000000..e4c5d9f --- /dev/null +++ b/0005-libparted-Fix-sun-disklabel-unhandled-exception.patch @@ -0,0 +1,31 @@ +From 95b877cfa36c1571487c2a67a3902f1f5c4dc747 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Tue, 7 Jan 2025 16:50:21 -0800 +Subject: [PATCH 5/8] libparted: Fix sun disklabel unhandled exception + +The CHS warning should only continue if ignored, not if unhandled. + +Script mode, or exception handlers can return PED_EXCEPTION_UNHANDLED +which should act the same as a cancel. Previously it would only exit if +cancel was selected, allowing it to continue to use the bad CHS and +crash later. +--- + libparted/labels/sun.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libparted/labels/sun.c b/libparted/labels/sun.c +index 5ed2886..853576b 100644 +--- a/libparted/labels/sun.c ++++ b/libparted/labels/sun.c +@@ -284,7 +284,7 @@ _check_geometry_sanity (PedDisk* disk, SunRawLabel* label) + PED_BE16_TO_CPU(label->pcylcount), + PED_BE16_TO_CPU(label->ntrks), + PED_BE16_TO_CPU(label->nsect)) +- == PED_EXCEPTION_CANCEL) ++ != PED_EXCEPTION_IGNORE) + return 0; + #endif + dev->bios_geom.sectors = PED_BE16_TO_CPU(label->nsect); +-- +2.47.1 + diff --git a/0006-tests-Add-test-for-SUN-disklabel-handling.patch b/0006-tests-Add-test-for-SUN-disklabel-handling.patch new file mode 100644 index 0000000..735e60d --- /dev/null +++ b/0006-tests-Add-test-for-SUN-disklabel-handling.patch @@ -0,0 +1,116 @@ +From bdb92f73112177c091a764836a9ceaa59f7e9b15 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 8 Jan 2025 11:59:40 -0800 +Subject: [PATCH 6/8] tests: Add test for SUN disklabel handling + +When fixed the output from script mode should be an unknown disklabel, +not sun. +--- + tests/Makefile.am | 3 ++- + tests/sun-badlabel | 42 +++++++++++++++++++++++++++++++++++++ + tests/t4002-sun-badlabel.sh | 23 ++++++++++++++++++++ + 3 files changed, 67 insertions(+), 1 deletion(-) + create mode 100755 tests/sun-badlabel + create mode 100644 tests/t4002-sun-badlabel.sh + +diff --git a/tests/Makefile.am b/tests/Makefile.am +index fa27b44..00f4a9d 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -67,6 +67,7 @@ TESTS = \ + t3400-whole-disk-FAT-partition.sh \ + t4000-sun-raid-type.sh \ + t4001-sun-vtoc.sh \ ++ t4002-sun-badlabel.sh \ + t4100-msdos-partition-limits.sh \ + t4100-dvh-partition-limits.sh \ + t4100-msdos-starting-sector.sh \ +@@ -103,7 +104,7 @@ TESTS = \ + EXTRA_DIST = \ + $(TESTS) t-local.sh t-lvm.sh \ + init.cfg init.sh t-lib-helpers.sh gpt-header-munge \ +- gpt-header-move msdos-overlap gpt-attrs ++ gpt-header-move msdos-overlap gpt-attrs sun-badlabel + + check_PROGRAMS = print-align print-flags print-max dup-clobber duplicate \ + fs-resize +diff --git a/tests/sun-badlabel b/tests/sun-badlabel +new file mode 100755 +index 0000000..6a28e86 +--- /dev/null ++++ b/tests/sun-badlabel +@@ -0,0 +1,42 @@ ++#!/usr/bin/python3 ++# Mangle the CHS values stored in a SUN disklabel ++# This sets CHS to 1 track, 2 sectors and updates the checksum ++# This triggers a bug in the SUN disklabel code when the CHS ++# error is UNHANDLED (in script mode or with a custom exception ++# handler) and it continues using a bad label which will coredump ++# when .duplicate() is called on it. ++ ++import array ++from struct import unpack_from, pack_into ++import sys ++ ++file = open(sys.argv[1],'rb+') ++header = file.read(512) ++ ++# Make sure it looks like a SUN disklabel first ++magic = unpack_from(">H", header, 0x1FC)[0] ++if magic != 0xDABE: ++ raise RuntimeError("Not a SUN disklabel. magic = 0x%04X" % magic) ++csum = unpack_from(">H", header, 0x1FE)[0] ++ntrks = unpack_from(">H", header, 0x1B4)[0] ++nsect = unpack_from(">H", header, 0x1B6)[0] ++ ++header = array.array('B', header) ++# cylinders at 0x1B0 ++# modify ntrks at offset 0x1B4 ++pack_into('>H', header, 0x1B4, 1) ++# modify nsect at offset 0x1B6 ++pack_into('>H', header, 0x1B6, 2) ++ ++## Undo old values ++csum ^= ntrks ++csum ^= nsect ++ ++## Add new ++csum ^= 1 ++csum ^= 2 ++pack_into('>H', header, 0x1FE, csum) ++ ++file.seek(0) ++file.write(header) ++file.close() +diff --git a/tests/t4002-sun-badlabel.sh b/tests/t4002-sun-badlabel.sh +new file mode 100644 +index 0000000..177c0e4 +--- /dev/null ++++ b/tests/t4002-sun-badlabel.sh +@@ -0,0 +1,23 @@ ++#!/bin/sh ++# Test exception handling on a bad SUN disklabel ++ ++. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir ++ss=$sector_size_ ++ ++n_sectors=2000 # number of sectors ++dev=sun-disk-file ++# create an empty file as a test disk ++dd if=/dev/zero of=$dev bs=$ss count=$n_sectors 2> /dev/null || fail=1 ++ ++# label the test disk as a sun disk ++parted -s $dev mklabel sun > out 2>&1 || fail=1 ++compare /dev/null out || fail=1 ++ ++# Mangle the disklabel to have incorrect CHS values, but a valid checksum ++sun-badlabel $dev || fail=1 ++ ++# Check the output (this should return 1, but depend on checking the output for the test) ++parted -m -s $dev p > out 2>&1 ++grep unknown out || { cat out; fail=1; } ++ ++Exit $fail +-- +2.47.1 + diff --git a/0007-libparted-Fix-dvh-disklabel-unhandled-exception.patch b/0007-libparted-Fix-dvh-disklabel-unhandled-exception.patch new file mode 100644 index 0000000..59dacde --- /dev/null +++ b/0007-libparted-Fix-dvh-disklabel-unhandled-exception.patch @@ -0,0 +1,29 @@ +From 1480769f2a7071c5a251b6c69658808199e8b05b Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 8 Jan 2025 13:35:04 -0800 +Subject: [PATCH 7/8] libparted: Fix dvh disklabel unhandled exception + +When an exception is using PED_EXCEPTION_IGNORE_CANCEL it should check +for !PED_EXCEPTION_IGNORE so that an unhandled exception is treated the +same as cancel. Otherwise it could lead to using the disklabel with +incorrect values. +--- + libparted/labels/dvh.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libparted/labels/dvh.c b/libparted/labels/dvh.c +index 0f9124d..7d7dae3 100644 +--- a/libparted/labels/dvh.c ++++ b/libparted/labels/dvh.c +@@ -308,7 +308,7 @@ dvh_read (PedDisk* disk) + PED_EXCEPTION_IGNORE_CANCEL, + _("Checksum is wrong, indicating the partition " + "table is corrupt.")) +- == PED_EXCEPTION_CANCEL) ++ != PED_EXCEPTION_IGNORE) + return 0; + } + +-- +2.47.1 + diff --git a/0008-tests-Add-test-for-dvh-with-a-bad-checksum.patch b/0008-tests-Add-test-for-dvh-with-a-bad-checksum.patch new file mode 100644 index 0000000..b1f9451 --- /dev/null +++ b/0008-tests-Add-test-for-dvh-with-a-bad-checksum.patch @@ -0,0 +1,57 @@ +From 82b582996ce691eb635bed124603207515b92efe Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 8 Jan 2025 14:01:39 -0800 +Subject: [PATCH 8/8] tests: Add test for dvh with a bad checksum + +When using script mode it should return an unknown partition type, not +dvh, because the exception is unhandled. +--- + tests/Makefile.am | 1 + + tests/t4101-dvh-badlabel.sh | 23 +++++++++++++++++++++++ + 2 files changed, 24 insertions(+) + create mode 100644 tests/t4101-dvh-badlabel.sh + +diff --git a/tests/Makefile.am b/tests/Makefile.am +index 00f4a9d..5eeab08 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -71,6 +71,7 @@ TESTS = \ + t4100-msdos-partition-limits.sh \ + t4100-dvh-partition-limits.sh \ + t4100-msdos-starting-sector.sh \ ++ t4101-dvh-badlabel.sh \ + t4200-partprobe.sh \ + t4300-nilfs2-tiny.sh \ + t4301-nilfs2-badsb2.sh \ +diff --git a/tests/t4101-dvh-badlabel.sh b/tests/t4101-dvh-badlabel.sh +new file mode 100644 +index 0000000..075c044 +--- /dev/null ++++ b/tests/t4101-dvh-badlabel.sh +@@ -0,0 +1,23 @@ ++#!/bin/sh ++# Test exception handling on a bad DVH disklabel ++ ++. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir ++ss=$sector_size_ ++ ++n_sectors=2000 # number of sectors ++dev=sun-disk-file ++# create an empty file as a test disk ++dd if=/dev/zero of=$dev bs=$ss count=$n_sectors 2> /dev/null || fail=1 ++ ++# label the test disk as a dvh disk ++parted -s $dev mklabel dvh > out 2>&1 || fail=1 ++compare /dev/null out || fail=1 ++ ++# Mangle the disklabel to have incorrect checksum ++dd if=/dev/zero of=$dev conv=notrunc bs=4 count=1 seek=1 ++ ++# Check the output (this should return 1, but depend on checking the output for the test) ++parted -m -s $dev p > out 2>&1 ++grep unknown out || { cat out; fail=1; } ++ ++Exit $fail +-- +2.47.1 + diff --git a/parted.spec b/parted.spec index fc4362f..a07d44e 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 9%{?dist} +Release: 10%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -14,6 +14,10 @@ Patch0001: 0001-parted-Print-the-Fixing.-message-to-stderr.patch Patch0002: 0002-doc-Document-IEC-unit-behavior-in-the-manpage.patch Patch0003: 0003-libparted-Fail-early-when-detecting-nilfs2.patch Patch0004: 0004-bug-74444-PATCH-parted-fix-do_version-declaration.patch +Patch0005: 0005-libparted-Fix-sun-disklabel-unhandled-exception.patch +Patch0006: 0006-tests-Add-test-for-SUN-disklabel-handling.patch +Patch0007: 0007-libparted-Fix-dvh-disklabel-unhandled-exception.patch +Patch0008: 0008-tests-Add-test-for-dvh-with-a-bad-checksum.patch BuildRequires: gcc BuildRequires: e2fsprogs-devel @@ -118,6 +122,12 @@ make check %changelog +* Wed Jan 15 2025 Brian C. Lane - 3.6-10 +- tests: Add test for dvh with a bad checksum (bcl) +- libparted: Fix dvh disklabel unhandled exception (bcl) +- tests: Add test for SUN disklabel handling (bcl) +- libparted: Fix sun disklabel unhandled exception (bcl) + * Wed Nov 20 2024 Brian C. Lane - 3.6-9 - parted: Fix do_version declaration (rudi) From 2e579d4323385b4491069adbb56e851bbc67606e Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Fri, 17 Jan 2025 22:26:33 +0000 Subject: [PATCH 21/23] Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild --- parted.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parted.spec b/parted.spec index a07d44e..c0203d1 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 10%{?dist} +Release: 11%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -122,6 +122,9 @@ make check %changelog +* Fri Jan 17 2025 Fedora Release Engineering - 3.6-11 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild + * Wed Jan 15 2025 Brian C. Lane - 3.6-10 - tests: Add test for dvh with a bad checksum (bcl) - libparted: Fix dvh disklabel unhandled exception (bcl) From a13c518ae560f199c9c6412fa923896ec7b2a96a Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Fri, 30 May 2025 10:49:27 -0700 Subject: [PATCH 22/23] - doc: Fix some groff/mandoc linting complaints (bcl) - nilfs2: Fixed possible sigsegv in case of corrupted superblock (abutenko) - libparted: Do not detect ext4 without journal as ext2 (pascal) - tests: probing ext4 without journal should still indicate ext4 (bcl) --- ...t4-without-journal-should-still-indi.patch | 52 +++++++++++ ...-detect-ext4-without-journal-as-ext2.patch | 61 +++++++++++++ ...sible-sigsegv-in-case-of-corrupted-s.patch | 61 +++++++++++++ ...some-groff-mandoc-linting-complaints.patch | 90 +++++++++++++++++++ parted.spec | 12 ++- 5 files changed, 275 insertions(+), 1 deletion(-) create mode 100644 0009-tests-probing-ext4-without-journal-should-still-indi.patch create mode 100644 0010-libparted-Do-not-detect-ext4-without-journal-as-ext2.patch create mode 100644 0011-nilfs2-Fixed-possible-sigsegv-in-case-of-corrupted-s.patch create mode 100644 0012-doc-Fix-some-groff-mandoc-linting-complaints.patch diff --git a/0009-tests-probing-ext4-without-journal-should-still-indi.patch b/0009-tests-probing-ext4-without-journal-should-still-indi.patch new file mode 100644 index 0000000..1fa6a1c --- /dev/null +++ b/0009-tests-probing-ext4-without-journal-should-still-indi.patch @@ -0,0 +1,52 @@ +From 43c2b908396e8b7baa475e009f3f4dbf9b9beac7 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 28 May 2025 11:24:21 -0700 +Subject: [PATCH 09/12] tests: probing ext4 without journal should still + indicate ext4 + +t1700 tests a fix for the ext filesystem probe code, it was previously +returning ext2 when the filesystem is really ext4 without a journal. + +t3200 is updated to reflect the correct filesystem type -- it creates a +fs too small for a journal so it used to identify it as ext2 but now +correctly identifies it as ext4. +--- + tests/t1700-probe-fs.sh | 10 ++++++++++ + tests/t3200-resize-partition.sh | 2 +- + 2 files changed, 11 insertions(+), 1 deletion(-) + +diff --git a/tests/t1700-probe-fs.sh b/tests/t1700-probe-fs.sh +index 7557f92..2bf2810 100755 +--- a/tests/t1700-probe-fs.sh ++++ b/tests/t1700-probe-fs.sh +@@ -70,4 +70,14 @@ for feature in uninit_bg flex_bg; do + rm $dev + done + ++# ext4 without a journal should still indicate ext4 ++# create an ext3 file system ++dd if=/dev/null of=$dev bs=1024 seek=8192 >/dev/null || skip_ "dd failed" ++mkfs.ext4 -O ^has_journal -F $dev >/dev/null || skip_ "mkfs.ext4 failed" ++ ++# probe the file system, which should still be ext4 ++parted -m -s $dev u s print >out 2>&1 || fail=1 ++grep '^1:.*:ext4::;$' out || fail=1 ++rm $dev ++ + Exit $fail +diff --git a/tests/t3200-resize-partition.sh b/tests/t3200-resize-partition.sh +index 846fbc3..c9decab 100755 +--- a/tests/t3200-resize-partition.sh ++++ b/tests/t3200-resize-partition.sh +@@ -111,7 +111,7 @@ compare exp out || fail=1 + parted -m -s $dev u s p > out 2>&1 || fail=1 + + sed -n 3p out > k && mv k out || fail=1 +-printf "1:$default_start:$new_end:3073s:ext2::$ms;\n" > exp || fail=1 ++printf "1:$default_start:$new_end:3073s:ext4::$ms;\n" > exp || fail=1 + compare exp out || fail=1 + + umount "${dev}1" || fail=1 +-- +2.49.0 + diff --git a/0010-libparted-Do-not-detect-ext4-without-journal-as-ext2.patch b/0010-libparted-Do-not-detect-ext4-without-journal-as-ext2.patch new file mode 100644 index 0000000..2739563 --- /dev/null +++ b/0010-libparted-Do-not-detect-ext4-without-journal-as-ext2.patch @@ -0,0 +1,61 @@ +From e61584ddeb952ff04823936dabd1a6a241f04f38 Mon Sep 17 00:00:00 2001 +From: Pascal Hambourg +Date: Thu, 17 Apr 2025 18:42:33 +0200 +Subject: [PATCH 10/12] libparted: Do not detect ext4 without journal as ext2 + +ext4 may have other incompatible features than journal and cannot be +mounted as ext2 by linux, so detect it as ext4 even without journal +if it has other incompatible features. + +Signed-off-by: Brian C. Lane +--- + libparted/fs/ext2/interface.c | 33 +++++++++++++++------------------ + 1 file changed, 15 insertions(+), 18 deletions(-) + +diff --git a/libparted/fs/ext2/interface.c b/libparted/fs/ext2/interface.c +index 7e0b197..5f64ab3 100644 +--- a/libparted/fs/ext2/interface.c ++++ b/libparted/fs/ext2/interface.c +@@ -52,24 +52,21 @@ _ext2_generic_probe (PedGeometry* geom, int expect_ext_ver) + int is_ext3 = 0; + int is_ext4 = 0; + +- is_ext3 = (EXT2_SUPER_FEATURE_COMPAT (*sb) +- & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0; +- if (is_ext3) { +- is_ext4 = ((EXT2_SUPER_FEATURE_RO_COMPAT (*sb) +- & EXT4_FEATURE_RO_COMPAT_HUGE_FILE) +- || (EXT2_SUPER_FEATURE_RO_COMPAT (*sb) +- & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) +- || (EXT2_SUPER_FEATURE_RO_COMPAT (*sb) +- & EXT4_FEATURE_RO_COMPAT_DIR_NLINK) +- || (EXT2_SUPER_FEATURE_INCOMPAT (*sb) +- & EXT4_FEATURE_INCOMPAT_EXTENTS) +- || (EXT2_SUPER_FEATURE_INCOMPAT (*sb) +- & EXT4_FEATURE_INCOMPAT_64BIT) +- || (EXT2_SUPER_FEATURE_INCOMPAT (*sb) +- & EXT4_FEATURE_INCOMPAT_FLEX_BG)); +- if (is_ext4) +- is_ext3 = 0; +- } ++ is_ext4 = ((EXT2_SUPER_FEATURE_RO_COMPAT (*sb) ++ & EXT4_FEATURE_RO_COMPAT_HUGE_FILE) ++ || (EXT2_SUPER_FEATURE_RO_COMPAT (*sb) ++ & EXT4_FEATURE_RO_COMPAT_GDT_CSUM) ++ || (EXT2_SUPER_FEATURE_RO_COMPAT (*sb) ++ & EXT4_FEATURE_RO_COMPAT_DIR_NLINK) ++ || (EXT2_SUPER_FEATURE_INCOMPAT (*sb) ++ & EXT4_FEATURE_INCOMPAT_EXTENTS) ++ || (EXT2_SUPER_FEATURE_INCOMPAT (*sb) ++ & EXT4_FEATURE_INCOMPAT_64BIT) ++ || (EXT2_SUPER_FEATURE_INCOMPAT (*sb) ++ & EXT4_FEATURE_INCOMPAT_FLEX_BG)); ++ if (!is_ext4) ++ is_ext3 = (EXT2_SUPER_FEATURE_COMPAT (*sb) ++ & EXT3_FEATURE_COMPAT_HAS_JOURNAL) != 0; + if (expect_ext_ver == 2 && (is_ext3 || is_ext4)) + return NULL; + if (expect_ext_ver == 3 && !is_ext3) +-- +2.49.0 + diff --git a/0011-nilfs2-Fixed-possible-sigsegv-in-case-of-corrupted-s.patch b/0011-nilfs2-Fixed-possible-sigsegv-in-case-of-corrupted-s.patch new file mode 100644 index 0000000..de1b0c5 --- /dev/null +++ b/0011-nilfs2-Fixed-possible-sigsegv-in-case-of-corrupted-s.patch @@ -0,0 +1,61 @@ +From 2fad7d827d27e75298f1d17b5fa6567ddfc4c338 Mon Sep 17 00:00:00 2001 +From: Anton Butenko +Date: Fri, 28 Feb 2025 16:09:18 +0100 +Subject: [PATCH 11/12] nilfs2: Fixed possible sigsegv in case of corrupted + superblock + +bytes value comes from the superblock and it must be at least as long as +s_sum which is a 32 bit value. So sumoff + 4 is the correct lower limit +for it, not sumoff - 4. + +Signed-off-by: Brian C. Lane +--- + libparted/fs/nilfs2/nilfs2.c | 2 +- + tests/t4301-nilfs2-badsb2.sh | 10 ++++++++-- + 2 files changed, 9 insertions(+), 3 deletions(-) + +diff --git a/libparted/fs/nilfs2/nilfs2.c b/libparted/fs/nilfs2/nilfs2.c +index 40f8567..74186f1 100644 +--- a/libparted/fs/nilfs2/nilfs2.c ++++ b/libparted/fs/nilfs2/nilfs2.c +@@ -88,7 +88,7 @@ is_valid_nilfs_sb(struct nilfs2_super_block *sb) + return 0; + + bytes = PED_LE16_TO_CPU(sb->s_bytes); +- if (bytes > 1024 || bytes < sumoff - 4) ++ if (bytes > 1024 || bytes < sumoff + 4) + return 0; + + crc = __efi_crc32(sb, sumoff, PED_LE32_TO_CPU(sb->s_crc_seed)); +diff --git a/tests/t4301-nilfs2-badsb2.sh b/tests/t4301-nilfs2-badsb2.sh +index 2a1205b..45b6644 100755 +--- a/tests/t4301-nilfs2-badsb2.sh ++++ b/tests/t4301-nilfs2-badsb2.sh +@@ -27,16 +27,22 @@ end=$(($len * 512 / $ss)) + parted -s $dev mklabel msdos mkpart primary 1s ${end}s || framework_failure_ + + # Write a secondary superblock with the nilfs magic number and a nilfs +-# superblock length (s_bytes) field of only 10 bytes. ++# superblock length (s_bytes) field of only 13 bytes. + # struct nilfs2_super_block starts with these four fields... + # uint32_t s_rev_level; + # uint16_t s_minor_rev_level; + # uint16_t s_magic; + # uint16_t s_bytes; + sb2_offset=$(( 24 / ($ss / 512) + 1)) +-perl -e "print pack 'LSSS.', 0, 0, 0x3434, 10, $ss" | ++perl -e "print pack 'LSSS.', 0, 0, 0x3434, 13, $ss" | + dd of=$dev bs=$ss seek=$sb2_offset count=1 conv=notrunc + ++# Write primary nilfs magic number and a nilfs ++# superblock length (s_bytes) field of only 13 bytes. ++sb_offset=3 ++perl -e "print pack 'LSSS.', 0, 0, 0x3434, 13, $ss" | ++ dd of=$dev bs=$ss seek=$sb_offset count=1 conv=notrunc ++ + # This used to give parted a sigsegv. + parted -s $dev print || fail=1 + +-- +2.49.0 + diff --git a/0012-doc-Fix-some-groff-mandoc-linting-complaints.patch b/0012-doc-Fix-some-groff-mandoc-linting-complaints.patch new file mode 100644 index 0000000..a846f6f --- /dev/null +++ b/0012-doc-Fix-some-groff-mandoc-linting-complaints.patch @@ -0,0 +1,90 @@ +From a2164c99b4d7d37334f9ca5ece55d8af95d002b7 Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Wed, 28 May 2025 13:09:32 -0700 +Subject: [PATCH 12/12] doc: Fix some groff/mandoc linting complaints + +--- + doc/C/parted.8 | 27 ++++++++++++--------------- + 1 file changed, 12 insertions(+), 15 deletions(-) + +diff --git a/doc/C/parted.8 b/doc/C/parted.8 +index 171269c..c852112 100644 +--- a/doc/C/parted.8 ++++ b/doc/C/parted.8 +@@ -54,7 +54,6 @@ Use optimum alignment as given by the disk topology information. This + aligns to a multiple of the physical block size in a way that guarantees + optimal performance. + .RE +- + .SH COMMANDS + .TP + .B [device] +@@ -62,8 +61,7 @@ The block device to be used. When none is given, \fBparted\fP will use the + first block device it finds. + .TP + .B [command [options]] +-Specifies the command to be executed. If no command is given, +-.BR parted ++Specifies the command to be executed. If no command is given, \fBparted\fP + will present a command prompt. Possible commands are: + .RS + .TP +@@ -119,8 +117,8 @@ or an LVM logical volume if necessary. + .B set \fIpartition\fP \fIflag\fP \fIstate\fP + Change the state of the \fIflag\fP on \fIpartition\fP to \fIstate\fP. + Supported flags are: "boot", "root", "swap", "hidden", "raid", "lvm", "lba", +-"legacy_boot", "irst", "msftres", "esp", "chromeos_kernel", "bls_boot", "linux-home", +-"no_automount", "bios_grub", and "palo". ++"legacy_boot", "irst", "msftres", "esp", "chromeos_kernel", "bls_boot", ++"linux-home", "no_automount", "bios_grub", and "palo". + \fIstate\fP should be either "on" or "off". + .TP + .B unit \fIunit\fP +@@ -140,10 +138,10 @@ On MS-DOS set the type aka. partition id of \fIpartition\fP to + the type-uuid of \fIpartition\fP to \fIuuid\fP. + .TP + .B disk_set \fIflag\fP \fIstate\fP +-Change a \fIflag\fP on the disk to \fIstate\fP. A flag can be either "on" or "off". +-Some or all of these flags will be available, depending on what disk label you +-are using. Supported flags are: "pmbr_boot" on GPT to enable the boot flag on the +-GPT's protective MBR partition. ++Change a \fIflag\fP on the disk to \fIstate\fP. A flag can be either "on" or ++"off". Some or all of these flags will be available, depending on what disk ++abel you are using. Supported flags are: "pmbr_boot" on GPT to enable the ++boot flag on the GPT's protective MBR partition. + .TP + .B disk_toggle \fIflag\fP + Toggle the state of the disk \fIflag\fP. +@@ -155,24 +153,23 @@ Display version information and a copyright message. + \fBparted\fP will compute sensible ranges for the locations you specify when using + units like "GB", "MB", etc. Use the sector unit "s" or IEC binary units like + "GiB", "MiB", to specify exact locations. +- + When you specify start or end values using IEC binary units like "MiB", + "GiB", "TiB", etc., \fBparted\fP treats those values as exact, and equivalent to + the same number specified in bytes (i.e., with the "B" suffix), in that it + provides no helpful range of sloppiness. Contrast that with a partition + start request of "4GB", which may actually resolve to some sector up to 500MB +-before or after that point. Thus, when creating a partition in an exact location +-you should use units of bytes ("B"), sectors ("s"), or IEC binary units like +-"MiB", "GiB", but not "MB", "GB", etc. ++before or after that point. Thus, when creating a partition in an exact ++location you should use units of bytes ("B"), sectors ("s"), or IEC binary units ++like "MiB", "GiB", but not "MB", "GB", etc. + .SH REPORTING BUGS + Report bugs to + .SH SEE ALSO + .BR fdisk (8), + .BR mkfs (8), + The \fIparted\fP program is fully documented in the +-.BR info(1) ++.BR info (1) + format +-.IR "GNU partitioning software" ++.I "GNU partitioning software" + manual. + .SH AUTHOR + This manual page was written by Timshel Knoll , +-- +2.49.0 + diff --git a/parted.spec b/parted.spec index c0203d1..31ea054 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 11%{?dist} +Release: 12%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -18,6 +18,10 @@ Patch0005: 0005-libparted-Fix-sun-disklabel-unhandled-exception.patch Patch0006: 0006-tests-Add-test-for-SUN-disklabel-handling.patch Patch0007: 0007-libparted-Fix-dvh-disklabel-unhandled-exception.patch Patch0008: 0008-tests-Add-test-for-dvh-with-a-bad-checksum.patch +Patch0009: 0009-tests-probing-ext4-without-journal-should-still-indi.patch +Patch0010: 0010-libparted-Do-not-detect-ext4-without-journal-as-ext2.patch +Patch0011: 0011-nilfs2-Fixed-possible-sigsegv-in-case-of-corrupted-s.patch +Patch0012: 0012-doc-Fix-some-groff-mandoc-linting-complaints.patch BuildRequires: gcc BuildRequires: e2fsprogs-devel @@ -122,6 +126,12 @@ make check %changelog +* Fri May 30 2025 Brian C. Lane - 3.6-12 +- doc: Fix some groff/mandoc linting complaints (bcl) +- nilfs2: Fixed possible sigsegv in case of corrupted superblock (abutenko) +- libparted: Do not detect ext4 without journal as ext2 (pascal) +- tests: probing ext4 without journal should still indicate ext4 (bcl) + * Fri Jan 17 2025 Fedora Release Engineering - 3.6-11 - Rebuilt for https://fedoraproject.org/wiki/Fedora_42_Mass_Rebuild From 66c2ad5f018ccccbdaa60f883675cf6c0243aba7 Mon Sep 17 00:00:00 2001 From: Fedora Release Engineering Date: Thu, 24 Jul 2025 23:58:58 +0000 Subject: [PATCH 23/23] Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild --- parted.spec | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/parted.spec b/parted.spec index 31ea054..7948ba4 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.6 -Release: 12%{?dist} +Release: 13%{?dist} License: GPL-3.0-or-later URL: http://www.gnu.org/software/parted @@ -126,6 +126,9 @@ make check %changelog +* Thu Jul 24 2025 Fedora Release Engineering - 3.6-13 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_43_Mass_Rebuild + * Fri May 30 2025 Brian C. Lane - 3.6-12 - doc: Fix some groff/mandoc linting complaints (bcl) - nilfs2: Fixed possible sigsegv in case of corrupted superblock (abutenko)