diff --git a/0035-hurd-Fix-partition-paths.patch b/0035-hurd-Fix-partition-paths.patch new file mode 100644 index 0000000..80a6ecb --- /dev/null +++ b/0035-hurd-Fix-partition-paths.patch @@ -0,0 +1,29 @@ +From dde6702f20b7c34b091b25580ab19009c9d91b30 Mon Sep 17 00:00:00 2001 +From: Colin Watson +Date: Thu, 26 Nov 2020 21:59:39 +0100 +Subject: [PATCH 35/38] hurd: Fix partition paths + +We have always had an 's' to separate drive number from partition +number. + +Signed-off-by: Brian C. Lane +--- + libparted/arch/gnu.c | 2 +- + 1 file changed, 1 insertion(+), 1 deletion(-) + +diff --git a/libparted/arch/gnu.c b/libparted/arch/gnu.c +index d7204cc..507a5ff 100644 +--- a/libparted/arch/gnu.c ++++ b/libparted/arch/gnu.c +@@ -805,7 +805,7 @@ gnu_partition_get_path (const PedPartition* part) + result = (char*) ped_malloc (result_len); + if (!result) + return NULL; +- snprintf (result, result_len, "%s%d", dev_path, part->num); ++ snprintf (result, result_len, "%ss%d", dev_path, part->num); + return result; + } + +-- +2.31.1 + diff --git a/0036-hurd-Support-rumpdisk-based-device-names.patch b/0036-hurd-Support-rumpdisk-based-device-names.patch new file mode 100644 index 0000000..6b14e30 --- /dev/null +++ b/0036-hurd-Support-rumpdisk-based-device-names.patch @@ -0,0 +1,33 @@ +From e0a83f3bdf6cfb4b2b6d3631a5ab157291bfbdfa Mon Sep 17 00:00:00 2001 +From: Samuel Thibault +Date: Sun, 29 Nov 2020 23:20:17 +0100 +Subject: [PATCH 36/38] hurd: Support rumpdisk-based device names + +Signed-off-by: Brian C. Lane +--- + libparted/arch/gnu.c | 9 +++++++++ + 1 file changed, 9 insertions(+) + +diff --git a/libparted/arch/gnu.c b/libparted/arch/gnu.c +index 507a5ff..0797115 100644 +--- a/libparted/arch/gnu.c ++++ b/libparted/arch/gnu.c +@@ -786,6 +786,15 @@ probe_standard_devices () + _ped_device_probe ("/dev/hd6"); + _ped_device_probe ("/dev/hd7"); + ++ _ped_device_probe ("/dev/wd0"); ++ _ped_device_probe ("/dev/wd1"); ++ _ped_device_probe ("/dev/wd2"); ++ _ped_device_probe ("/dev/wd3"); ++ _ped_device_probe ("/dev/wd4"); ++ _ped_device_probe ("/dev/wd5"); ++ _ped_device_probe ("/dev/wd6"); ++ _ped_device_probe ("/dev/wd7"); ++ + return 1; + } + +-- +2.31.1 + diff --git a/0037-hurd-Implement-partition-table-rereading.patch b/0037-hurd-Implement-partition-table-rereading.patch new file mode 100644 index 0000000..ccb756e --- /dev/null +++ b/0037-hurd-Implement-partition-table-rereading.patch @@ -0,0 +1,135 @@ +From c16cb23bf91cf3255e2cf8ea596fe5e1b4ea1ad5 Mon Sep 17 00:00:00 2001 +From: Colin Watson +Date: Sun, 29 Nov 2020 23:19:23 +0100 +Subject: [PATCH 37/38] hurd: Implement partition table rereading + +We have to tell both the device for the drive itself, it case it +implements the partitioned devices, and tell the partition devices +to go away, in case they are implemented on their own by using parted. + +Signed-off-by: Brian C. Lane +--- + libparted/arch/gnu.c | 84 ++++++++++++++++++++++++++++++++++++++++---- + 1 file changed, 78 insertions(+), 6 deletions(-) + +diff --git a/libparted/arch/gnu.c b/libparted/arch/gnu.c +index 0797115..b040c45 100644 +--- a/libparted/arch/gnu.c ++++ b/libparted/arch/gnu.c +@@ -185,7 +185,7 @@ _init_device (const char *path) + if (!dev->arch_specific) + goto error_free_path; + +- dev->type = PED_DEVICE_FILE; /* FIXME? */ ++ dev->type = PED_DEVICE_UNKNOWN; /* It's deprecated anyway */ + dev->open_count = 0; + dev->read_only = 0; + dev->external_mode = 0; +@@ -204,11 +204,83 @@ error: + return NULL; + } + ++/* Ask the kernel and translators to reload the partition table. ++ XXX: Will probably be replaced by some RPC to partfs when it's finished. In ++ the meantime, gnumach's glue layer will pass BLKRRPART to the Linux drivers. ++ */ ++#define BLKRRPART 0x125F + static int +-_kernel_reread_part_table (PedDevice* dev) ++_reread_part_table (PedDevice* dev) + { +- /* XXX: We must wait for partfs to be finished. */ +- return 1; ++ struct store *store = GNU_SPECIFIC (dev)->store; ++ int retry_count = 9; ++ int len = strlen (dev->path); ++ char path[len + 3 + 1]; ++ int i; ++ int done = 1; ++ ++ sync (); ++ ++ if(strcmp (store->class->name, "device") == 0) { ++ while (device_set_status (store->port, BLKRRPART, NULL, 0)) { ++ retry_count--; ++ sync (); ++ if (retry_count == 3) ++ sleep (1); /* Pause to allow system to settle */ ++ ++ if (!retry_count) { ++ ped_exception_throw ( ++ PED_EXCEPTION_WARNING, ++ PED_EXCEPTION_IGNORE, ++ _("WARNING: the kernel failed to re-read the " ++ "partition table on %s (%s). As a result, " ++ "it may not reflect all of your changes " ++ "until after reboot."), ++ dev->path, strerror (errno)); ++ return 0; ++ } ++ } ++ } ++ ++ i = 1; ++ while (1) { ++ file_t node; ++ error_t err; ++ ++ /* Throw away all active parted-based translators */ ++ snprintf (path, sizeof (path), "%ss%u", dev->path, i); ++ node = file_name_lookup (path, O_NOTRANS, 0666); ++ if (node == MACH_PORT_NULL) { ++ if (errno == ENOENT) ++ /* Finished looping over them */ ++ break; ++ ++ ped_exception_throw ( ++ PED_EXCEPTION_WARNING, ++ PED_EXCEPTION_IGNORE, ++ _("Warning: unable to open %s (%s). As a " ++ "result, it may not reflect all of your " ++ "changes until after reboot."), ++ path, strerror (errno)); ++ done = 0; ++ } ++ ++ err = file_set_translator (node, 0, FS_TRANS_SET, ++ 0, 0, 0, MACH_PORT_NULL, MACH_MSG_TYPE_COPY_SEND); ++ if (err) { ++ ped_exception_throw ( ++ PED_EXCEPTION_WARNING, ++ PED_EXCEPTION_IGNORE, ++ _("Warning: failed to make translator go away " ++ "on %s (%s). As a result, it may not reflect " ++ "all of your changes until after reboot."), ++ dev->path, strerror (errno)); ++ done = 0; ++ } ++ i++; ++ } ++ ++ return done; + } + + /* Free the memory associated with a PedDevice structure. */ +@@ -355,7 +427,7 @@ gnu_close (PedDevice* dev) + _flush_cache (dev); + + if (dev->dirty && dev->type != PED_DEVICE_FILE) { +- if (_kernel_reread_part_table (dev)) ++ if (_reread_part_table (dev)) + dev->dirty = 0; + } + +@@ -827,7 +899,7 @@ gnu_partition_is_busy (const PedPartition* part) + static int + gnu_disk_commit (PedDisk* disk) + { +- return 1; ++ return _reread_part_table (disk->dev); + } + + static PedDeviceArchOps gnu_dev_ops = { +-- +2.31.1 + diff --git a/0038-keep-GUID-specific-attributes.patch b/0038-keep-GUID-specific-attributes.patch new file mode 100644 index 0000000..617868e --- /dev/null +++ b/0038-keep-GUID-specific-attributes.patch @@ -0,0 +1,283 @@ +From 9d1ac5015340aa7a4cc71cb7f63bae8c1718b8ee Mon Sep 17 00:00:00 2001 +From: Arvin Schnell +Date: Thu, 23 Sep 2021 16:31:42 +0000 +Subject: [PATCH 38/38] keep GUID specific attributes + +Keep GUID specific attributes when writing GPT. + +Signed-off-by: Brian C. Lane +--- + libparted/labels/gpt.c | 30 +++++------------ + tests/Makefile.am | 3 +- + tests/gpt-attrs | 72 ++++++++++++++++++++++++++++++++++++++++ + tests/t0215-gpt-attrs.sh | 46 +++++++++++++++++++++++++ + 4 files changed, 129 insertions(+), 22 deletions(-) + create mode 100755 tests/gpt-attrs + create mode 100644 tests/t0215-gpt-attrs.sh + +diff --git a/libparted/labels/gpt.c b/libparted/labels/gpt.c +index 9b987c1..ba9a71a 100644 +--- a/libparted/labels/gpt.c ++++ b/libparted/labels/gpt.c +@@ -297,18 +297,17 @@ typedef struct _GPTPartitionData + efi_guid_t uuid; + efi_char16_t name[37]; + char *translated_name; ++ GuidPartitionEntryAttributes_t attributes; + int lvm; + int swap; + int raid; + int boot; + int bios_grub; + int hp_service; +- int hidden; + int msftres; + int msftdata; + int atvrecv; + int msftrecv; +- int legacy_boot; + int prep; + int irst; + int chromeos_kernel; +@@ -826,25 +825,20 @@ _parse_part_entry (PedDisk *disk, GuidPartitionEntry_t *pte) + gpt_part_data->name[i] = (efi_char16_t) pte->PartitionName[i]; + gpt_part_data->name[i] = 0; + gpt_part_data->translated_name = 0; ++ gpt_part_data->attributes = pte->Attributes; + + gpt_part_data->lvm = gpt_part_data->swap + = gpt_part_data->raid + = gpt_part_data->boot = gpt_part_data->hp_service +- = gpt_part_data->hidden = gpt_part_data->msftres ++ = gpt_part_data->msftres + = gpt_part_data->msftdata + = gpt_part_data->msftrecv +- = gpt_part_data->legacy_boot + = gpt_part_data->prep + = gpt_part_data->irst + = gpt_part_data->chromeos_kernel + = gpt_part_data->bls_boot + = gpt_part_data->bios_grub = gpt_part_data->atvrecv = 0; + +- if (pte->Attributes.RequiredToFunction & 0x1) +- gpt_part_data->hidden = 1; +- if (pte->Attributes.LegacyBIOSBootable & 0x1) +- gpt_part_data->legacy_boot = 1; +- + if (!guid_cmp (gpt_part_data->type, PARTITION_SYSTEM_GUID)) + gpt_part_data->boot = 1; + else if (!guid_cmp (gpt_part_data->type, PARTITION_BIOS_GRUB_GUID)) +@@ -1241,12 +1235,7 @@ _partition_generate_part_entry (PedPartition *part, GuidPartitionEntry_t *pte) + pte->UniquePartitionGuid = gpt_part_data->uuid; + pte->StartingLBA = PED_CPU_TO_LE64 (part->geom.start); + pte->EndingLBA = PED_CPU_TO_LE64 (part->geom.end); +- memset (&pte->Attributes, 0, sizeof (GuidPartitionEntryAttributes_t)); +- +- if (gpt_part_data->hidden) +- pte->Attributes.RequiredToFunction = 1; +- if (gpt_part_data->legacy_boot) +- pte->Attributes.LegacyBIOSBootable = 1; ++ pte->Attributes = gpt_part_data->attributes; + + for (i = 0; i < 36; i++) + pte->PartitionName[i] = gpt_part_data->name[i]; +@@ -1388,12 +1377,10 @@ gpt_partition_new (const PedDisk *disk, + gpt_part_data->boot = 0; + gpt_part_data->bios_grub = 0; + gpt_part_data->hp_service = 0; +- gpt_part_data->hidden = 0; + gpt_part_data->msftres = 0; + gpt_part_data->msftdata = 0; + gpt_part_data->msftrecv = 0; + gpt_part_data->atvrecv = 0; +- gpt_part_data->legacy_boot = 0; + gpt_part_data->prep = 0; + gpt_part_data->translated_name = 0; + gpt_part_data->irst = 0; +@@ -1402,6 +1389,7 @@ gpt_partition_new (const PedDisk *disk, + uuid_generate ((unsigned char *) &gpt_part_data->uuid); + swap_uuid_and_efi_guid (&gpt_part_data->uuid); + memset (gpt_part_data->name, 0, sizeof gpt_part_data->name); ++ memset (&gpt_part_data->attributes, 0, sizeof gpt_part_data->attributes); + return part; + + error_free_part: +@@ -1911,10 +1899,10 @@ gpt_partition_set_flag (PedPartition *part, PedPartitionFlag flag, int state) + = gpt_part_data->atvrecv = 0; + return gpt_partition_set_system (part, part->fs_type); + case PED_PARTITION_HIDDEN: +- gpt_part_data->hidden = state; ++ gpt_part_data->attributes.RequiredToFunction = state; + return 1; + case PED_PARTITION_LEGACY_BOOT: +- gpt_part_data->legacy_boot = state; ++ gpt_part_data->attributes.LegacyBIOSBootable = state; + return 1; + case PED_PARTITION_ROOT: + case PED_PARTITION_LBA: +@@ -1953,9 +1941,9 @@ gpt_partition_get_flag (const PedPartition *part, PedPartitionFlag flag) + case PED_PARTITION_APPLE_TV_RECOVERY: + return gpt_part_data->atvrecv; + case PED_PARTITION_HIDDEN: +- return gpt_part_data->hidden; ++ return gpt_part_data->attributes.RequiredToFunction; + case PED_PARTITION_LEGACY_BOOT: +- return gpt_part_data->legacy_boot; ++ return gpt_part_data->attributes.LegacyBIOSBootable; + case PED_PARTITION_PREP: + return gpt_part_data->prep; + case PED_PARTITION_IRST: +diff --git a/tests/Makefile.am b/tests/Makefile.am +index f9340aa..3dc6e72 100644 +--- a/tests/Makefile.am ++++ b/tests/Makefile.am +@@ -26,6 +26,7 @@ TESTS = \ + t0211-gpt-rewrite-header.sh \ + t0212-gpt-many-partitions.sh \ + t0213-mkpart-start-negative.sh \ ++ t0215-gpt-attrs.sh \ + t0220-gpt-msftres.sh \ + t0250-gpt.sh \ + t0251-gpt-unicode.sh \ +@@ -98,7 +99,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-header-move msdos-overlap gpt-attrs + + check_PROGRAMS = print-align print-flags print-max dup-clobber duplicate \ + fs-resize +diff --git a/tests/gpt-attrs b/tests/gpt-attrs +new file mode 100755 +index 0000000..0a01447 +--- /dev/null ++++ b/tests/gpt-attrs +@@ -0,0 +1,72 @@ ++#!/usr/bin/python3 ++ ++# Copyright (C) 2021 SUSE LLC ++ ++# program to show gpt partition attributes or set attributes of ++# partition 1 ++ ++# only works with 512 sectors and standard GPT header layout (128 ++# partition entires with 128 bytes each, secondary header at end of ++# device) ++ ++ ++from struct import unpack_from, pack_into ++from zipfile import crc32 ++import array ++import sys ++ ++ ++class Gpt: ++ ++ # Calculate and insert the CRCs of the partition entires and the ++ # header. ++ def calc_crcs(self, header, entries): ++ # compute crc of partition entries ++ crc2 = crc32(entries) & 0xFFFFFFFF ++ pack_into('. ++ ++. "${srcdir=.}/init.sh"; path_prepend_ ../parted $srcdir ++require_512_byte_sector_size_ ++ ++dev=loop-file ++ ++# create device ++truncate --size 50MiB "$dev" || fail=1 ++ ++# create gpt label and one partitions ++parted --script "$dev" mklabel gpt > out 2>&1 || fail=1 ++parted --script "$dev" mkpart "test1" ext4 0% 10% > out 2>&1 || fail=1 ++ ++# set guid specific bit ++gpt-attrs "$dev" set 0x100000000000000 || fail=1 ++ ++# create additional partition ++parted --script "$dev" mkpart "test2" ext4 10% 20% > out 2>&1 || fail=1 ++ ++cat < exp || fail=1 ++0x100000000000000 ++EOF ++ ++# check guid specific bit ++gpt-attrs "$dev" show > out || fail=1 ++compare exp out || fail=1 ++ ++Exit $fail +-- +2.31.1 + diff --git a/parted.spec b/parted.spec index 0cf7d08..18bb61a 100644 --- a/parted.spec +++ b/parted.spec @@ -45,6 +45,10 @@ Patch0031: 0031-libparted-Tell-libdevmapper-to-retry-remove-when-BUS.patch Patch0032: 0032-libparted-Check-devpath-before-passing-to-strlen.patch Patch0033: 0033-parted-Allow-empty-string-for-partition-name.patch Patch0034: 0034-parted-Add-json-cmdline-switch-to-output-JSON.patch +Patch0035: 0035-hurd-Fix-partition-paths.patch +Patch0036: 0036-hurd-Support-rumpdisk-based-device-names.patch +Patch0037: 0037-hurd-Implement-partition-table-rereading.patch +Patch0038: 0038-keep-GUID-specific-attributes.patch BuildRequires: gcc BuildRequires: e2fsprogs-devel @@ -148,6 +152,12 @@ make check %changelog +* Thu Sep 23 2021 Brian C. Lane - 3.4-8 +- 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)