Sync from SUSE:SLFO:Main parted revision dc5588dbfd804708f468eb1571b92f4f

This commit is contained in:
Adrian Schröter 2024-05-03 17:42:04 +02:00
commit 6807ecc80c
40 changed files with 5141 additions and 0 deletions

23
.gitattributes vendored Normal file
View File

@ -0,0 +1,23 @@
## Default LFS
*.7z filter=lfs diff=lfs merge=lfs -text
*.bsp filter=lfs diff=lfs merge=lfs -text
*.bz2 filter=lfs diff=lfs merge=lfs -text
*.gem filter=lfs diff=lfs merge=lfs -text
*.gz filter=lfs diff=lfs merge=lfs -text
*.jar filter=lfs diff=lfs merge=lfs -text
*.lz filter=lfs diff=lfs merge=lfs -text
*.lzma filter=lfs diff=lfs merge=lfs -text
*.obscpio filter=lfs diff=lfs merge=lfs -text
*.oxt filter=lfs diff=lfs merge=lfs -text
*.pdf filter=lfs diff=lfs merge=lfs -text
*.png filter=lfs diff=lfs merge=lfs -text
*.rpm filter=lfs diff=lfs merge=lfs -text
*.tbz filter=lfs diff=lfs merge=lfs -text
*.tbz2 filter=lfs diff=lfs merge=lfs -text
*.tgz filter=lfs diff=lfs merge=lfs -text
*.ttf filter=lfs diff=lfs merge=lfs -text
*.txz filter=lfs diff=lfs merge=lfs -text
*.whl filter=lfs diff=lfs merge=lfs -text
*.xz filter=lfs diff=lfs merge=lfs -text
*.zip filter=lfs diff=lfs merge=lfs -text
*.zst filter=lfs diff=lfs merge=lfs -text

4
baselibs.conf Normal file
View File

@ -0,0 +1,4 @@
libparted2
obsoletes "parted-<targettype> <= 2.3.10"
provides "parted-<targettype> = <version>"
libparted-fs-resize0

View File

@ -0,0 +1,557 @@
From 1d798715b5998cd4afd184beb88ebdbe1a2642e8 Mon Sep 17 00:00:00 2001
From: Arvin Schnell <aschnell@suse.de>
Date: Thu, 14 Oct 2021 16:29:06 +0200
Subject: [PATCH] allow direct handling of partition type id and uuid
---
include/parted/disk.in.h | 23 +++++-
libparted/disk.c | 86 ++++++++++++++++++++++
libparted/labels/dasd.c | 4 ++
libparted/labels/dos.c | 30 +++++++-
libparted/labels/gpt.c | 40 ++++++++++-
parted/parted.c | 146 +++++++++++++++++++++++++++++++++++++-
tests/t0800-json-gpt.sh | 2 +
tests/t0801-json-msdos.sh | 5 +-
8 files changed, 329 insertions(+), 7 deletions(-)
diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h
index 303f59c..d7fde12 100644
--- a/include/parted/disk.in.h
+++ b/include/parted/disk.in.h
@@ -32,6 +32,7 @@
*/
#include <stdlib.h>
#include <unistd.h>
+#include <stdint.h>
/**
* Disk flags
@@ -91,9 +92,11 @@ enum _PedPartitionFlag {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
PED_DISK_TYPE_PARTITION_NAME=2, /**< supports partition names */
- PED_DISK_TYPE_SYSTEM_NAME=4 /**< supports system names */
+ PED_DISK_TYPE_SYSTEM_NAME=4, /**< supports system names */
+ PED_DISK_TYPE_PARTITION_TYPE_ID=8, /**< supports partition type-ids */
+ PED_DISK_TYPE_PARTITION_TYPE_UUID=16, /**< supports partition type-uuids */
};
#define PED_DISK_TYPE_FIRST_FEATURE PED_DISK_TYPE_EXTENDED
-#define PED_DISK_TYPE_LAST_FEATURE PED_DISK_TYPE_SYSTEM_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,10 @@ extern int ped_partition_set_system (PedPartition* part,
extern int ped_partition_set_system_name (PedPartition* part, const char* name);
extern const char* ped_partition_get_name (const PedPartition* part);
extern const char* ped_partition_get_system_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 8496fc0..80f3154 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,62 @@ ped_partition_get_name (const PedPartition* part)
return part->disk->type->ops->partition_get_name (part);
}
+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);
+}
+
+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);
+}
+
+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);
+}
+
+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 6b0b10d..1747202 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,
disk_set_flag: dasd_disk_set_flag,
disk_get_flag: dasd_disk_get_flag,
disk_is_flag_available: dasd_disk_is_flag_available,
diff --git a/libparted/labels/dos.c b/libparted/labels/dos.c
index b44ccaf..44c8cfc 100644
--- a/libparted/labels/dos.c
+++ b/libparted/labels/dos.c
@@ -1754,6 +1754,30 @@ msdos_partition_is_flag_available (const PedPartition* part,
}
}
+
+int
+msdos_partition_set_type_id (PedPartition *part, uint8_t id)
+{
+ DosPartitionData *dos_part_data = part->disk_specific;
+
+ dos_part_data->system = id;
+
+ // TODO set the correct flag but there is no function for that. better cleanup flags
+ // and use system directly (like in gpt.c)
+
+ return 1;
+}
+
+
+uint8_t _GL_ATTRIBUTE_PURE
+msdos_partition_get_type_id (const PedPartition *part)
+{
+ const DosPartitionData *dos_part_data = part->disk_specific;
+
+ return dos_part_data->system;
+}
+
+
static PedGeometry*
_try_constraint (const PedPartition* part, const PedConstraint* external,
PedConstraint* internal)
@@ -2590,6 +2614,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 +2626,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 c5d7bb3..db18790 100644
--- a/libparted/labels/gpt.c
+++ b/libparted/labels/gpt.c
@@ -1685,6 +1685,45 @@ 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)
{
@@ -1780,6 +1814,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,
@@ -1792,7 +1830,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 310f011..f840037 100644
--- a/parted/parted.c
+++ b/parted/parted.c
@@ -19,6 +19,7 @@
#include <config.h>
#include <stdbool.h>
+#include <uuid/uuid.h>
#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_id_msg = N_("TYPE_ID is a value between 0x01 and 0xff\n");
+static const char* type_uuid_msg = N_("TYPE_UUID is a non-null uuid\n");
static const char* copyright_msg = N_(
"Copyright (C) 1998 - 2006 Free Software Foundation, Inc.\n"
@@ -917,6 +920,110 @@ error:
return 0;
}
+static int
+do_type_id (PedDevice** dev, PedDisk** diskp)
+{
+ PedPartition* part = NULL;
+ char* input = NULL;
+
+ if (!*diskp)
+ *diskp = ped_disk_new (*dev);
+ if (!*diskp)
+ goto error;
+
+ if (!ped_disk_type_check_feature((*diskp)->type, PED_DISK_TYPE_PARTITION_TYPE_ID)) {
+ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+ _("%s disk labels do not support partition type-id."),
+ (*diskp)->type->name);
+ goto error;
+ }
+
+ if (!command_line_get_partition (_("Partition number?"), *diskp, &part))
+ goto error;
+
+ 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, 0);
+ if (tmp == 0 || tmp > 0xff) {
+ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+ _("Invalid id."));
+ goto error;
+ }
+
+ if (!ped_partition_set_type_id (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 int
+do_type_uuid (PedDevice** dev, PedDisk** diskp)
+{
+ PedPartition* part = NULL;
+ char* input = NULL;
+
+ if (!*diskp)
+ *diskp = ped_disk_new (*dev);
+ if (!*diskp)
+ goto error;
+
+ if (!ped_disk_type_check_feature((*diskp)->type, PED_DISK_TYPE_PARTITION_TYPE_UUID)) {
+ ped_exception_throw (PED_EXCEPTION_ERROR, PED_EXCEPTION_CANCEL,
+ _("%s disk labels do not support partition type-uuid."),
+ (*diskp)->type->name);
+ goto error;
+ }
+
+ if (!command_line_get_partition (_("Partition number?"), *diskp, &part))
+ goto error;
+
+ 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 uuid."));
+ goto error;
+ }
+
+ 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)
{
@@ -1161,6 +1268,8 @@ do_print (PedDevice** dev, PedDisk** diskp)
Table* table;
int has_extended;
int has_name;
+ int has_id;
+ int has_uuid;
int has_devices_arg = 0;
int has_free_arg = 0;
int has_list_arg = 0;
@@ -1270,6 +1379,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);
+ has_id = ped_disk_type_check_feature ((*diskp)->type,
+ PED_DISK_TYPE_PARTITION_TYPE_ID);
+ has_uuid = ped_disk_type_check_feature ((*diskp)->type,
+ PED_DISK_TYPE_PARTITION_TYPE_UUID);
PedPartition* part;
if (opt_output_mode == HUMAN) {
@@ -1407,6 +1520,21 @@ do_print (PedDevice** dev, PedDisk** diskp)
if (!(part->type & PED_PARTITION_FREESPACE)) {
+ if (has_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_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)
@@ -2218,6 +2346,22 @@ _("name NUMBER NAME name partition NUMBER as NAME"),
NULL),
str_list_create (_(number_msg), _(name_msg), NULL), 1));
+command_register (commands, command_create (
+ str_list_create_unique ("type-id", _("type-id"), NULL),
+ do_type_id,
+ str_list_create (
+_("type-id NUMBER TYPE-ID type-id set TYPE-ID of partition NUMBER"),
+NULL),
+ str_list_create (_(number_msg), _(type_id_msg), NULL), 1));
+
+command_register (commands, command_create (
+ str_list_create_unique ("type-uuid", _("type-uuid"), NULL),
+ do_type_uuid,
+ str_list_create (
+_("type-uuid NUMBER TYPE-UUID type-uuid set TYPE-UUID of partition NUMBER"),
+NULL),
+ str_list_create (_(number_msg), _(type_uuid_msg), NULL), 1));
+
command_register (commands, command_create (
str_list_create_unique ("print", _("print"), NULL),
do_print,
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 <<EOF > 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 <<EOF > 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 <<EOF > 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 <<EOF > exp || fail=1
"end": "20.0MiB",
"size": "10.0MiB",
"type": "logical",
+ "type-id": "0x8e",
"flags": [
"lvm"
]

View File

@ -0,0 +1,32 @@
From: Petr Uzel <petr.uzel@suse.cz>
Subject: parted: dos: Wipe boot code only on x86
Patch-mainline: no, custom SUSE patch
---
libparted/labels/dos.c | 7 +++++++
1 file changed, 7 insertions(+)
Index: parted-3.3/libparted/labels/dos.c
===================================================================
--- parted-3.3.orig/libparted/labels/dos.c
+++ parted-3.3/libparted/labels/dos.c
@@ -1287,6 +1287,12 @@ msdos_write (const PedDisk* disk)
return 0;
DosRawTable *table = (DosRawTable *) s0;
+/*
+ * Some ARM devices, such as the OMAP3 series, have a buggy boot rom that
+ * simply goes into nirvana if it finds non-0 in the first 4 bytes of the SD
+ * card.
+ */
+#if defined(__x86_64__) || defined(__i386__)
/* either no bootrecord at all, or AIX IPL signature ... */
if ( (!table->boot_code[0]) ||
( table->boot_code[0] == (char) 0xc9 &&
@@ -1297,6 +1303,7 @@ msdos_write (const PedDisk* disk)
memset (table, 0, 512);
memcpy (table->boot_code, MBR_BOOT_CODE, sizeof (MBR_BOOT_CODE));
}
+#endif
/* If there is no unique identifier, generate a random one */
if (!table->mbr_signature)

BIN
fatresize-0.1.tar.bz2 (Stored with Git LFS) Normal file

Binary file not shown.

View File

@ -0,0 +1,73 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Sun, 3 Dec 2017 12:09:44 +0100
Subject: Fix getting the device name from partition name
References: boo#959181
Patch-mainline: submitted, https://github.com/ya-mouse/fatresize/pull/4
There are many partition device names like e.g. /dev/mmcblk0p1 where
it is not enough to trim the trailing digits to get the disk device
name. Using open() here would depend on a POSIX platform. So do it
like _ped_device_probe() and silence libparted exceptions and try
to get the device with ped_device_get(). Trim further trailing
characters until libparted finds it. Print an error and exit if
the partition name is invalid.
Fixes #2
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
fatresize/fatresize.c | 29 +++++++++++++++++++++++++++++
1 file changed, 29 insertions(+)
--- a/fatresize/fatresize.c
+++ b/fatresize/fatresize.c
@@ -9,6 +9,7 @@
#include <unistd.h>
#include <ctype.h>
+#include <parted/parted.h>
#include <parted/device.h>
#include <parted/filesys.h>
@@ -79,6 +80,18 @@ resize(const char* disk_device, int part
}
+/* Code parts have been taken from _ped_device_probe(). */
+static void
+probe_device(PedDevice **dev, const char *path)
+{
+ ped_exception_fetch_all();
+ *dev = ped_device_get(path);
+ if (!*dev)
+ ped_exception_catch();
+ ped_exception_leave_all();
+}
+
+
int
main(int argc, char** argv)
{
@@ -126,6 +139,22 @@ main(int argc, char** argv)
disk_device = strndup(argv[1], pos - argv[1] + 1);
partition_number = strtol(pos + 1, NULL, 10);
+ PedDevice *peddev = NULL;
+ /* check if the device really exists */
+ while (pos != argv[1] && *pos != '/' && !peddev)
+ {
+ disk_device[pos - argv[1] + 1] = '\0';
+ probe_device(&peddev, disk_device);
+ --pos;
+ }
+ if (!peddev)
+ {
+ free(disk_device);
+ fprintf(stderr, "invalid device\n");
+ exit(EXIT_FAILURE);
+ }
+ ped_device_destroy(peddev);
+
if (argc == 3)
{
char* endptr = NULL;

31
hfs_fix.dif Normal file
View File

@ -0,0 +1,31 @@
---
libparted/labels/mac.c | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
Index: parted-3.3/libparted/labels/mac.c
===================================================================
--- parted-3.3.orig/libparted/labels/mac.c
+++ parted-3.3/libparted/labels/mac.c
@@ -468,7 +468,7 @@ _rawpart_is_void (MacRawPartition* raw_p
return _rawpart_cmp_type (raw_part, "Apple_Void");
}
-/* returns 1 if the raw_part represents a partition that is "unused space", or
+/* returns 0 if the raw_part represents a partition that is "unused space", or
* doesn't represent a partition at all. NOTE: some people make Apple_Free
* partitions with MacOS, because they can't select another type. So, if the
* name is anything other than "Extra" or "", it is treated as a "real"
@@ -531,6 +531,13 @@ _rawpart_analyse (MacRawPartition* raw_p
if (!part)
goto error;
+ /* Check for Apple_Free and set type to PED_PARTITION_FREESPACE */
+ if (_rawpart_cmp_type (raw_part, "Apple_Free")
+ && (strcmp (raw_part->name, "Extra") == 0))
+ part->type = PED_PARTITION_FREESPACE;
+ else
+ part->type = PED_PARTITION_NORMAL;
+
mac_part_data = part->disk_specific;
strncpy (mac_part_data->volume_name, raw_part->name, 32);

View File

@ -0,0 +1,24 @@
From: Petr Uzel <petr.uzel@suse.cz>
Subject: libparted: Avoid libdevice-mapper warnings
Patch-mainline: no, custom SUSE patch
---
libparted/arch/linux.c | 6 ++++++
1 file changed, 6 insertions(+)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -2852,6 +2852,12 @@ _dm_remove_partition(PedDisk* disk, int
goto err;
}
close (fd);
+ /* After we closed the fd, udev starts sniffing it, rendering the device busy for a moment
+ * This is not fatal since we're going to retry anyway, but produces bogus warnings
+ * from libdevice-mapper.
+ * Avoid this by giving udev a moment to release the device
+ */
+ usleep(100000);
struct dm_task *task = dm_task_create(DM_DEVICE_REMOVE);
if (!task)
goto err;

View File

@ -0,0 +1,36 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Mon, 19 Feb 2018 17:45:32 +0100
Subject: libparted: Canonicalize /dev/md/ paths
References: bsc#1078820
Patch-mainline: submitted, 2018-02-20
The BLKPG* ioctl handling relies on getting the current partitions
from /sys/block/$devname/. With an md name like e.g. "vol0", the
block device to be used cannot be found and the BLKPG* ioctls are
used for all partitions. So canonicalize /dev/md/ paths as well.
Test: t6100-mdraid-partitions
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/device.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/libparted/device.c b/libparted/device.c
index 36fecd2..2fd3c2f 100644
--- a/libparted/device.c
+++ b/libparted/device.c
@@ -152,11 +152,8 @@ ped_device_get (const char* path)
char* normal_path = NULL;
PED_ASSERT (path != NULL);
- /* Don't canonicalize /dev/mapper or /dev/md/ paths, see
- tests/symlink.c
- */
- if (strncmp (path, "/dev/mapper/", 12) &&
- strncmp (path, "/dev/md/", 8))
+ /* Don't canonicalize /dev/mapper/ paths. */
+ if (strncmp (path, "/dev/mapper/", 12))
normal_path = canonicalize_file_name (path);
if (!normal_path)
/* Well, maybe it is just that the file does not exist.

View File

@ -0,0 +1,136 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Thu, 15 Jun 2017 19:04:41 +0200
Subject: libparted/dasd: add swap flag handling for DASD-CDL
References: fate#314888, bsc#1044536
Patch-mainline: no, upstream wants to drop the swap flag
The way how the linux-swap partition type is handled is not how
fdasd handles it. It is only set if there is a linux-swap file
system set with mkpart or if there is a swap file system created
by mkswap on disk. But we want to know the partition type on disk.
So introduce a swap flag which behaves like the other flags. The
parted function do_mkpart() sets this flag for us if creating a
partition with FS type name "linux-swap*".
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/labels/dasd.c | 42 +++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)
Index: parted-3.3/libparted/labels/dasd.c
===================================================================
--- parted-3.3.orig/libparted/labels/dasd.c
+++ parted-3.3/libparted/labels/dasd.c
@@ -65,6 +65,7 @@ extern void ped_disk_dasd_done ();
typedef struct {
int type;
int system;
+ int swap;
int raid;
int lvm;
} DasdPartitionData;
@@ -316,6 +317,7 @@ dasd_read (PedDisk* disk)
part->num = 1;
part->fs_type = ped_file_system_probe (&part->geom);
dasd_data = part->disk_specific;
+ dasd_data->swap = 0;
dasd_data->raid = 0;
dasd_data->lvm = 0;
dasd_data->type = 0;
@@ -400,6 +402,7 @@ dasd_read (PedDisk* disk)
part->num = 1;
part->fs_type = ped_file_system_probe (&part->geom);
dasd_data = part->disk_specific;
+ dasd_data->swap = 0;
dasd_data->raid = 0;
dasd_data->lvm = 0;
dasd_data->type = 0;
@@ -457,18 +460,11 @@ dasd_read (PedDisk* disk)
}
dasd_data = part->disk_specific;
+ dasd_data->swap = !strncmp(PART_TYPE_SWAP, str, 6);
dasd_data->raid = !strncmp(PART_TYPE_RAID, str, 6);
dasd_data->lvm = !strncmp(PART_TYPE_LVM, str, 6);
dasd_partition_set_system(part, part->fs_type);
- 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;
- }
- }
-
vtoc_ebcdic_enc(p->f1->DS1DSNAM, p->f1->DS1DSNAM, 44);
dasd_data->type = 0;
@@ -749,14 +745,25 @@ dasd_partition_set_flag (PedPartition* p
dasd_data = part->disk_specific;
switch (flag) {
+ case PED_PARTITION_SWAP:
+ if (state) {
+ dasd_data->raid = 0;
+ dasd_data->lvm = 0;
+ }
+ dasd_data->swap = state;
+ return ped_partition_set_system(part, part->fs_type);
case PED_PARTITION_RAID:
- if (state)
+ if (state) {
+ dasd_data->swap = 0;
dasd_data->lvm = 0;
+ }
dasd_data->raid = state;
return ped_partition_set_system(part, part->fs_type);
case PED_PARTITION_LVM:
- if (state)
+ if (state) {
+ dasd_data->swap = 0;
dasd_data->raid = 0;
+ }
dasd_data->lvm = state;
return ped_partition_set_system(part, part->fs_type);
default:
@@ -774,6 +781,8 @@ dasd_partition_get_flag (const PedPartit
dasd_data = part->disk_specific;
switch (flag) {
+ case PED_PARTITION_SWAP:
+ return dasd_data->swap;
case PED_PARTITION_RAID:
return dasd_data->raid;
case PED_PARTITION_LVM:
@@ -802,6 +811,8 @@ dasd_partition_is_flag_available (const
return 0;
switch (flag) {
+ case PED_PARTITION_SWAP:
+ return 1;
case PED_PARTITION_RAID:
return 1;
case PED_PARTITION_LVM:
@@ -985,17 +996,14 @@ dasd_partition_set_system (PedPartition*
return 1;
}
- if (!fs_type) {
- dasd_data->system = PARTITION_LINUX;
- PDEBUG;
- } else if (is_linux_swap (fs_type->name)) {
+ if (dasd_data->swap) {
dasd_data->system = PARTITION_LINUX_SWAP;
PDEBUG;
- } else {
- dasd_data->system = PARTITION_LINUX;
- PDEBUG;
+ return 1;
}
+ dasd_data->system = PARTITION_LINUX;
+ PDEBUG;
return 1;
}

View File

@ -0,0 +1,130 @@
From: Petr Uzel <petr.uzel@suse.cz>
Subject: libparted: dasd: Add an implicit partition disk flag
Patch-mainline: no, custom SUSE patch
---
include/parted/disk.in.h | 4 +++-
libparted/disk.c | 2 ++
libparted/labels/dasd.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 50 insertions(+), 1 deletion(-)
Index: parted-3.3/include/parted/disk.in.h
===================================================================
--- parted-3.3.orig/include/parted/disk.in.h
+++ parted-3.3/include/parted/disk.in.h
@@ -38,9 +38,11 @@ enum _PedDiskFlag {
PED_DISK_CYLINDER_ALIGNMENT=1,
/* This flag controls whether the boot flag of a GPT PMBR is set */
PED_DISK_GPT_PMBR_BOOT=2,
+ /* This flag indicates that there is an implicit (aka fake) partition on the DASD disk */
+ PED_DISK_DASD_IMPLICIT_PARTITION=3,
};
#define PED_DISK_FIRST_FLAG PED_DISK_CYLINDER_ALIGNMENT
-#define PED_DISK_LAST_FLAG PED_DISK_GPT_PMBR_BOOT
+#define PED_DISK_LAST_FLAG PED_DISK_DASD_IMPLICIT_PARTITION
/**
* Partition types
Index: parted-3.3/libparted/disk.c
===================================================================
--- parted-3.3.orig/libparted/disk.c
+++ parted-3.3/libparted/disk.c
@@ -841,6 +841,8 @@ ped_disk_flag_get_name(PedDiskFlag flag)
return N_("cylinder_alignment");
case PED_DISK_GPT_PMBR_BOOT:
return N_("pmbr_boot");
+ case PED_DISK_DASD_IMPLICIT_PARTITION:
+ return N_("implicit_partition_table");
default:
ped_exception_throw (
PED_EXCEPTION_BUG,
Index: parted-3.3/libparted/labels/dasd.c
===================================================================
--- parted-3.3.orig/libparted/labels/dasd.c
+++ parted-3.3/libparted/labels/dasd.c
@@ -73,6 +73,7 @@ typedef struct {
unsigned int format_type;
unsigned int label_block;
volume_label_t vlabel;
+ unsigned int has_implicit_partition;
} DasdDiskSpecific;
static int dasd_probe (const PedDevice *dev);
@@ -107,6 +108,10 @@ static int dasd_partition_set_system (Pe
const PedFileSystemType* fs_type);
static int dasd_alloc_metadata (PedDisk* disk);
+static int dasd_disk_set_flag (PedDisk *disk, PedDiskFlag flag, int state);
+static int dasd_disk_is_flag_available(const PedDisk *disk, PedDiskFlag flag);
+static int dasd_disk_get_flag (const PedDisk *disk, PedDiskFlag flag);
+
#include "pt-common.h"
PT_define_limit_functions (dasd)
@@ -116,6 +121,9 @@ static PedDiskOps dasd_disk_ops = {
partition_set_name: NULL,
partition_get_name: NULL,
+ disk_set_flag: dasd_disk_set_flag,
+ disk_get_flag: dasd_disk_get_flag,
+ disk_is_flag_available: dasd_disk_is_flag_available,
get_partition_alignment: dasd_get_partition_alignment,
@@ -150,6 +158,8 @@ dasd_alloc (const PedDevice* dev)
return NULL;
}
+ disk_specific->has_implicit_partition = 0;
+
/* CDL format, newer */
disk_specific->format_type = 2;
disk_specific->label_block = 2;
@@ -289,6 +299,7 @@ dasd_read (PedDisk* disk)
goto error_close_dev;
disk_specific->format_type = 1;
+ disk_specific->has_implicit_partition = 1;
/* Register implicit partition */
ped_disk_delete_all (disk);
@@ -922,6 +933,40 @@ dasd_partition_enumerate (PedPartition*
}
static int
+dasd_disk_set_flag (PedDisk *disk, PedDiskFlag flag, int state)
+{
+ /* PED_DISK_DASD_IMPLICIT_PARTITION is immutable */
+ return 0;
+}
+
+static int
+dasd_disk_is_flag_available(const PedDisk *disk, PedDiskFlag flag)
+{
+ switch (flag)
+ {
+ case PED_DISK_DASD_IMPLICIT_PARTITION:
+ return 1;
+ default:
+ return 0;
+ }
+}
+
+static int
+dasd_disk_get_flag (const PedDisk *disk, PedDiskFlag flag)
+{
+ DasdDiskSpecific* disk_specific = disk->disk_specific;
+
+ switch (flag)
+ {
+ case PED_DISK_DASD_IMPLICIT_PARTITION:
+ return disk_specific->has_implicit_partition;
+ break;
+ default:
+ return 0;
+ }
+}
+
+static int
dasd_partition_set_system (PedPartition* part,
const PedFileSystemType* fs_type)
{

View File

@ -0,0 +1,44 @@
From: Andre Wild <wild@linux.vnet.ibm.com>
Date: Fri, 24 Mar 2017 03:11:11 +0100
Subject: libparted/dasd: improve lvm/raid flag handling for DASD-CDL
References: bsc#1040163, fate#314888
Patch-mainline: submitted, 2017-05-23
This commit corrects the reading of lvm/raid flags on DASD/CDL formatted
disks. Previously, users were not able to see what was the actual flags
stored on the disk. Now the file system check is removed and this issue
is corrected.
Fixes: c8873b0044c8 ("When reading the DASD disk label, ...")
Signed-off-by: Andre Wild <wild@linux.vnet.ibm.com>
Signed-off-by: Wang Dong <dongdwdw@linux.vnet.ibm.com>
Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com>
Acked-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/labels/dasd.c | 15 +++------------
1 file changed, 3 insertions(+), 12 deletions(-)
--- a/libparted/labels/dasd.c
+++ b/libparted/labels/dasd.c
@@ -457,18 +457,9 @@ 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);
+ dasd_data->raid = !strncmp(PART_TYPE_RAID, str, 6);
+ dasd_data->lvm = !strncmp(PART_TYPE_LVM, str, 6);
+ dasd_partition_set_system(part, part->fs_type);
if (strncmp(PART_TYPE_SWAP, str, 6) == 0) {
fs = ped_file_system_probe(&part->geom);

View File

@ -0,0 +1,23 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Mon, 23 Oct 2017 17:47:47 +0200
Subject: libparted: Fix NVDIMM partition naming
References: bsc#1064446
Patch-mainline: no, required to fix custom SUSE device naming
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/arch/linux.c | 1 +
1 file changed, 1 insertion(+)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -2489,6 +2489,7 @@ _device_get_part_path (PedDevice const *
dev->type == PED_DEVICE_CPQARRAY ||
dev->type == PED_DEVICE_DAC960 ||
dev->type == PED_DEVICE_NVME ||
+ dev->type == PED_DEVICE_PMEM ||
dev->type == PED_DEVICE_SDMMC)
p = "p";
else if (dev->type == PED_DEVICE_DM)

View File

@ -0,0 +1,20 @@
From: Petr Uzel <petr.uzel@suse.cz>
Subject: libparted: Fix NVMe device naming
References: bsc#982169
Patch-mainline: no, required to fix custom SUSE device naming
---
libparted/arch/linux.c | 1 +
1 file changed, 1 insertion(+)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -2488,6 +2488,7 @@ _device_get_part_path (PedDevice const *
if (dev->type == PED_DEVICE_ATARAID ||
dev->type == PED_DEVICE_CPQARRAY ||
dev->type == PED_DEVICE_DAC960 ||
+ dev->type == PED_DEVICE_NVME ||
dev->type == PED_DEVICE_SDMMC)
p = "p";
else if (dev->type == PED_DEVICE_DM)

View File

@ -0,0 +1,15 @@
libparted/arch/linux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -2489,7 +2489,7 @@ _device_get_part_path (PedDevice const *
dev->type == PED_DEVICE_CPQARRAY ||
dev->type == PED_DEVICE_DAC960 ||
dev->type == PED_DEVICE_NVME ||
- dev->type == PED_DEVICE_PMEM ||
+ ((dev->type == PED_DEVICE_PMEM) && (!isdigit (devpath[path_len -1 ]))) ||
dev->type == PED_DEVICE_SDMMC)
p = "p";
else if (dev->type == PED_DEVICE_DM)

View File

@ -0,0 +1,51 @@
From: Petr Uzel <petr.uzel@suse.cz>
Subject: libparted: Make BLKRRPART more robust
Patch-mainline: no, upstream does not use BLKRRPART and leaves DASDs broken
---
libparted/arch/linux.c | 10 +++++++---
1 file changed, 7 insertions(+), 3 deletions(-)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -39,6 +39,7 @@
#include <sys/stat.h>
#include <sys/types.h>
#include <sys/utsname.h> /* for uname() */
+#include <sys/file.h>
#include <scsi/scsi.h>
#include <assert.h>
#include <sys/sysmacros.h>
@@ -3242,14 +3243,15 @@ static int
_kernel_reread_part_table (PedDevice* dev)
{
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
- int retry_count = 9;
+ int retry_count = 5;
sync();
+ flock(arch_specific->fd, LOCK_EX);
while (ioctl (arch_specific->fd, BLKRRPART)) {
retry_count--;
sync();
- if (retry_count == 3)
- sleep(1); /* Pause to allow system to settle */
+
+ sleep(1); /* Pause to allow system to settle */
if (!retry_count) {
ped_exception_throw (
@@ -3259,10 +3261,12 @@ _kernel_reread_part_table (PedDevice* de
"table on %s (%s). As a result, it may not "
"reflect all of your changes until after reboot."),
dev->path, strerror (errno));
+ flock(arch_specific->fd, LOCK_UN);
return 0;
}
}
+ flock(arch_specific->fd, LOCK_UN);
return 1;
}

View File

@ -0,0 +1,139 @@
From: Petr Uzel <petr.uzel@suse.cz>
Date: Thu, 26 May 2016 09:28:21 +0200
Subject: libparted: open the device RO and lazily switch to RW only if
necessary
References: bsc#979275
Patch-mainline: not yet
Avoid useless udev events triggered by opening the device RW
for purely read-only operations.
Author: Michael Matz <matz@suse.de>
[sparschauer: Use _flush_cache() also for reads, don't switch to RW
in _flush_cache() to avoid a possible recursion (bnc#989751), open
partitions in _flush_cache() O_RDONLY instead of O_WRONLY]
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/arch/linux.c | 33 ++++++++++++++++++++++++++++++---
libparted/arch/linux.h | 1 +
2 files changed, 31 insertions(+), 3 deletions(-)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -298,6 +298,9 @@ static unsigned int _device_get_partitio
static int _device_open (PedDevice* dev, int flags);
static int _device_open_ro (PedDevice* dev);
static int _device_close (PedDevice* dev);
+static int linux_close (PedDevice* dev);
+static void _flush_cache (PedDevice* dev);
+
static int
_read_fd (int fd, char **buf)
@@ -451,6 +454,22 @@ _is_blkext_major (int major)
return _major_type_in_devices (major, "blkext");
}
+static void
+_ensure_read_write (PedDevice *dev)
+{
+ PED_ASSERT (dev != NULL);
+ LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
+
+ if (arch_specific->rw)
+ return;
+
+ if (!linux_close(dev))
+ return;
+
+ if (!_device_open (dev, RW_MODE))
+ return;
+}
+
#ifdef ENABLE_DEVICE_MAPPER
static int
_dm_task_run_wait (struct dm_task *task, uint32_t cookie)
@@ -1678,7 +1697,7 @@ _flush_cache (PedDevice* dev)
if (!name)
break;
if (!_partition_is_mounted_by_path (name)) {
- fd = open (name, WR_MODE, 0);
+ fd = open (name, RD_MODE, 0);
if (fd > -1) {
ioctl (fd, BLKFLSBUF);
retry:
@@ -1709,7 +1728,7 @@ _device_open_ro (PedDevice* dev)
static int
linux_open (PedDevice* dev)
{
- return _device_open (dev, RW_MODE);
+ return _device_open (dev, RD_MODE);
}
static int
@@ -1747,6 +1766,10 @@ retry:
}
} else {
dev->read_only = 0;
+ if (flags == WR_MODE || flags == RW_MODE)
+ arch_specific->rw = 1;
+ else
+ arch_specific->rw = 0;
}
_flush_cache (dev);
@@ -1984,6 +2007,7 @@ _write_lastoddsector (PedDevice* dev, co
PED_ASSERT(dev != NULL);
PED_ASSERT(buffer != NULL);
+ _ensure_read_write (dev);
arch_specific = LINUX_SPECIFIC (dev);
@@ -2032,6 +2056,9 @@ linux_write (PedDevice* dev, const void*
return 1;
}
+ _ensure_read_write (dev);
+ if (count == 0)
+ return 1; /* We just ensured the device is open RW (see call from dasd_write()) */
if (_get_linux_version() < KERNEL_VERSION (2,6,0)) {
/* Kludge. This is necessary to read/write the last
block of an odd-sized disk, until Linux 2.5.x kernel fixes.
@@ -2570,6 +2597,7 @@ _blkpg_part_command (PedDevice* dev, str
LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
struct blkpg_ioctl_arg ioctl_arg;
+ _ensure_read_write (dev);
ioctl_arg.op = op;
ioctl_arg.flags = 0;
ioctl_arg.datalen = sizeof (struct blkpg_partition);
Index: parted-3.3/libparted/arch/linux.h
===================================================================
--- parted-3.3.orig/libparted/arch/linux.h
+++ parted-3.3/libparted/arch/linux.h
@@ -30,6 +30,7 @@ struct _LinuxSpecific {
int fd;
int major;
int minor;
+ int rw;
char* dmtype; /**< device map target type */
#if defined __s390__ || defined __s390x__
unsigned int real_sector_size;
Index: parted-3.3/libparted/labels/dasd.c
===================================================================
--- parted-3.3.orig/libparted/labels/dasd.c
+++ parted-3.3/libparted/labels/dasd.c
@@ -637,6 +637,10 @@ dasd_write (const PedDisk* disk)
return 1;
}
+ /* Ensure the device is open RW */
+ char dummy[10]; /* to avoid assertion in ped_device_write */
+ ped_device_write(disk->dev, &dummy, 0, 0);
+
/* initialize the anchor */
fdasd_initialize_anchor(&anchor);
if (fdasd_get_geometry(disk->dev, &anchor, arch_specific->fd) == 0)

View File

@ -0,0 +1,65 @@
From: Petr Uzel <petr.uzel@suse.cz>
Subject: libparted: Change partition naming for SUSE needs
References: bsc#1056508
Patch-mainline: no, custom SUSE patch
Device mapper partitions always use the suffix "-part%d" for
partition names. Other devices with a trailing number in their
name use the "p%d" suffix. All other devices use the "%d" suffix.
YaST depends on this.
[mwilck: Fixed dm part name in _dm_add_partition(), bsc#1056508]
[sparschauer: Fixed dm part name in _dm_resize_partition(), bsc#1056508]
[sparschauer: Wrote the patch description]
[sparschauer: Dropped "_part" suffix, bsc#1078820, bsc#1081547]
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
libparted/arch/linux.c | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -2456,11 +2456,17 @@ _device_get_part_path (PedDevice const *
result = zasprintf ("%.*s/part%d",
(int) (path_len - 5), devpath, num);
} else {
- char const *p = (dev->type == PED_DEVICE_DAC960
- || dev->type == PED_DEVICE_CPQARRAY
- || dev->type == PED_DEVICE_ATARAID
- || isdigit (devpath[path_len - 1])
- ? "p" : "");
+ const char *p;
+ if (dev->type == PED_DEVICE_ATARAID ||
+ dev->type == PED_DEVICE_CPQARRAY ||
+ dev->type == PED_DEVICE_DAC960 ||
+ dev->type == PED_DEVICE_SDMMC)
+ p = "p";
+ else if (dev->type == PED_DEVICE_DM)
+ p = "-part";
+ else
+ p = (isdigit (devpath[path_len - 1])
+ ? "p" : "");
result = zasprintf ("%s%s%d", devpath, p, num);
}
#ifdef ENABLE_DEVICE_MAPPER
@@ -2927,7 +2933,7 @@ _dm_add_partition (PedDisk* disk, const
size_t name_len = strlen (dev_name);
vol_name = zasprintf ("%s%s%d",
dev_name,
- isdigit (dev_name[name_len - 1]) ? "p" : "",
+ "-part",
part->num);
if (vol_name == NULL)
goto err;
@@ -3004,7 +3010,7 @@ _dm_resize_partition (PedDisk* disk, con
size_t name_len = strlen (dev_name);
vol_name = zasprintf ("%s%s%d",
dev_name,
- isdigit (dev_name[name_len - 1]) ? "p" : "",
+ "-part",
part->num);
if (vol_name == NULL)
goto err;

View File

@ -0,0 +1,80 @@
From: Petr Uzel <petr.uzel@suse.cz>
Date: Fri, 14 Feb 2014 09:12:47 +0100
Subject: libparted: use BLKRRPART for DASDs
References: bnc#862139
Patch-mainline: no, upstream dropped proper DASD support
This reverts upstream commit 9fa0e1800db5b9f094ae481fd95a51da03f19e95.
This reverts upstream commit 1223b9fc07859cb619c80dc057bd05458f9b5669.
and some fixups on top
---
libparted/arch/linux.c | 50 ++++++++++++++++++++++++++++++++++++++++---------
1 file changed, 41 insertions(+), 9 deletions(-)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -3239,6 +3239,34 @@ _disk_sync_part_table (PedDisk* disk)
}
static int
+_kernel_reread_part_table (PedDevice* dev)
+{
+ LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
+ int retry_count = 9;
+
+ sync();
+ while (ioctl (arch_specific->fd, BLKRRPART)) {
+ 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;
+ }
+ }
+
+ return 1;
+}
+
+static int
_have_blkpg ()
{
static int have_blkpg = -1;
@@ -3257,14 +3285,19 @@ linux_disk_commit (PedDisk* disk)
{
if (disk->dev->type != PED_DEVICE_FILE) {
- /* We now require BLKPG support. If this assertion fails,
- please write to the mailing list describing your system.
- Assuming it's never triggered, ...
- FIXME: remove this assertion in 2012. */
- assert (_have_blkpg ());
-
- if (!_disk_sync_part_table (disk))
- return 0;
+ /* The ioctl() command BLKPG_ADD_PARTITION does not notify
+ * the devfs system; consequently, /proc/partitions will not
+ * be up to date, and the proper links in /dev are not
+ * created. Therefore, if using DevFS, we must get the kernel
+ * to re-read and grok the partition table.
+ */
+ /* Work around kernel dasd problem so we really do BLKRRPART */
+ if (disk->dev->type == PED_DEVICE_DASD)
+ return _kernel_reread_part_table(disk->dev);
+
+ assert(_have_blkpg());
+ if (!_disk_sync_part_table(disk))
+ return 0;
}
return 1;

View File

@ -0,0 +1,109 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Thu, 25 Jan 2018 17:06:00 +0100
Subject: libparted: dasd: Use BLKRRPART only when needed
References: bsc#1065197, bsc#1067435
Patch-mainline: no, upstream dropped proper DASD support
The BLKRRPART ioctl is required due to limitations of the DASD
disk layout. We use it always for those devices right now but when
adding or removing a partition at the end, then it is enough to use
the BLKPG* ioctls. The problem with BLKRRPART occurs when one of the
first partitions is busy. BLKRRPART touches all partitions and the
parted command fails in this case.
So detect that situation and use BLKRRPART only when needed instead.
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
include/parted/disk.in.h | 1 +
libparted/arch/linux.c | 13 +++++++------
libparted/disk.c | 15 +++++++++++++--
3 files changed, 21 insertions(+), 8 deletions(-)
Index: parted-3.3/include/parted/disk.in.h
===================================================================
--- parted-3.3.orig/include/parted/disk.in.h
+++ parted-3.3/include/parted/disk.in.h
@@ -195,6 +195,7 @@ struct _PedDisk {
int update_mode; /**< mode without free/metadata
partitions, for easier
update */
+ int needs_blkrrpart; /* special cases on DASDs */
};
struct _PedDiskOps {
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -3324,15 +3324,15 @@ static int
linux_disk_commit (PedDisk* disk)
{
if (disk->dev->type != PED_DEVICE_FILE) {
-
- /* The ioctl() command BLKPG_ADD_PARTITION does not notify
- * the devfs system; consequently, /proc/partitions will not
- * be up to date, and the proper links in /dev are not
- * created. Therefore, if using DevFS, we must get the kernel
- * to re-read and grok the partition table.
+ /* If adding or removing partitions not at the end, then the
+ * ioctl() command BLKPG_ADD_PARTITION does not notify the
+ * devfs system; consequently, /proc/partitions will not be up
+ * to date, and the proper links in /dev are not created.
+ * Therefore, if using DevFS, we must get the kernel to re-read
+ * and grok the partition table.
*/
/* Work around kernel dasd problem so we really do BLKRRPART */
- if (disk->dev->type == PED_DEVICE_DASD)
+ if (disk->dev->type == PED_DEVICE_DASD && disk->needs_blkrrpart)
return _kernel_reread_part_table(disk->dev);
assert(_have_blkpg());
Index: parted-3.3/libparted/disk.c
===================================================================
--- parted-3.3.orig/libparted/disk.c
+++ parted-3.3/libparted/disk.c
@@ -407,6 +407,7 @@ _ped_disk_alloc (const PedDevice* dev, c
disk->update_mode = 1;
disk->part_list = NULL;
disk->needs_clobber = 0;
+ disk->needs_blkrrpart = 0;
return disk;
error:
@@ -1734,8 +1735,12 @@ _disk_raw_remove (PedDisk* disk, PedPart
if (part->prev) {
part->prev->next = part->next;
- if (part->next)
+ if (part->next) {
+ /* remove partition in the middle */
+ if (part->type == PED_PARTITION_NORMAL)
+ disk->needs_blkrrpart = 1;
part->next->prev = part->prev;
+ }
} else {
if (part->type & PED_PARTITION_LOGICAL) {
ped_disk_extended_partition (disk)->part_list
@@ -1743,8 +1748,12 @@ _disk_raw_remove (PedDisk* disk, PedPart
} else {
disk->part_list = part->next;
}
- if (part->next)
+ if (part->next) {
+ /* remove first partition */
+ if (part->type == PED_PARTITION_NORMAL)
+ disk->needs_blkrrpart = 1;
part->next->prev = NULL;
+ }
}
return 1;
@@ -1774,6 +1783,8 @@ _disk_raw_add (PedDisk* disk, PedPartiti
}
if (walk) {
+ if (part->type == PED_PARTITION_NORMAL)
+ disk->needs_blkrrpart = 1;
return _disk_raw_insert_before (disk, walk, part);
} else {
if (last) {

View File

@ -0,0 +1,76 @@
From: Petr Uzel <petr.uzel@suse.cz>
Subject: parted: Make informing the kernel more reliable
References: bnc#657360
Patch-mainline: no
This patch should make parted's process of informing the kernel
about changes of partition table sligtly more reliable.
It consists of 2 quite unrelated parts:
* increase the max sleep time if partition is busy from 1 to 2 seconds
* do not inform the kernel when only partition flags change - kernel
does not care about the flags
---
libparted/arch/linux.c | 2 +-
parted/parted.c | 28 +++++++++++++++++++++++++++-
2 files changed, 28 insertions(+), 2 deletions(-)
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -3153,7 +3153,7 @@ _disk_sync_part_table (PedDisk* disk)
/* Attempt to remove the partition, retrying for
up to max_sleep_seconds upon any failure due to EBUSY. */
unsigned int sleep_microseconds = 10000;
- unsigned int max_sleep_seconds = 1;
+ unsigned int max_sleep_seconds = 2;
unsigned int n_sleep = (max_sleep_seconds
* 1000000 / sleep_microseconds);
do {
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -267,6 +267,32 @@ _disk_warn_loss (PedDisk* disk)
disk->dev->path) == PED_EXCEPTION_YES;
}
+/*
+ * Copied from ped_disk_commit(), but with removed the call to
+ * ped_disk_commit_to_os(). This is used in do_set() - BLKPG* ioctls() do not
+ * care about the partition flags anyway.
+ */
+static int
+ped_disk_commit_just_to_disk (PedDisk* disk)
+{
+ /* Open the device here, so that the underlying fd is not closed
+ between commit_to_dev and commit_to_os (closing causes unwanted
+ udev events to be sent under Linux). */
+ if (!ped_device_open (disk->dev))
+ goto error;
+
+ if (!ped_disk_commit_to_dev (disk))
+ goto error_close_dev;
+
+ ped_device_close (disk->dev);
+ return 1;
+
+error_close_dev:
+ ped_device_close (disk->dev);
+error:
+ return 0;
+}
+
/* This function changes "sector" to "new_sector" if the new value lies
* within the required range.
*/
@@ -1791,7 +1817,7 @@ do_set (PedDevice** dev, PedDisk **diskp
if (!ped_partition_set_flag (part, flag, state))
goto error;
- if (!ped_disk_commit (*diskp))
+ if (!ped_disk_commit_just_to_disk (*diskp))
goto error;
if ((*dev)->type != PED_DEVICE_FILE)

View File

@ -0,0 +1,30 @@
From: Petr Uzel <petr.uzel@suse.cz>
Subject: build: Add ncursesw6 support
Patch-mainline: no, custom SUSE patch
---
configure.ac | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
Index: parted-3.3/configure.ac
===================================================================
--- parted-3.3.orig/configure.ac
+++ parted-3.3/configure.ac
@@ -147,7 +147,8 @@ AM_CPPFLAGS="$AM_CPPFLAGS -D_REENTRANT"
dnl Check for programs.
AC_SEARCH_LIBS([strerror],[cposix])
-AC_PROG_CC
+AC_PROG_CC_STDC
+AC_USE_SYSTEM_EXTENSIONS
AC_PROG_GCC_TRADITIONAL
AM_PROG_CC_C_O
@@ -320,7 +321,7 @@ dnl Check for termcap
if test "$with_readline" = yes; then
OLD_LIBS="$LIBS"
LIBS=""
- AC_SEARCH_LIBS([tgetent], [tinfo ncurses curses termcap termlib],
+ AC_SEARCH_LIBS([tgetent], [tinfo ncursesw curses termcap termlib],
[PARTED_LIBS="$PARTED_LIBS $LIBS"],
[AC_MSG_ERROR(dnl
[termcap could not be found which is required for the

BIN
parted-3.5.tar.xz (Stored with Git LFS) Normal file

Binary file not shown.

11
parted-3.5.tar.xz.sig Normal file
View File

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

View File

@ -0,0 +1,107 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Mon, 20 Nov 2017 18:01:56 +0100
Subject: parted: Add '--ignore-busy' option
References: bsc#1058667
Patch-mainline: not yet, based on v3 submitted on 2017-11-07
There are dangerous actions like e.g. shrinking or removing a busy
partition which should be possible in script mode but not without
using an option to enforce that. This is meant to prevent buggy
scripts from doing those actions unintentionally.
Also add proper printing of the help text for a long option without
a short option.
Suggested-by: Phillip Susi <psusi@ubuntu.com>
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
doc/C/parted.8 | 3 +++
parted/parted.c | 16 ++++++++++++++--
2 files changed, 17 insertions(+), 2 deletions(-)
Index: parted-3.3/doc/C/parted.8
===================================================================
--- parted-3.3.orig/doc/C/parted.8
+++ parted-3.3/doc/C/parted.8
@@ -30,6 +30,9 @@ never prompts for user intervention
.B -v, --version
displays the version
.TP
+.B --ignore-busy
+perform the requested action in script mode although a partition is busy
+.TP
.B --wipesignatures
mkpart wipes the superblock signatures from the disk region where it is
about to create the partition
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -76,8 +76,9 @@ static int MEGABYTE_SECTORS (PedDevice*
enum
{
PRETEND_INPUT_TTY = CHAR_MAX + 1,
- WIPESIGNATURES = CHAR_MAX + 2,
+ IGNORE_BUSY = CHAR_MAX + 2,
+ WIPESIGNATURES = CHAR_MAX + 3,
};
/* Output modes */
enum
@@ -118,6 +119,7 @@ static struct option const options[] = {
{"fix", 0, NULL, 'f'},
{"version", 0, NULL, 'v'},
{"align", required_argument, NULL, 'a'},
+ {"ignore-busy", 0, NULL, IGNORE_BUSY},
{"wipesignatures", 0, NULL, WIPESIGNATURES},
{"-pretend-input-tty", 0, NULL, PRETEND_INPUT_TTY},
{NULL, 0, NULL, 0}
@@ -130,10 +132,13 @@ static const char *const options_help []
{"fix", N_("in script mode, fix instead of abort when asked")},
{"version", N_("displays the version")},
{"align=[none|cyl|min|opt]", N_("alignment for new partitions")},
+ {"ignore-busy", N_("perform action although partition is busy")},
{"wipesignatures", N_("wipe superblock signatures when creating partition")},
{NULL, NULL}
};
+#define LONGOPT_HELP_START 6 /* index to first long option help */
+
int opt_script_mode = 0;
int opt_fix_mode = 0;
int pretend_input_tty = 0;
@@ -141,6 +146,7 @@ int opt_machine_mode = 0;
int disk_is_modified = 0;
int is_toggle_mode = 0;
int alignment = ALIGNMENT_OPTIMAL;
+int ignore_busy = 0;
static const char* number_msg = N_(
"NUMBER is the partition number used by Linux. On MS-DOS disk labels, the "
@@ -514,12 +520,17 @@ print_options_help ()
{
int i;
- for (i=0; options_help [i][0]; i++) {
+ for (i=0; i < LONGOPT_HELP_START; i++) {
printf (" -%c, --%-25.25s %s\n",
options_help [i][0][0],
options_help [i][0],
_(options_help [i][1]));
}
+ for (i=LONGOPT_HELP_START; options_help [i][0]; i++) {
+ printf (" --%-29.25s %s\n",
+ options_help [i][0],
+ _(options_help [i][1]));
+ }
}
int
@@ -2299,6 +2310,7 @@ while (1)
alignment = XARGMATCH ("--align", optarg,
align_args, align_types);
break;
+ case IGNORE_BUSY: ignore_busy = 1; break;
case PRETEND_INPUT_TTY:
pretend_input_tty = 1;
break;

View File

@ -0,0 +1,42 @@
From: Petr Uzel <petr.uzel@suse.cz>
Subject: build: Patch fatresize build into parted package
Patch-mainline: no, custom SUSE patch
Fatresize is used by YaST to resize FAT16/FAT32 file systems. It uses
libparted functions for that purpose but does not resize the FAT
partition afterward. That is the task of parted instead. So using it
without parted and YaST doesn't make much sense.
Versions more recent than 0.1 like e.g. 1.0.3 are incompatible and
risk data loss by silently increasing the FS size (See: bsc#1072479).
Upstream: https://github.com/ya-mouse/fatresize
[sparschauer: Wrote the patch description]
---
Makefile.am | 2 +-
configure.ac | 1 +
2 files changed, 2 insertions(+), 1 deletion(-)
Index: parted-3.3/Makefile.am
===================================================================
--- parted-3.3.orig/Makefile.am
+++ parted-3.3/Makefile.am
@@ -1,5 +1,5 @@
ACLOCAL_AMFLAGS = -I m4
-SUBDIRS = po lib include libparted parted partprobe doc debug tests
+SUBDIRS = po lib include libparted parted partprobe fatresize doc debug tests
EXTRA_DIST = \
.version \
Index: parted-3.3/configure.ac
===================================================================
--- parted-3.3.orig/configure.ac
+++ parted-3.3/configure.ac
@@ -571,6 +571,7 @@ libparted.pc
libparted-fs-resize.pc
parted/Makefile
partprobe/Makefile
+fatresize/Makefile
doc/Makefile
doc/C/Makefile
doc/pt_BR/Makefile

View File

@ -0,0 +1,122 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Tue, 7 Nov 2017 14:09:46 +0100
Subject: parted: Fix resizepart and rm command
References: bsc#1058667
Patch-mainline: not yet, based on v3 submitted on 2017-11-07
In script mode the resizepart command fails when shrinking and
if the partition is busy. Also the warnings printed in this
case are only applicable to interactive mode. A similar problem
exists with the rm command.
So print different warnings in script mode and continue if growing
a busy partition. Require the '--ignore-busy' option to be set in
order to shrink or remove a busy partition. Shrinking cannot be
more dangerous in script mode than removing. So allow shrinking a
partition in script mode which is not busy.
In interactive mode there is a problem if providing the partition
number and the end of the partition as arguments to the resizepart
command directly with a busy partition. The warning is shown and
after continuing anyway parted asks for the partition end although
it has already been provided. So count the number of words on
command line and warn after processing all of them or after getting
the partition number.
Fixes: 21c58e17c473 ("parted: add resizepart command")
Reported-by: Arvin Schnell <aschnell@suse.com>
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
parted/parted.c | 39 ++++++++++++++++++++++++++++++++-------
2 files changed, 36 insertions(+), 7 deletions(-)
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -229,13 +229,19 @@ _timer_handler (PedTimer* timer, void* c
}
static int
-_partition_warn_busy (PedPartition* part)
+_partition_warn_busy (PedPartition* part, bool dangerous)
{
char* path;
if (ped_partition_is_busy (part)) {
path = ped_partition_get_path (part);
- if (ped_exception_throw (
+ if (opt_script_mode && (!dangerous || ignore_busy)) {
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_UNHANDLED,
+ _("Partition %s is being used, continuing anyway."),
+ path);
+ } else if (ped_exception_throw (
PED_EXCEPTION_WARNING,
PED_EXCEPTION_YES_NO,
_("Partition %s is being used. Are you sure you " \
@@ -1655,6 +1661,11 @@ do_resizepart (PedDevice** dev, PedDisk*
PedSector start, end, oldend;
PedGeometry *range_end = NULL;
PedConstraint* constraint;
+ int cmdline_words = command_line_get_word_count();
+ /* update this if adding/removing arguments to/from this command */
+ const int part_idx = 1;
+ const int end_idx = 2;
+ const bool danger_if_busy = false;
int rc = 0;
char* end_input = NULL;
char* end_size = NULL;
@@ -1671,7 +1682,8 @@ do_resizepart (PedDevice** dev, PedDisk*
}
/* If the partition is busy this may clear the command_line and prompt the user */
- if (!_partition_warn_busy (part))
+ /* warn early if the partition end is not provided on cmdline */
+ if (cmdline_words <= part_idx && !_partition_warn_busy (part, danger_if_busy))
goto error;
/* Push the End value back onto the command_line, if it exists */
@@ -1871,13 +1873,23 @@ do_resizepart (PedDevice** dev, PedDisk*
start, end))
goto error_destroy_constraint;
/* warn when shrinking partition - might lose data */
- if (part->geom.end < oldend)
- if (ped_exception_throw (
+ if (part->geom.end < oldend) {
+ if (opt_script_mode && (!ped_partition_is_busy (part) || ignore_busy)) {
+ char *path = ped_partition_get_path (part);
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_UNHANDLED,
+ _("Shrinking partition %s, data loss possible."), path);
+ free(path);
+ } else if (ped_exception_throw (
PED_EXCEPTION_WARNING,
PED_EXCEPTION_YES_NO,
_("Shrinking a partition can cause data loss, " \
"are you sure you want to continue?")) != PED_EXCEPTION_YES)
+ {
goto error_destroy_constraint;
+ }
+ }
ped_disk_commit (disk);
if ((*dev)->type != PED_DEVICE_FILE)
@@ -1714,6 +1739,7 @@ static int
do_rm (PedDevice** dev, PedDisk** diskp)
{
PedPartition* part = NULL;
+ const bool danger_if_busy = true;
if (!*diskp)
*diskp = ped_disk_new (*dev);
@@ -1722,7 +1748,7 @@ do_rm (PedDevice** dev, PedDisk** diskp)
if (!command_line_get_partition (_("Partition number?"), *diskp, &part))
goto error;
- if (!_partition_warn_busy (part))
+ if (!_partition_warn_busy (part, danger_if_busy))
goto error;
if (!ped_disk_delete_partition (*diskp, part))

View File

@ -0,0 +1,206 @@
From: Petr Uzel <petr.uzel@suse.cz>
Date: Thu, 28 Apr 2016 17:18:44 +0200
Subject: [PATCH] parted: implement --wipesignatures option
References: bsc#943623, fate#319893, bsc#980834
Patch-mainline: no, custom extension
With this option, parted uses libblkid to wipe superblock signatures
from a disk region where it is about to create a new partition.
[sparschauer: Use own #if USE_BLKID block in linux_dev_ops (bsc#1047031)]
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
doc/C/parted.8 | 4 ++++
include/parted/device.in.h | 2 ++
libparted/arch/linux.c | 39 +++++++++++++++++++++++++++++++++++++++
libparted/device.c | 17 +++++++++++++++++
parted/parted.c | 16 ++++++++++++++++
5 files changed, 78 insertions(+)
Index: parted-3.3/doc/C/parted.8
===================================================================
--- parted-3.3.orig/doc/C/parted.8
+++ parted-3.3/doc/C/parted.8
@@ -30,6 +30,10 @@ never prompts for user intervention
.B -v, --version
displays the version
.TP
+.B --wipesignatures
+mkpart wipes the superblock signatures from the disk region where it is
+about to create the partition
+.TP
.B -a \fIalignment-type\fP, --align \fIalignment-type\fP
Set alignment for newly created partitions, valid alignment types are:
.RS
Index: parted-3.3/include/parted/device.in.h
===================================================================
--- parted-3.3.orig/include/parted/device.in.h
+++ parted-3.3/include/parted/device.in.h
@@ -122,6 +122,7 @@ struct _PedDeviceArchOps {
/* These functions are optional */
PedAlignment *(*get_minimum_alignment)(const PedDevice *dev);
PedAlignment *(*get_optimum_alignment)(const PedDevice *dev);
+ int (*wipe_signatures)(const PedDevice *dev, PedSector start, PedSector length);
};
#include <parted/constraint.h>
@@ -158,6 +159,7 @@ extern PedConstraint *ped_device_get_opt
extern PedAlignment *ped_device_get_minimum_alignment(const PedDevice *dev);
extern PedAlignment *ped_device_get_optimum_alignment(const PedDevice *dev);
+extern int ped_device_wipe_signatures(const PedDevice *dev, PedSector start, PedSector length);
/* private stuff ;-) */
Index: parted-3.3/libparted/arch/linux.c
===================================================================
--- parted-3.3.orig/libparted/arch/linux.c
+++ parted-3.3/libparted/arch/linux.c
@@ -3395,6 +3395,44 @@ linux_get_optimum_alignment(const PedDev
blkid_topology_get_alignment_offset(tp) / dev->sector_size,
blkid_topology_get_optimal_io_size(tp) / dev->sector_size);
}
+
+static int
+linux_wipe_signatures(const PedDevice *dev, PedSector start, PedSector length)
+{
+ PED_ASSERT (dev != NULL);
+ LinuxSpecific* arch_specific = LINUX_SPECIFIC (dev);
+
+ blkid_loff_t wipe_offset = start * dev->sector_size;
+ blkid_loff_t wipe_size = length * dev->sector_size;
+
+ _ensure_read_write (dev);
+
+ blkid_probe pr;
+ pr = blkid_new_probe();
+ if (!pr)
+ goto error;
+
+ if (blkid_probe_set_device(pr, arch_specific->fd, wipe_offset, wipe_size) == -1)
+ goto error_free_probe;
+ if (blkid_probe_enable_superblocks(pr, 1) == -1)
+ goto error_free_probe;
+ if (blkid_probe_set_superblocks_flags(pr, BLKID_SUBLKS_MAGIC) == -1)
+ goto error_free_probe;
+
+ while (blkid_do_probe(pr) == 0) {
+ if (blkid_do_wipe(pr, 0) == -1)
+ goto error_free_probe;
+ }
+
+ blkid_free_probe(pr);
+ return 1;
+
+error_free_probe:
+ blkid_free_probe(pr);
+
+error:
+ return 0;
+}
#endif
#if defined __s390__ || defined __s390x__
@@ -3471,6 +3509,9 @@ static PedDeviceArchOps linux_dev_ops =
get_minimum_alignment: linux_get_minimum_alignment,
get_optimum_alignment: linux_get_optimum_alignment,
#endif
+#if USE_BLKID
+ wipe_signatures: linux_wipe_signatures,
+#endif
};
PedDiskArchOps linux_disk_ops = {
Index: parted-3.3/libparted/device.c
===================================================================
--- parted-3.3.orig/libparted/device.c
+++ parted-3.3/libparted/device.c
@@ -559,4 +559,21 @@ ped_device_get_optimum_alignment(const P
return align;
}
+
+/**
+ * Wipe superblock signatures from the specified region on the device.
+ *
+ * \return zero on failure
+ */
+int
+ped_device_wipe_signatures(const PedDevice *dev, PedSector start, PedSector length)
+{
+ int ret = 0;
+
+ if (ped_architecture->dev_ops->wipe_signatures)
+ ret = ped_architecture->dev_ops->wipe_signatures(dev, start, length);
+
+ return ret;
+}
+
/** @} */
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -76,6 +76,7 @@ static int MEGABYTE_SECTORS (PedDevice*
enum
{
PRETEND_INPUT_TTY = CHAR_MAX + 1,
+ WIPESIGNATURES = CHAR_MAX + 2,
};
/* Output modes */
@@ -117,6 +118,7 @@ static struct option const options[] = {
{"fix", 0, NULL, 'f'},
{"version", 0, NULL, 'v'},
{"align", required_argument, NULL, 'a'},
+ {"wipesignatures", 0, NULL, WIPESIGNATURES},
{"-pretend-input-tty", 0, NULL, PRETEND_INPUT_TTY},
{NULL, 0, NULL, 0}
};
@@ -128,11 +130,13 @@ static const char *const options_help []
{"version", N_("displays the version")},
{"align=[none|cyl|min|opt]", N_("alignment for new partitions")},
+ {"wipesignatures", N_("wipe superblock signatures when creating partition")},
{NULL, NULL}
};
int opt_script_mode = 0;
int opt_fix_mode = 0;
int pretend_input_tty = 0;
int opt_output_mode = HUMAN;
+int wipesignatures = 0;
int disk_is_modified = 0;
int is_toggle_mode = 0;
@@ -651,6 +655,7 @@ _adjust_end_if_iec (PedSector* start, Pe
}
}
+
static int
do_mkpart (PedDevice** dev, PedDisk** diskp)
{
@@ -848,6 +853,14 @@ do_mkpart (PedDevice** dev, PedDisk** di
if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
+ if (wipesignatures) {
+ if (!ped_device_wipe_signatures(*dev, part->geom.start, part->geom.length))
+ ped_exception_throw (
+ PED_EXCEPTION_WARNING,
+ PED_EXCEPTION_OK,
+ _("Wiping the superblock signatures has failed."));
+ }
+
if (!ped_disk_commit (disk))
goto error_remove_part;
@@ -2252,6 +2265,9 @@ while (1)
case PRETEND_INPUT_TTY:
pretend_input_tty = 1;
break;
+ case WIPESIGNATURES:
+ wipesignatures = 1;
+ break;
default:
wrong = 1;
break;

180
parted-mac.patch Normal file
View File

@ -0,0 +1,180 @@
From: Petr Uzel <petr.uzel@suse.cz>
Subject: parted: mac: Print the system name
Patch-mainline: no, custom SUSE patch
---
include/parted/disk.in.h | 9 +++++++--
libparted/disk.c | 33 +++++++++++++++++++++++++++++++++
libparted/labels/mac.c | 34 +++++++++++++++++++++++++++++++++-
parted/parted.c | 12 ++++++++++++
4 files changed, 85 insertions(+), 3 deletions(-)
Index: parted-3.3/include/parted/disk.in.h
===================================================================
--- parted-3.3.orig/include/parted/disk.in.h
+++ parted-3.3/include/parted/disk.in.h
@@ -83,10 +83,11 @@ enum _PedPartitionFlag {
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
- PED_DISK_TYPE_PARTITION_NAME=2 /**< supports partition names */
+ PED_DISK_TYPE_PARTITION_NAME=2, /**< supports partition names */
+ PED_DISK_TYPE_SYSTEM_NAME=4 /**< supports system names */
};
#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_SYSTEM_NAME
struct _PedDisk;
struct _PedPartition;
@@ -246,6 +247,8 @@ struct _PedDiskOps {
/* other */
int (*alloc_metadata) (PedDisk* disk);
int (*get_max_primary_partition_count) (const PedDisk* disk);
+ void (*partition_set_system_name) (PedPartition* part, const char* name);
+ const char* (*partition_get_system_name) (const PedPartition* part);
bool (*get_max_supported_partition_count) (const PedDisk* disk,
int* supported);
PedAlignment *(*get_partition_alignment)(const PedDisk *disk);
@@ -337,7 +340,9 @@ extern int ped_partition_is_flag_availab
extern int ped_partition_set_system (PedPartition* part,
const PedFileSystemType* fs_type);
extern int ped_partition_set_name (PedPartition* part, const char* name);
+extern int ped_partition_set_system_name (PedPartition* part, const char* name);
extern const char* ped_partition_get_name (const PedPartition* part);
+extern const char* ped_partition_get_system_name (const PedPartition* part);
extern int ped_partition_is_busy (const PedPartition* part);
extern char* ped_partition_get_path (const PedPartition* part);
Index: parted-3.3/libparted/disk.c
===================================================================
--- parted-3.3.orig/libparted/disk.c
+++ parted-3.3/libparted/disk.c
@@ -1185,6 +1185,39 @@ _disk_pop_update_mode (PedDisk* disk)
* @{
*/
+const char*
+ped_partition_get_system_name (const PedPartition* part)
+{
+ PED_ASSERT (part != NULL);
+ PED_ASSERT (part->disk != NULL);
+ PED_ASSERT (ped_partition_is_active (part));
+
+ if (!ped_disk_type_check_feature (
+ part->disk->type, PED_DISK_TYPE_SYSTEM_NAME))
+ return NULL; /* silent skip */
+
+ PED_ASSERT (part->disk->type->ops->partition_get_system_name != NULL);
+ return part->disk->type->ops->partition_get_system_name (part);
+}
+
+int
+ped_partition_set_system_name (PedPartition* part, const char* name)
+{
+ PED_ASSERT (part != NULL);
+ PED_ASSERT (part->disk != NULL);
+ PED_ASSERT (ped_partition_is_active (part));
+ PED_ASSERT (name != NULL);
+
+ if (!ped_disk_type_check_feature (
+ part->disk->type, PED_DISK_TYPE_SYSTEM_NAME))
+ return 0; /* silent skip */
+
+ PED_ASSERT (part->disk->type->ops->partition_set_system_name != NULL);
+ part->disk->type->ops->partition_set_system_name (part, name);
+ return 1;
+}
+
+
PedPartition*
_ped_partition_alloc (const PedDisk* disk, PedPartitionType type,
const PedFileSystemType* fs_type,
Index: parted-3.3/libparted/labels/mac.c
===================================================================
--- parted-3.3.orig/libparted/labels/mac.c
+++ parted-3.3/libparted/labels/mac.c
@@ -1396,6 +1396,36 @@ mac_get_partition_alignment(const PedDis
return ped_alignment_new(0, 1);
}
+/* we do not really want to call this ... yet */
+static void
+mac_partition_set_system_name (PedPartition* part, const char* name)
+{
+ MacPartitionData* mac_data;
+ int i;
+
+ PED_ASSERT (part != NULL);
+ PED_ASSERT (part->disk_specific != NULL);
+ mac_data = part->disk_specific;
+
+ strncpy (mac_data->system_name, name, 32);
+ mac_data->system_name [32] = 0;
+ for (i = strlen (mac_data->system_name) - 1;
+ mac_data->system_name[i] == ' '; i--)
+ mac_data->system_name [i] = 0;
+}
+
+static const char*
+mac_partition_get_system_name (const PedPartition* part)
+{
+ MacPartitionData* mac_data;
+
+ PED_ASSERT (part != NULL);
+ PED_ASSERT (part->disk_specific != NULL);
+ mac_data = part->disk_specific;
+
+ return mac_data->system_name;
+}
+
static PedConstraint*
_primary_constraint (PedDisk* disk)
{
@@ -1596,6 +1626,8 @@ static PedDiskOps mac_disk_ops = {
partition_set_name: mac_partition_set_name,
partition_get_name: mac_partition_get_name,
+ partition_set_system_name: mac_partition_set_system_name,
+ partition_get_system_name: mac_partition_get_system_name,
get_partition_alignment: mac_get_partition_alignment,
@@ -1606,7 +1638,7 @@ static PedDiskType mac_disk_type = {
next: NULL,
name: "mac",
ops: &mac_disk_ops,
- features: PED_DISK_TYPE_PARTITION_NAME
+ features: PED_DISK_TYPE_PARTITION_NAME | PED_DISK_TYPE_SYSTEM_NAME
};
void
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -946,6 +946,7 @@
static char*
partition_print_flags (PedPartition const *part)
{
+ const char* sysname;
char *res = xstrdup ("");
if (!part)
return res;
@@ -967,6 +968,17 @@
}
}
+ sysname = ped_partition_get_system_name( part );
+ if (sysname) {
+ char tmpstr[21];
+ snprintf(tmpstr, sizeof(tmpstr) - 1, "type=%s", sysname);
+ size_t new_len = res_buf_len + strlen(sep) + strlen(tmpstr);
+ res = xrealloc(res, new_len);
+ stpcpy (stpcpy (res + res_buf_len - 1, sep), tmpstr);
+ res_buf_len = new_len;
+ sep = ", ";
+ }
+
return res;
}

View File

@ -0,0 +1,46 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Thu, 15 Jun 2017 18:50:32 +0200
Subject: parted: mkpart: set a swap flag if available
References: fate#314888, bsc#1044536
Patch-mainline: no, upstream wants to drop the swap flag
libparted can't differentiate if ped_partition_set_system() is
called from mkpart context or when reading from disk. This makes
it hard to handle the linux-swap partition type properly.
So check in do_mkpart() if a swap flag is available and only set it
there if the selected FS type name starts with "linux-swap".
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
parted/parted.c | 10 ++++++++++
1 file changed, 10 insertions(+)
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -656,6 +656,13 @@ _adjust_end_if_iec (PedSector* start, Pe
}
+static inline int
+is_linux_swap (char const *fs_type_name)
+{
+ char const *prefix = "linux-swap";
+ return strncmp (fs_type_name, prefix, strlen (prefix)) == 0;
+}
+
static int
do_mkpart (PedDevice** dev, PedDisk** diskp)
{
@@ -852,6 +859,9 @@ do_mkpart (PedDevice** dev, PedDisk** di
goto error_remove_part;
if (ped_partition_is_flag_available (part, PED_PARTITION_LBA))
ped_partition_set_flag (part, PED_PARTITION_LBA, 1);
+ if (ped_partition_is_flag_available (part, PED_PARTITION_SWAP) &&
+ fs_type && is_linux_swap(fs_type->name))
+ ped_partition_set_flag (part, PED_PARTITION_SWAP, 1);
if (wipesignatures) {
if (!ped_device_wipe_signatures(*dev, part->geom.start, part->geom.length))

View File

@ -0,0 +1,24 @@
From: Anna Maresova <anicka@suse.cz>
Date: Wed Mar 25 18:17:28 CET 2020
Subject: parted: print maximum number of partitions for yast
Patch-mainline: no, custom SUSE patch
Index: parted-3.3/parted/parted.c
===================================================================
--- parted-3.3.orig/parted/parted.c
+++ parted-3.3/parted/parted.c
@@ -1125,10 +1125,13 @@ _print_disk_info (const PedDevice *dev,
break;
}
- printf ("%s:%s:%s:%lld:%lld:%s:%s:%s;\n",
+ printf ("%s:%s:%s:%lld:%lld:%s:%s:%s",
escaped_path, end, transport[dev->type],
dev->sector_size, dev->phys_sector_size,
pt_name, escaped_model, disk_flags);
+ if (getenv("PARTED_PRINT_NUMBER_OF_PARTITION_SLOTS"))
+ printf(":%lld", diskp && diskp->type->ops->get_max_primary_partition_count ? diskp->type->ops->get_max_primary_partition_count(diskp) : 0);
+ printf(";\n");
free (escaped_path);
free (escaped_model);
} else if (opt_output_mode == JSON) {

26
parted-wipeaix.patch Normal file
View File

@ -0,0 +1,26 @@
From: Petr Uzel <petr.uzel@suse.cz>
Subject: parted: dos: Wipe AIX FS signatures
Patch-mainline: no, custom SUSE patch
---
libparted/labels/dos.c | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
Index: parted-3.3/libparted/labels/dos.c
===================================================================
--- parted-3.3.orig/libparted/labels/dos.c
+++ parted-3.3/libparted/labels/dos.c
@@ -1287,7 +1287,13 @@ msdos_write (const PedDisk* disk)
return 0;
DosRawTable *table = (DosRawTable *) s0;
- if (!table->boot_code[0]) {
+ /* either no bootrecord at all, or AIX IPL signature ... */
+ if ( (!table->boot_code[0]) ||
+ ( table->boot_code[0] == (char) 0xc9 &&
+ table->boot_code[1] == (char) 0xc2 &&
+ table->boot_code[2] == (char) 0xd4 &&
+ table->boot_code[3] == (char) 0xc1)
+ ) {
memset (table, 0, 512);
memcpy (table->boot_code, MBR_BOOT_CODE, sizeof (MBR_BOOT_CODE));
}

1924
parted.changes Normal file

File diff suppressed because it is too large Load Diff

110
parted.keyring Normal file
View File

@ -0,0 +1,110 @@
Release GPG keyring of parted group.
-----BEGIN PGP PUBLIC KEY BLOCK-----
mQENBEt+xXMBCACkA1ZtcO4H7ZUG/0aL4RlZIozsorXzFrrTAsJEHvdy+rHCH3xR
cFz6IMbfCOdV+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M70Ye3uCP6E
TFYYdlnD+KHlXtaCKqu4vh9QEVV9lx6qx3Gh4gNcKYQwsGBtNi+QcGlR+cQZnIfQ
yNDmEqwON6sW2LqKSrkBjwN18jK3kDSSTMXKAEIM4OTTayqD9jdoA+j6pJ3QF8m5
MupQVzWmw8NNbNuPfGmsE/s=
=R7dX
-----END PGP PUBLIC KEY BLOCK-----

226
parted.spec Normal file
View File

@ -0,0 +1,226 @@
#
# spec file for package parted
#
# Copyright (c) 2022 SUSE LLC
#
# All modifications and additions to the file contributed by third parties
# remain the property of their copyright owners, unless otherwise agreed
# upon. The license for this file, and modifications and additions to the
# file, is the same license as for the pristine package itself (unless the
# license for the pristine package is not an Open Source License, in which
# case the license is the MIT License). An "Open Source License" is a
# license that conforms to the Open Source Definition (Version 1.9)
# published by the Open Source Initiative.
# Please submit bugfixes or comments via https://bugs.opensuse.org/
#
Name: parted
Version: 3.5
Release: 0
Summary: GNU partitioner
License: GPL-3.0-or-later
Group: System/Filesystems
URL: http://www.gnu.org/software/parted/
Source0: ftp://ftp.gnu.org/gnu/parted/%{name}-%{version}.tar.xz
Source1: ftp://ftp.gnu.org/gnu/parted/%{name}-%{version}.tar.xz.sig
# Taken from https://savannah.gnu.org/project/release-gpgkeys.php?group=parted&download=1
Source2: %{name}.keyring
Source3: baselibs.conf
Source4: fatresize-0.1.tar.bz2
# Build patches
Patch1: parted-2.4-ncursesw6.patch
# Other patches
Patch10: hfs_fix.dif
Patch11: parted-wipeaix.patch
Patch12: libparted-partition-naming.patch
#PATCH-FEATURE-SUSE more-reliable-informing-the-kernel.patch bnc#657360 petr.uzel@suse.cz
Patch13: more-reliable-informing-the-kernel.patch
Patch14: dummy-bootcode-only-for-x86.patch
Patch16: parted-mac.patch
Patch17: libparted-use-BLKRRPART-for-DASD.patch.patch
Patch18: libparted-make-BLKRRPART-more-robust.patch
Patch19: libparted-dasd-implicit-partition-disk-flag.patch
Patch21: libparted-avoid-libdevice-mapper-warnings.patch
# Patch31 dropped for bsc#1058667
Patch22: libparted-open-the-device-RO-and-lazily-switch-to-RW.patch
Patch23: parted-implement-wipesignatures-option.patch
# bsc#982169
Patch24: libparted-fix-nvme-partition-naming.patch
# fate#314888
Patch25: libparted-dasd-improve-lvm-raid-flag-handling.patch
Patch26: parted-mkpart-set-a-swap-flag-if-available.patch
Patch27: libparted-dasd-add-swap-flag-handling-for-DASD-CDL.patch
Patch29: libparted-fix-NVDIMM-partition-naming.patch
Patch31: parted-add-ignore-busy-option.patch
Patch32: parted-fix-resizepart-and-rm-command.patch
Patch33: libparted-use-BLKRRPART-only-when-needed.patch
Patch34: libparted-canonicalize-dev-md-paths.patch
# bsc#1168756
Patch36: libparted-linux-pmem-path.patch
# bsc#1164260
Patch37: parted-print-max-partitions-for-yast.patch
Patch38: direct-handling-of-partition-type-id-and-uuid.patch
Patch39: type-command.patch
# bsc#1164907
# Fatresize
Patch100: parted-fatresize-autoconf.patch
Patch101: fatresize-fix-getting-dev-name.patch
# Tests patches
Patch156: tests-add-helper-require_swap_.patch
Patch157: tests-add-dev-md-check-to-t6100.patch
Patch158: tests-disable.patch
# SUSE tests patches
Patch200: tests-adapt-to-SUSE.patch
BuildRequires: check-devel
BuildRequires: device-mapper-devel >= 1.02.33
BuildRequires: libblkid-devel >= 2.17
BuildRequires: libselinux-devel
BuildRequires: libsepol-devel
BuildRequires: libtool
BuildRequires: libuuid-devel
BuildRequires: makeinfo
BuildRequires: pkg-config
BuildRequires: python3-base
BuildRequires: readline-devel
PreReq: %install_info_prereq
BuildRoot: %{_tmppath}/%{name}-%{version}-build
# bug437293
%ifarch ppc64
Obsoletes: parted-64bit
%endif
%description
GNU Parted is a program for creating, destroying, resizing, checking,
and copying partitions, and the file systems on them.
%package -n libparted2
Summary: Library for manipulating partitions
Group: System/Libraries
Obsoletes: libparted0
%description -n libparted2
Libparted is a library for creating, destroying, resizing, checking
and copying partitions and the file systems on them.
%package -n libparted-fs-resize0
Summary: Library for manipulating partitions
Group: System/Libraries
%description -n libparted-fs-resize0
Libparted is a library for creating, destroying, resizing, checking
and copying partitions and the file systems on them.
%package devel
Summary: Parted Include Files and Libraries necessary for Development
Group: Development/Libraries/C and C++
Requires: device-mapper-devel >= 1.02.33
Requires: libparted-fs-resize0 = %version
Requires: libparted2 = %version
# bug437293
%ifarch ppc64
Obsoletes: parted-devel-64bit
%endif
%description devel
This package contains all necessary include files and libraries needed
to develop applications that require these.
%lang_package
%prep
%setup -a 4
%patch1 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch21 -p1
%patch22 -p1
%patch23 -p1
%patch24 -p1
%patch25 -p1
%patch26 -p1
%patch27 -p1
%patch29 -p1
%patch31 -p1
%patch32 -p1
%patch33 -p1
%patch34 -p1
%patch36 -p1
%patch37 -p1
%patch38 -p1
%patch39 -p1
%patch100 -p1
%patch101 -p1
%patch156 -p1
%patch157 -p1
%patch158 -p1
%patch200 -p1
%build
export CFLAGS="%{optflags} `ncursesw6-config --cflags`"
export LIBS="`ncursesw6-config --libs`"
AUTOPOINT=true autoreconf --force --install
%configure --disable-static \
--enable-device-mapper=yes \
--enable-dynamic-loading=no \
--enable-selinux \
--disable-silent-rules
make %{?_smp_mflags}
%check
make check
%install
%make_install
rm %{buildroot}%{_libdir}/*.la
%find_lang %{name}
%post
%install_info --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz
%preun
%install_info_delete --info-dir=%{_infodir} %{_infodir}/%{name}.info.gz
%post -n libparted2 -p /sbin/ldconfig
%postun -n libparted2 -p /sbin/ldconfig
%post -n libparted-fs-resize0 -p /sbin/ldconfig
%postun -n libparted-fs-resize0 -p /sbin/ldconfig
%files
%defattr(-,root,root)
%license COPYING
%doc AUTHORS BUGS ChangeLog NEWS README THANKS TODO
%{_sbindir}/*
%{_mandir}/man8/part*.8.gz
%doc %{_infodir}/*.info*
%files devel
%defattr(-,root,root)
%doc doc/API doc/FAT
%{_includedir}/*
%{_libdir}/pkgconfig/libparted*.pc
%{_libdir}/*.so
%files -n libparted2
%defattr(-,root,root)
%{_libdir}/libparted.so.*
%files -n libparted-fs-resize0
%defattr(-,root,root)
%{_libdir}/libparted-fs-resize.so.*
%files lang -f %{name}.lang
%changelog

121
tests-adapt-to-SUSE.patch Normal file
View File

@ -0,0 +1,121 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Wed Sep 13 11:14:42 2017 +0200
Subject: tests: Adapt to SUSE parted
Patch-mainline: no, custom SUSE patch
msdos type flag
Tests: t0283, t2200, t2310, t3200, t3300, t4100, t6002, t9042
For: parted-type.patch
Change dm partition name from 'pN' to '-partN'
Tests: t6001, t6002, t6004, t6005
For: libparted-partition-naming.patch
---
Index: parted-3.3/tests/t6001-psep.sh
===================================================================
--- parted-3.3.orig/tests/t6001-psep.sh
+++ parted-3.3/tests/t6001-psep.sh
@@ -31,9 +31,9 @@ linear2_=plinear-$$foo
d1= d2=
f1= f2=
cleanup_fn_() {
- dmsetup remove ${linear_}p1
+ dmsetup remove ${linear_}-part1
dmsetup remove $linear_
- dmsetup remove ${linear2_}1
+ dmsetup remove ${linear2_}-part1
dmsetup remove $linear2_
test -n "$d1" && losetup -d "$d1"
test -n "$d2" && losetup -d "$d2"
@@ -56,7 +56,7 @@ parted -s $dev mklabel msdos mkpart prim
compare /dev/null out || fail=1
#make sure device name is correct
-wait_for_dev_to_appear_ ${dev}p1 || fail=1
+wait_for_dev_to_appear_ ${dev}-part1 || fail=1
#repeat on name not ending in a digit
# setup: create a mapping
@@ -68,7 +68,7 @@ parted -s $dev mklabel msdos mkpart prim
compare /dev/null out || fail=1
#make sure device name is correct
-wait_for_dev_to_appear_ ${dev}1 || fail=1
+wait_for_dev_to_appear_ ${dev}-part1 || fail=1
if [ -n "$fail" ]; then
ls /dev/mapper
Index: parted-3.3/tests/t6004-dm-many-partitions.sh
===================================================================
--- parted-3.3.orig/tests/t6004-dm-many-partitions.sh
+++ parted-3.3/tests/t6004-dm-many-partitions.sh
@@ -50,10 +50,10 @@ parted -m -a min -s /dev/mapper/$dm_name
# Make sure all the partitions appeared under /dev/mapper/
for ((i=1; i<=$n_partitions; i+=1)); do
- wait_for_dev_to_appear_ "/dev/mapper/${dm_name}p$i" || { fail=1; break; }
+ wait_for_dev_to_appear_ "/dev/mapper/${dm_name}-part$i" || { fail=1; break; }
# remove the partitions as we go, otherwise cleanup won't work.
- dmsetup remove /dev/mapper/${dm_name}p$i
+ dmsetup remove /dev/mapper/${dm_name}-part$i
done
Exit $fail
Index: parted-3.3/tests/t6005-dm-uuid.sh
===================================================================
--- parted-3.3.orig/tests/t6005-dm-uuid.sh
+++ parted-3.3/tests/t6005-dm-uuid.sh
@@ -47,14 +47,14 @@ for ((i=1; i<=$n_partitions; i+=1)); do
cmd="$cmd mkpart p$i ${s}s ${s}s"
done
parted -m -a min -s /dev/mapper/$dm_name mklabel gpt $cmd > /dev/null 2>&1 || fail=1
-wait_for_dev_to_appear_ /dev/mapper/${dm_name}p${n_partitions} || fail=1
+wait_for_dev_to_appear_ /dev/mapper/${dm_name}-part${n_partitions} || fail=1
# Make sure all the partitions have UUIDs
for ((i=1; i<=$n_partitions; i+=1)); do
- dmsetup info /dev/mapper/${dm_name}p$i | grep UUID || fail=1
+ dmsetup info /dev/mapper/${dm_name}-part$i | grep UUID || fail=1
# remove the partitions as we go, otherwise cleanup won't work.
- dmsetup remove /dev/mapper/${dm_name}p$i
+ dmsetup remove /dev/mapper/${dm_name}-part$i
done
Exit $fail
Index: parted-3.3/tests/t6002-dm-busy.sh
===================================================================
--- parted-3.3.orig/tests/t6002-dm-busy.sh
+++ parted-3.3/tests/t6002-dm-busy.sh
@@ -35,9 +35,9 @@ d1=
f1=
dev=
cleanup_fn_() {
- umount "${dev}p2" > /dev/null 2>&1
- dmsetup remove ${linear_}p1
- dmsetup remove ${linear_}p2
+ umount "${dev}-part2" > /dev/null 2>&1
+ dmsetup remove ${linear_}-part1
+ dmsetup remove ${linear_}-part2
dmsetup remove $linear_
test -n "$d1" && losetup -d "$d1"
rm -f "$f1"
@@ -62,14 +62,14 @@ parted -s $dev -a none mkpart primary fa
compare /dev/null out || fail=1
# wait for new partition device to appear
-wait_for_dev_to_appear_ ${dev}p2 || fail_ ${dev}p2 did not appear
+wait_for_dev_to_appear_ ${dev}-part2 || fail_ ${dev}-part2 did not appear
-mkfs.vfat -F 32 ${dev}p2 || fail_ mkfs.vfat failed
+mkfs.vfat -F 32 ${dev}-part2 || fail_ mkfs.vfat failed
mount_point=$(pwd)/mnt
mkdir $mount_point || fail=1
-mount "${dev}p2" "$mount_point" || fail=1
+mount "${dev}-part2" "$mount_point" || fail=1
# Removal of unmounted partition must succeed.
parted -s "$dev" rm 1 > /dev/null 2>&1 || fail=1

View File

@ -0,0 +1,118 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Tue, 20 Feb 2018 12:16:26 +0100
Subject: tests: Add /dev/md/ check to t6100
For: libparted-canonicalize-dev-md-paths.patch
References: bsc#1078820
Patch-mainline: submitted, 2018-02-20
The test t6100 checks creating two partitions with /dev/md99 and
a gpt disk label. But using an md name with the symlink in /dev/md/
is not tested. That path might not be canonicalized and the BLKPG*
handling cannot find the existing partitions in /sys/block/$dev/.
That can be observed when creating the second partition while the
first one is in use.
So move common code to new functions create_mddev() and
remove_mdparts(), check if the swap tools are available, retest with
/dev/md/pedtest99, msdos disk label, and the first partition as swap.
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
tests/t6100-mdraid-partitions.sh | 62 +++++++++++++++++++++++++++++++++++-----
1 file changed, 55 insertions(+), 7 deletions(-)
Index: parted-3.3/tests/t6100-mdraid-partitions.sh
===================================================================
--- parted-3.3.orig/tests/t6100-mdraid-partitions.sh
+++ parted-3.3/tests/t6100-mdraid-partitions.sh
@@ -21,6 +21,7 @@
require_root_
require_scsi_debug_module_
require_mdadm_
+require_swap_
# create memory-backed device
scsi_debug_setup_ dev_size_mb=10 > dev-name ||
@@ -40,14 +41,28 @@ parted -s "$scsi_dev" mklabel gpt \
compare /dev/null out || fail=1
wait_for_dev_to_appear_ ${scsi_dev}2 || { fail=1; cat /proc/partitions; }
+create_mddev() {
+ # create mdraid on top of both partitions
+ mdadm -C $md_dev -e0 --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2"
+ wait_for_dev_to_appear_ ${md_dev} || { fail=1; cat /proc/partitions; }
+}
+
cleanup_fn_() {
# stop mdraid array
mdadm -S $md_dev || warn_ "Failed to stop MD array, $md_dev"
}
-# create mdraid on top of both partitions with v0.90 metadata
-mdadm -C $md_dev -e0 --force -R -l1 -n2 "${scsi_dev}1" "${scsi_dev}2"
-wait_for_dev_to_appear_ ${md_dev} || { fail=1; cat /proc/partitions; }
+remove_mdparts() {
+ # Remove partitions from the raid device.
+ parted -s $md_dev rm 2 rm 1 > out 2>&1 || fail=1
+ compare /dev/null out || fail=1
+
+ # Verify that kernel has been informed about those removals.
+ wait_for_dev_to_disappear_ ${md_dev}p1 2 || { fail=1; cat /proc/partitions; }
+ wait_for_dev_to_disappear_ ${md_dev}p2 2 || { fail=1; cat /proc/partitions; }
+}
+
+create_mddev
# create gpt and two partitions on the raid device
parted -s $md_dev mklabel gpt \
@@ -58,12 +73,45 @@ compare /dev/null out || fail=1
# Verify that kernel has been informed about the second device.
wait_for_dev_to_appear_ ${md_dev}p2 || { fail=1; cat /proc/partitions; }
-# Remove partitions from the raid device.
-parted -s $md_dev rm 2 rm 1 > out 2>&1 || fail=1
+remove_mdparts
+
+########################################################################
+# Second part with /dev/md/ symlink, msdos label and busy swap partition
+
+cleanup_fn_
+
+# Arbitrary name, not likely to be used already
+md_name=pedtest99
+md_dev=/dev/md/$md_name
+
+test -b $md_dev && skip_ "$md_dev already exists"
+
+create_mddev
+
+# create msdos and one partition on the raid device
+parted -s $md_dev mklabel msdos \
+ mkpart primary ext2 1M 2M > out 2>&1 || fail=1
+compare /dev/null out || fail=1
+
+# Verify that kernel has been informed about the device.
+wait_for_dev_to_appear_ ${md_dev}p1 || { fail=1; cat /proc/partitions; }
+
+# Create swap filesystem
+mkswap -f ${md_dev}p1 || fail=1
+
+# Use as swap to make it busy
+swapon ${md_dev}p1 || fail=1
+
+# create msdos and one partition on the raid device
+parted -s $md_dev mkpart primary ext2 2M 3M > out 2>&1 || fail=1
compare /dev/null out || fail=1
-# Verify that kernel has been informed about those removals.
-wait_for_dev_to_disappear_ ${md_dev}p1 2 || { fail=1; cat /proc/partitions; }
-wait_for_dev_to_disappear_ ${md_dev}p2 2 || { fail=1; cat /proc/partitions; }
+# Verify that kernel has been informed about the second device.
+wait_for_dev_to_appear_ ${md_dev}p2 || { fail=1; cat /proc/partitions; }
+
+# Disable swap again
+swapoff ${md_dev}p1 || warn_ "Failed to disable swap on ${md_dev}p1"
+
+remove_mdparts
Exit $fail

View File

@ -0,0 +1,32 @@
From: Sebastian Parschauer <sparschauer@suse.de>
Date: Tue, 20 Feb 2018 12:30:23 +0100
Subject: tests: Add helper 'require_swap_'
For: libparted-canonicalize-dev-md-paths.patch
References: bsc#1078820
Patch-mainline: submitted, 2018-02-20
To achieve that a partition is busy, it is easiest to use it as swap
partition. So check if mkswap, swapon, and swapoff are available.
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
---
tests/t-lib-helpers.sh | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/tests/t-lib-helpers.sh b/tests/t-lib-helpers.sh
index 9312343..962b4f1 100644
--- a/tests/t-lib-helpers.sh
+++ b/tests/t-lib-helpers.sh
@@ -362,6 +362,12 @@ require_xfs_()
mkfs.xfs -V || skip_ "this test requires XFS support"
}
+require_swap_()
+{
+ mkswap -V && swapon -V && swapoff -V || \
+ skip_ "this test requires swap support"
+}
+
require_dvhtool_()
{
dvhtool --help \

25
tests-disable.patch Normal file
View File

@ -0,0 +1,25 @@
diff --git a/libparted/tests/Makefile.am b/libparted/tests/Makefile.am
index c92a3a3..915bbc4 100644
--- a/libparted/tests/Makefile.am
+++ b/libparted/tests/Makefile.am
@@ -3,7 +3,7 @@
#
# 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 t2000-disk.sh t2100-zerolen.sh t3000-symlink.sh
EXTRA_DIST = $(TESTS)
check_PROGRAMS = label disk zerolen symlink volser
AM_CFLAGS = $(WARN_CFLAGS) $(WERROR_CFLAGS)
diff --git a/tests/Makefile.am b/tests/Makefile.am
index f9340aa..9d0d08f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -60,7 +60,6 @@ TESTS = \
t3200-type-change.sh \
t3210-gpt-type-change.sh \
t3300-palo-prep.sh \
- t3310-flags.sh \
t3400-whole-disk-FAT-partition.sh \
t4000-sun-raid-type.sh \
t4001-sun-vtoc.sh \

117
type-command.patch Normal file
View File

@ -0,0 +1,117 @@
--- a/parted/parted.c 2022-05-18 09:11:33.731616339 +0200
+++ b/parted/parted.c 2022-05-18 09:16:40.517372633 +0200
@@ -187,6 +187,8 @@
static const char* name_msg = N_("NAME is any word you want\n");
static const char* type_id_msg = N_("TYPE_ID is a value between 0x01 and 0xff\n");
static const char* type_uuid_msg = N_("TYPE_UUID is a non-null uuid\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"
@@ -1090,6 +1092,90 @@
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);
+
+ // 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;
+
+error_free_input:
+ free (input);
+error:
+ return 0;
+}
+
static char*
partition_print_flags (PedPartition const *part)
{
@@ -2581,6 +2667,14 @@
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,
str_list_create (