Accepting request 971283 from Base:System
OBS-URL: https://build.opensuse.org/request/show/971283 OBS-URL: https://build.opensuse.org/package/show/openSUSE:Factory/parted?expand=0&rev=136
This commit is contained in:
commit
c1aadaff61
557
direct-handling-of-partition-type-id-and-uuid.patch
Normal file
557
direct-handling-of-partition-type-id-and-uuid.patch
Normal 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"
|
||||||
|
]
|
@ -61,7 +61,7 @@ Index: parted-3.3/libparted/arch/linux.c
|
|||||||
if (!_partition_is_mounted_by_path (name)) {
|
if (!_partition_is_mounted_by_path (name)) {
|
||||||
- fd = open (name, WR_MODE, 0);
|
- fd = open (name, WR_MODE, 0);
|
||||||
+ fd = open (name, RD_MODE, 0);
|
+ fd = open (name, RD_MODE, 0);
|
||||||
if (fd > 0) {
|
if (fd > -1) {
|
||||||
ioctl (fd, BLKFLSBUF);
|
ioctl (fd, BLKFLSBUF);
|
||||||
retry:
|
retry:
|
||||||
@@ -1709,7 +1728,7 @@ _device_open_ro (PedDevice* dev)
|
@@ -1709,7 +1728,7 @@ _device_open_ro (PedDevice* dev)
|
||||||
|
@ -9,17 +9,17 @@ Index: parted-3.3/configure.ac
|
|||||||
===================================================================
|
===================================================================
|
||||||
--- parted-3.3.orig/configure.ac
|
--- parted-3.3.orig/configure.ac
|
||||||
+++ parted-3.3/configure.ac
|
+++ parted-3.3/configure.ac
|
||||||
@@ -151,7 +151,8 @@ AM_CPPFLAGS="$AM_CPPFLAGS -D_REENTRANT"
|
@@ -147,7 +147,8 @@ AM_CPPFLAGS="$AM_CPPFLAGS -D_REENTRANT"
|
||||||
|
|
||||||
dnl Check for programs.
|
dnl Check for programs.
|
||||||
AC_ISC_POSIX
|
AC_SEARCH_LIBS([strerror],[cposix])
|
||||||
-AC_PROG_CC
|
-AC_PROG_CC
|
||||||
+AC_PROG_CC_STDC
|
+AC_PROG_CC_STDC
|
||||||
+AC_USE_SYSTEM_EXTENSIONS
|
+AC_USE_SYSTEM_EXTENSIONS
|
||||||
AC_PROG_GCC_TRADITIONAL
|
AC_PROG_GCC_TRADITIONAL
|
||||||
AM_PROG_CC_C_O
|
AM_PROG_CC_C_O
|
||||||
|
|
||||||
@@ -331,7 +332,7 @@ dnl Check for termcap
|
@@ -320,7 +321,7 @@ dnl Check for termcap
|
||||||
if test "$with_readline" = yes; then
|
if test "$with_readline" = yes; then
|
||||||
OLD_LIBS="$LIBS"
|
OLD_LIBS="$LIBS"
|
||||||
LIBS=""
|
LIBS=""
|
||||||
|
@ -1,3 +0,0 @@
|
|||||||
version https://git-lfs.github.com/spec/v1
|
|
||||||
oid sha256:e1298022472da5589b7f2be1d5ee3c1b66ec3d96dfbad03dc642afd009da5342
|
|
||||||
size 1860300
|
|
@ -1,11 +0,0 @@
|
|||||||
-----BEGIN PGP SIGNATURE-----
|
|
||||||
|
|
||||||
iQFDBAABCgAtFiEEtMa0UeT6i0IyyhkeEX6MFo7+On8FAmASBNUPHGJjbEByZWRo
|
|
||||||
YXQuY29tAAoJEBF+jBaO/jp/blAH+gNmum3xO2/fZhwRUo1mmb+qP9MlAexjt9VJ
|
|
||||||
KX79/5ICIFSubVLxzsJTN5g3hZQUoui3qcgdJhnp14bK3hSsvBKtvAAUp+myB+1t
|
|
||||||
9aypzK+qvw32aaCtPfS00qe4Re2ry6LyuW7hsATPIvcQWF/Xc76FLzG6ilzshxS0
|
|
||||||
iftCM/NSp3aGBcNa4Ru3TkbQ1vFtuKYkt24hItODtrYAMGb2IQzSPHCbZw1kfV/J
|
|
||||||
pypllYB7A6ykr9xqhXPW30d3hERmvcJS0LoUzzEmHRf4YYkYk2N0BQoa4KYI1ULX
|
|
||||||
rlpG+iJSc0RN8EgHwecdHfPN3umE2UXn3aYCS5GX2Dn9xPsjaSM=
|
|
||||||
=HdSF
|
|
||||||
-----END PGP SIGNATURE-----
|
|
BIN
parted-3.5.tar.xz
(Stored with Git LFS)
Normal file
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
11
parted-3.5.tar.xz.sig
Normal 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-----
|
@ -37,7 +37,7 @@ Index: parted-3.3/parted/parted.c
|
|||||||
===================================================================
|
===================================================================
|
||||||
--- parted-3.3.orig/parted/parted.c
|
--- parted-3.3.orig/parted/parted.c
|
||||||
+++ parted-3.3/parted/parted.c
|
+++ parted-3.3/parted/parted.c
|
||||||
@@ -76,7 +76,8 @@ static int MEGABYTE_SECTORS (PedDevice*
|
@@ -76,8 +76,9 @@ static int MEGABYTE_SECTORS (PedDevice*
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
PRETEND_INPUT_TTY = CHAR_MAX + 1,
|
PRETEND_INPUT_TTY = CHAR_MAX + 1,
|
||||||
@ -46,9 +46,10 @@ Index: parted-3.3/parted/parted.c
|
|||||||
+ WIPESIGNATURES = CHAR_MAX + 3,
|
+ WIPESIGNATURES = CHAR_MAX + 3,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/* Output modes */
|
||||||
enum
|
enum
|
||||||
@@ -118,6 +119,7 @@ static struct option const options[] = {
|
@@ -118,6 +119,7 @@ static struct option const options[] = {
|
||||||
{"script", 0, NULL, 's'},
|
{"fix", 0, NULL, 'f'},
|
||||||
{"version", 0, NULL, 'v'},
|
{"version", 0, NULL, 'v'},
|
||||||
{"align", required_argument, NULL, 'a'},
|
{"align", required_argument, NULL, 'a'},
|
||||||
+ {"ignore-busy", 0, NULL, IGNORE_BUSY},
|
+ {"ignore-busy", 0, NULL, IGNORE_BUSY},
|
||||||
@ -56,7 +57,7 @@ Index: parted-3.3/parted/parted.c
|
|||||||
{"-pretend-input-tty", 0, NULL, PRETEND_INPUT_TTY},
|
{"-pretend-input-tty", 0, NULL, PRETEND_INPUT_TTY},
|
||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
@@ -130,10 +132,13 @@ static const char *const options_help []
|
@@ -130,10 +132,13 @@ static const char *const options_help []
|
||||||
{"script", N_("never prompts for user intervention")},
|
{"fix", N_("in script mode, fix instead of abort when asked")},
|
||||||
{"version", N_("displays the version")},
|
{"version", N_("displays the version")},
|
||||||
{"align=[none|cyl|min|opt]", N_("alignment for new partitions")},
|
{"align=[none|cyl|min|opt]", N_("alignment for new partitions")},
|
||||||
+ {"ignore-busy", N_("perform action although partition is busy")},
|
+ {"ignore-busy", N_("perform action although partition is busy")},
|
||||||
@ -67,8 +68,8 @@ Index: parted-3.3/parted/parted.c
|
|||||||
+#define LONGOPT_HELP_START 6 /* index to first long option help */
|
+#define LONGOPT_HELP_START 6 /* index to first long option help */
|
||||||
+
|
+
|
||||||
int opt_script_mode = 0;
|
int opt_script_mode = 0;
|
||||||
|
int opt_fix_mode = 0;
|
||||||
int pretend_input_tty = 0;
|
int pretend_input_tty = 0;
|
||||||
int wipesignatures = 0;
|
|
||||||
@@ -141,6 +146,7 @@ int opt_machine_mode = 0;
|
@@ -141,6 +146,7 @@ int opt_machine_mode = 0;
|
||||||
int disk_is_modified = 0;
|
int disk_is_modified = 0;
|
||||||
int is_toggle_mode = 0;
|
int is_toggle_mode = 0;
|
||||||
|
@ -1,79 +0,0 @@
|
|||||||
From: Sebastian Parschauer <sparschauer@suse.de>
|
|
||||||
Date: Tue, 7 Nov 2017 20:14:06 +0100
|
|
||||||
Subject: parted: Escape printed device path in machine mode
|
|
||||||
References: bsc#1066467
|
|
||||||
Patch-mainline: submitted, 2017-11-07
|
|
||||||
|
|
||||||
The function _print_disk_info() uses the colon ':' as the separator
|
|
||||||
but the device path it prints can contain that character as well.
|
|
||||||
In that case parsing fails.
|
|
||||||
So introduce the function _escape_machine_string() to allocate an
|
|
||||||
output string twice as big as the input string and escape ':' and
|
|
||||||
'\' with a '\'. Print the escaped path and free it again. Ignore
|
|
||||||
the NULL pointer dereference in out-of-memory situation like it
|
|
||||||
is done for the other allocations in _print_disk_info() as well.
|
|
||||||
|
|
||||||
Resolves: bsc#1066467
|
|
||||||
|
|
||||||
Reported-by: Arvin Schnell <aschnell@suse.com>
|
|
||||||
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
|
|
||||||
---
|
|
||||||
parted/parted.c | 29 ++++++++++++++++++++++++++++-
|
|
||||||
1 file changed, 28 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
Index: parted-3.3/parted/parted.c
|
|
||||||
===================================================================
|
|
||||||
--- parted-3.3.orig/parted/parted.c
|
|
||||||
+++ parted-3.3/parted/parted.c
|
|
||||||
@@ -1053,6 +1053,30 @@ _print_disk_geometry (const PedDevice *d
|
|
||||||
free (cyl_size);
|
|
||||||
}
|
|
||||||
|
|
||||||
+static char *
|
|
||||||
+_escape_machine_string (const char *str)
|
|
||||||
+{
|
|
||||||
+ size_t i, j;
|
|
||||||
+ char *dest;
|
|
||||||
+
|
|
||||||
+ dest = ped_malloc ((strlen(str) + 1) * 2);
|
|
||||||
+ if (!dest)
|
|
||||||
+ return NULL;
|
|
||||||
+
|
|
||||||
+ for (i = 0, j = 0; str[i] != '\0'; i++, j++) {
|
|
||||||
+ switch (str[i]) {
|
|
||||||
+ case ':':
|
|
||||||
+ case '\\':
|
|
||||||
+ dest[j++] = '\\';
|
|
||||||
+ default:
|
|
||||||
+ dest[j] = str[i];
|
|
||||||
+ break;
|
|
||||||
+ }
|
|
||||||
+ }
|
|
||||||
+ dest[j] = '\0';
|
|
||||||
+ return dest;
|
|
||||||
+}
|
|
||||||
+
|
|
||||||
static void
|
|
||||||
_print_disk_info (const PedDevice *dev, const PedDisk *diskp)
|
|
||||||
{
|
|
||||||
@@ -1073,6 +1097,8 @@ _print_disk_info (const PedDevice *dev,
|
|
||||||
char *disk_flags = disk_print_flags (diskp);
|
|
||||||
|
|
||||||
if (opt_machine_mode) {
|
|
||||||
+ char *path = _escape_machine_string (dev->path);
|
|
||||||
+
|
|
||||||
switch (default_unit) {
|
|
||||||
case PED_UNIT_CHS: puts ("CHS;");
|
|
||||||
break;
|
|
||||||
@@ -1083,9 +1109,10 @@ _print_disk_info (const PedDevice *dev,
|
|
||||||
|
|
||||||
}
|
|
||||||
printf ("%s:%s:%s:%lld:%lld:%s:%s:%s;\n",
|
|
||||||
- dev->path, end, transport[dev->type],
|
|
||||||
+ path, end, transport[dev->type],
|
|
||||||
dev->sector_size, dev->phys_sector_size,
|
|
||||||
pt_name, dev->model, disk_flags);
|
|
||||||
+ free(path);
|
|
||||||
} else {
|
|
||||||
printf (_("Model: %s (%s)\n"),
|
|
||||||
dev->model, transport[dev->type]);
|
|
@ -77,16 +77,7 @@ Index: parted-3.3/parted/parted.c
|
|||||||
goto error;
|
goto error;
|
||||||
|
|
||||||
/* Push the End value back onto the command_line, if it exists */
|
/* Push the End value back onto the command_line, if it exists */
|
||||||
@@ -1681,19 +1693,32 @@ do_resizepart (PedDevice** dev, PedDisk*
|
@@ -1871,13 +1873,23 @@ do_resizepart (PedDevice** dev, PedDisk*
|
||||||
goto error;
|
|
||||||
_adjust_end_if_iec(&start, &end, range_end, end_input);
|
|
||||||
free(end_input);
|
|
||||||
+ if (cmdline_words >= end_idx && !_partition_warn_busy (part, danger_if_busy))
|
|
||||||
+ goto error;
|
|
||||||
+
|
|
||||||
/* Do not move start of the partition */
|
|
||||||
constraint = constraint_from_start_end_fixed_start (*dev, start, range_end);
|
|
||||||
if (!ped_disk_set_partition_geom (disk, part, constraint,
|
|
||||||
start, end))
|
start, end))
|
||||||
goto error_destroy_constraint;
|
goto error_destroy_constraint;
|
||||||
/* warn when shrinking partition - might lose data */
|
/* warn when shrinking partition - might lose data */
|
||||||
@ -105,9 +96,8 @@ Index: parted-3.3/parted/parted.c
|
|||||||
PED_EXCEPTION_YES_NO,
|
PED_EXCEPTION_YES_NO,
|
||||||
_("Shrinking a partition can cause data loss, " \
|
_("Shrinking a partition can cause data loss, " \
|
||||||
"are you sure you want to continue?")) != PED_EXCEPTION_YES)
|
"are you sure you want to continue?")) != PED_EXCEPTION_YES)
|
||||||
- goto error_destroy_constraint;
|
|
||||||
+ {
|
+ {
|
||||||
+ goto error_destroy_constraint;
|
goto error_destroy_constraint;
|
||||||
+ }
|
+ }
|
||||||
+ }
|
+ }
|
||||||
ped_disk_commit (disk);
|
ped_disk_commit (disk);
|
||||||
|
@ -148,9 +148,9 @@ Index: parted-3.3/parted/parted.c
|
|||||||
+ WIPESIGNATURES = CHAR_MAX + 2,
|
+ WIPESIGNATURES = CHAR_MAX + 2,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
/* Output modes */
|
||||||
@@ -117,6 +118,7 @@ static struct option const options[] = {
|
@@ -117,6 +118,7 @@ static struct option const options[] = {
|
||||||
{"script", 0, NULL, 's'},
|
{"fix", 0, NULL, 'f'},
|
||||||
{"version", 0, NULL, 'v'},
|
{"version", 0, NULL, 'v'},
|
||||||
{"align", required_argument, NULL, 'a'},
|
{"align", required_argument, NULL, 'a'},
|
||||||
+ {"wipesignatures", 0, NULL, WIPESIGNATURES},
|
+ {"wipesignatures", 0, NULL, WIPESIGNATURES},
|
||||||
@ -158,7 +158,6 @@ Index: parted-3.3/parted/parted.c
|
|||||||
{NULL, 0, NULL, 0}
|
{NULL, 0, NULL, 0}
|
||||||
};
|
};
|
||||||
@@ -128,11 +130,13 @@ static const char *const options_help []
|
@@ -128,11 +130,13 @@ static const char *const options_help []
|
||||||
{"script", N_("never prompts for user intervention")},
|
|
||||||
{"version", N_("displays the version")},
|
{"version", N_("displays the version")},
|
||||||
{"align=[none|cyl|min|opt]", N_("alignment for new partitions")},
|
{"align=[none|cyl|min|opt]", N_("alignment for new partitions")},
|
||||||
+ {"wipesignatures", N_("wipe superblock signatures when creating partition")},
|
+ {"wipesignatures", N_("wipe superblock signatures when creating partition")},
|
||||||
@ -166,9 +165,10 @@ Index: parted-3.3/parted/parted.c
|
|||||||
};
|
};
|
||||||
|
|
||||||
int opt_script_mode = 0;
|
int opt_script_mode = 0;
|
||||||
|
int opt_fix_mode = 0;
|
||||||
int pretend_input_tty = 0;
|
int pretend_input_tty = 0;
|
||||||
|
int opt_output_mode = HUMAN;
|
||||||
+int wipesignatures = 0;
|
+int wipesignatures = 0;
|
||||||
int opt_machine_mode = 0;
|
|
||||||
int disk_is_modified = 0;
|
int disk_is_modified = 0;
|
||||||
int is_toggle_mode = 0;
|
int is_toggle_mode = 0;
|
||||||
@@ -651,6 +655,7 @@ _adjust_end_if_iec (PedSector* start, Pe
|
@@ -651,6 +655,7 @@ _adjust_end_if_iec (PedSector* start, Pe
|
||||||
|
14
parted-json-no-type-flag.patch
Normal file
14
parted-json-no-type-flag.patch
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
diff --git a/parted/parted.c b/parted/parted.c
|
||||||
|
index 5c7c270..aa68d58 100644
|
||||||
|
--- a/parted/parted.c
|
||||||
|
+++ b/parted/parted.c
|
||||||
|
@@ -956,6 +956,9 @@ partition_print_flags_json (PedPartition const *part)
|
||||||
|
for (flag = ped_partition_flag_next (0); flag;
|
||||||
|
flag = ped_partition_flag_next (flag))
|
||||||
|
{
|
||||||
|
+ if (flag == PED_PARTITION_TYPE)
|
||||||
|
+ continue;
|
||||||
|
+
|
||||||
|
if (ped_partition_get_flag (part, flag))
|
||||||
|
{
|
||||||
|
if (!did_open_array)
|
@ -1,68 +0,0 @@
|
|||||||
From: Sebastian Parschauer <sparschauer@suse.de>
|
|
||||||
Date: Fri, 11 Aug 2017 12:46:42 +0200
|
|
||||||
Subject: parted/ui: Count empty quoted strings as words in multi_word
|
|
||||||
mode
|
|
||||||
References: bsc#1023818, boo#1032562
|
|
||||||
Patch-mainline: submitted, 2017-08-11
|
|
||||||
|
|
||||||
In non-interactive mode, the command line arguments are appended
|
|
||||||
to a string list with command_line_push_line() in multi_word mode.
|
|
||||||
That mode does not count empty strings as a word.
|
|
||||||
For mkpart and a GPT disk label, the partition name is picked up
|
|
||||||
from that string list. The partition name is mandatory and we
|
|
||||||
cannot make it optional. So it is not possible to set an empty
|
|
||||||
partition name from command line this way.
|
|
||||||
Also setting a default name is no option as this causes duplicate
|
|
||||||
/dev/disk/by-partlabel/ symlinks and systemd errors this way.
|
|
||||||
|
|
||||||
So count empty quoted strings as words in multi_word mode to allow
|
|
||||||
the following commands to set an empty partition name.
|
|
||||||
|
|
||||||
parted -s /dev/vdb mkpart "''" 1MiB 100%
|
|
||||||
parted -s /dev/vdb mkpart '""' ext3 1MiB 100%
|
|
||||||
parted -s /dev/vdb name 1 "''"
|
|
||||||
|
|
||||||
The quoting is required as in interactive mode the command
|
|
||||||
"mkpart " (with a trailing space) would set the partition name to
|
|
||||||
an empty string already.
|
|
||||||
|
|
||||||
Signed-off-by: Sebastian Parschauer <sparschauer@suse.de>
|
|
||||||
---
|
|
||||||
parted/ui.c | 8 +++++++-
|
|
||||||
1 file changed, 7 insertions(+), 1 deletion(-)
|
|
||||||
|
|
||||||
diff --git a/parted/ui.c b/parted/ui.c
|
|
||||||
index 752860baa087..9991596a3a5a 100644
|
|
||||||
--- a/parted/ui.c
|
|
||||||
+++ b/parted/ui.c
|
|
||||||
@@ -719,6 +719,7 @@ void
|
|
||||||
command_line_push_line (const char* line, int multi_word)
|
|
||||||
{
|
|
||||||
int quoted = 0;
|
|
||||||
+ int quotes_empty = 0;
|
|
||||||
char quote_char = 0;
|
|
||||||
char this_word [256];
|
|
||||||
int i;
|
|
||||||
@@ -746,6 +747,9 @@ command_line_push_line (const char* line, int multi_word)
|
|
||||||
|
|
||||||
if (quoted && *line == quote_char) {
|
|
||||||
quoted = 0;
|
|
||||||
+ /* allow empty partition name in script mode */
|
|
||||||
+ if (!i)
|
|
||||||
+ quotes_empty = 1;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -753,9 +757,11 @@ command_line_push_line (const char* line, int multi_word)
|
|
||||||
if (quoted && line[0] == '\\' && line[1])
|
|
||||||
line++;
|
|
||||||
|
|
||||||
+ quotes_empty = 0;
|
|
||||||
this_word [i++] = *line;
|
|
||||||
}
|
|
||||||
- if (i || !multi_word) {
|
|
||||||
+ if (i || !multi_word || quotes_empty) {
|
|
||||||
+ quotes_empty = 0;
|
|
||||||
this_word [i] = 0;
|
|
||||||
command_line_push_word (this_word);
|
|
||||||
}
|
|
@ -13,12 +13,12 @@ Index: parted-3.3/parted/parted.c
|
|||||||
}
|
}
|
||||||
- printf ("%s:%s:%s:%lld:%lld:%s:%s:%s;\n",
|
- printf ("%s:%s:%s:%lld:%lld:%s:%s:%s;\n",
|
||||||
+ printf ("%s:%s:%s:%lld:%lld:%s:%s:%s",
|
+ printf ("%s:%s:%s:%lld:%lld:%s:%s:%s",
|
||||||
path, end, transport[dev->type],
|
escaped_path, end, transport[dev->type],
|
||||||
dev->sector_size, dev->phys_sector_size,
|
dev->sector_size, dev->phys_sector_size,
|
||||||
pt_name, dev->model, disk_flags);
|
pt_name, escaped_model, disk_flags);
|
||||||
+ if (getenv("PARTED_PRINT_NUMBER_OF_PARTITION_SLOTS"))
|
+ 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(":%lld", diskp && diskp->type->ops->get_max_primary_partition_count ? diskp->type->ops->get_max_primary_partition_count(diskp) : 0);
|
||||||
+ printf(";\n");
|
+ printf(";\n");
|
||||||
free(path);
|
free (escaped_path);
|
||||||
} else {
|
free (escaped_model);
|
||||||
printf (_("Model: %s (%s)\n"),
|
} else if (opt_output_mode == JSON) {
|
||||||
|
@ -16,16 +16,14 @@ Index: parted-3.3/include/parted/disk.in.h
|
|||||||
===================================================================
|
===================================================================
|
||||||
--- parted-3.3.orig/include/parted/disk.in.h
|
--- parted-3.3.orig/include/parted/disk.in.h
|
||||||
+++ parted-3.3/include/parted/disk.in.h
|
+++ parted-3.3/include/parted/disk.in.h
|
||||||
@@ -78,10 +78,11 @@
|
@@ -86,9 +86,10 @@
|
||||||
PED_PARTITION_IRST=17,
|
|
||||||
PED_PARTITION_ESP=18,
|
|
||||||
PED_PARTITION_CHROMEOS_KERNEL=19,
|
PED_PARTITION_CHROMEOS_KERNEL=19,
|
||||||
- PED_PARTITION_BLS_BOOT=20
|
PED_PARTITION_BLS_BOOT=20,
|
||||||
+ PED_PARTITION_BLS_BOOT=20,
|
PED_PARTITION_LINUX_HOME=21,
|
||||||
+ PED_PARTITION_TYPE=21
|
+ PED_PARTITION_TYPE=22,
|
||||||
};
|
};
|
||||||
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
|
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
|
||||||
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_BLS_BOOT
|
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_LINUX_HOME
|
||||||
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_TYPE
|
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_TYPE
|
||||||
|
|
||||||
enum _PedDiskTypeFeature {
|
enum _PedDiskTypeFeature {
|
||||||
@ -69,8 +67,8 @@ Index: parted-3.3/libparted/labels/dos.c
|
|||||||
return dos_data->palo;
|
return dos_data->palo;
|
||||||
|
|
||||||
@@ -1728,6 +1735,7 @@ msdos_partition_is_flag_available (const
|
@@ -1728,6 +1735,7 @@ msdos_partition_is_flag_available (const
|
||||||
case PED_PARTITION_RAID:
|
|
||||||
case PED_PARTITION_LVM:
|
case PED_PARTITION_LVM:
|
||||||
|
case PED_PARTITION_SWAP:
|
||||||
case PED_PARTITION_LBA:
|
case PED_PARTITION_LBA:
|
||||||
+ case PED_PARTITION_TYPE:
|
+ case PED_PARTITION_TYPE:
|
||||||
case PED_PARTITION_PALO:
|
case PED_PARTITION_PALO:
|
||||||
@ -80,7 +78,7 @@ Index: parted-3.3/parted/parted.c
|
|||||||
===================================================================
|
===================================================================
|
||||||
--- parted-3.3.orig/parted/parted.c
|
--- parted-3.3.orig/parted/parted.c
|
||||||
+++ parted-3.3/parted/parted.c
|
+++ parted-3.3/parted/parted.c
|
||||||
@@ -928,28 +928,40 @@ error:
|
@@ -946,28 +946,40 @@ error:
|
||||||
static char*
|
static char*
|
||||||
partition_print_flags (PedPartition const *part)
|
partition_print_flags (PedPartition const *part)
|
||||||
{
|
{
|
||||||
@ -139,7 +137,7 @@ Index: parted-3.3/parted/parted.c
|
|||||||
+ return res;
|
+ return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int
|
static void
|
||||||
@@ -1808,12 +1820,19 @@ do_set (PedDevice** dev, PedDisk **diskp
|
@@ -1808,12 +1820,19 @@ do_set (PedDevice** dev, PedDisk **diskp
|
||||||
goto error;
|
goto error;
|
||||||
if (!command_line_get_part_flag (_("Flag to Invert?"), part, &flag))
|
if (!command_line_get_part_flag (_("Flag to Invert?"), part, &flag))
|
||||||
|
@ -1,3 +1,26 @@
|
|||||||
|
-------------------------------------------------------------------
|
||||||
|
Wed Apr 20 09:11:11 CEST 2022 - aschnell@suse.com
|
||||||
|
|
||||||
|
- update to version 3.5:
|
||||||
|
* Add support for JSON output.
|
||||||
|
* Add support for linux-home flag for GPT.
|
||||||
|
* Add --fix option.
|
||||||
|
added patches:
|
||||||
|
- direct-handling-of-partition-type-id-and-uuid.patch
|
||||||
|
- parted-json-no-type-flag.patch
|
||||||
|
refreshed patches:
|
||||||
|
- libparted-open-the-device-RO-and-lazily-switch-to-RW.patch
|
||||||
|
- parted-2.4-ncursesw6.patch
|
||||||
|
- parted-add-ignore-busy-option.patch
|
||||||
|
- parted-fix-resizepart-and-rm-command.patch
|
||||||
|
- parted-implement-wipesignatures-option.patch
|
||||||
|
- parted-print-max-partitions-for-yast.patch
|
||||||
|
- parted-type.patch
|
||||||
|
- tests-disable.patch
|
||||||
|
removed patches:
|
||||||
|
- parted-escape-printed-device-path.patch
|
||||||
|
- parted-mkpart-allow-empty-gpt-part-name.patch
|
||||||
|
|
||||||
-------------------------------------------------------------------
|
-------------------------------------------------------------------
|
||||||
Tue Oct 19 13:16:11 CEST 2021 - aschnell@suse.com
|
Tue Oct 19 13:16:11 CEST 2021 - aschnell@suse.com
|
||||||
|
|
||||||
|
14
parted.spec
14
parted.spec
@ -1,7 +1,7 @@
|
|||||||
#
|
#
|
||||||
# spec file for package parted
|
# spec file for package parted
|
||||||
#
|
#
|
||||||
# Copyright (c) 2021 SUSE LLC
|
# Copyright (c) 2022 SUSE LLC
|
||||||
#
|
#
|
||||||
# All modifications and additions to the file contributed by third parties
|
# All modifications and additions to the file contributed by third parties
|
||||||
# remain the property of their copyright owners, unless otherwise agreed
|
# remain the property of their copyright owners, unless otherwise agreed
|
||||||
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
|
|
||||||
Name: parted
|
Name: parted
|
||||||
Version: 3.4
|
Version: 3.5
|
||||||
Release: 0
|
Release: 0
|
||||||
Summary: GNU partitioner
|
Summary: GNU partitioner
|
||||||
License: GPL-3.0-or-later
|
License: GPL-3.0-or-later
|
||||||
@ -53,19 +53,17 @@ Patch24: libparted-fix-nvme-partition-naming.patch
|
|||||||
Patch25: libparted-dasd-improve-lvm-raid-flag-handling.patch
|
Patch25: libparted-dasd-improve-lvm-raid-flag-handling.patch
|
||||||
Patch26: parted-mkpart-set-a-swap-flag-if-available.patch
|
Patch26: parted-mkpart-set-a-swap-flag-if-available.patch
|
||||||
Patch27: libparted-dasd-add-swap-flag-handling-for-DASD-CDL.patch
|
Patch27: libparted-dasd-add-swap-flag-handling-for-DASD-CDL.patch
|
||||||
Patch28: parted-mkpart-allow-empty-gpt-part-name.patch
|
|
||||||
Patch29: libparted-fix-NVDIMM-partition-naming.patch
|
Patch29: libparted-fix-NVDIMM-partition-naming.patch
|
||||||
Patch30: parted-escape-printed-device-path.patch
|
|
||||||
Patch31: parted-add-ignore-busy-option.patch
|
Patch31: parted-add-ignore-busy-option.patch
|
||||||
Patch32: parted-fix-resizepart-and-rm-command.patch
|
Patch32: parted-fix-resizepart-and-rm-command.patch
|
||||||
Patch33: libparted-use-BLKRRPART-only-when-needed.patch
|
Patch33: libparted-use-BLKRRPART-only-when-needed.patch
|
||||||
Patch34: libparted-canonicalize-dev-md-paths.patch
|
Patch34: libparted-canonicalize-dev-md-paths.patch
|
||||||
|
Patch35: parted-json-no-type-flag.patch
|
||||||
# bsc#1168756
|
# bsc#1168756
|
||||||
Patch36: libparted-linux-pmem-path.patch
|
Patch36: libparted-linux-pmem-path.patch
|
||||||
|
|
||||||
# bsc#1164260
|
# bsc#1164260
|
||||||
Patch37: parted-print-max-partitions-for-yast.patch
|
Patch37: parted-print-max-partitions-for-yast.patch
|
||||||
|
Patch38: direct-handling-of-partition-type-id-and-uuid.patch
|
||||||
# bsc#1164907
|
# bsc#1164907
|
||||||
Patch64: parted-type-accept-hex.patch
|
Patch64: parted-type-accept-hex.patch
|
||||||
# Fatresize
|
# Fatresize
|
||||||
@ -155,15 +153,15 @@ to develop applications that require these.
|
|||||||
%patch25 -p1
|
%patch25 -p1
|
||||||
%patch26 -p1
|
%patch26 -p1
|
||||||
%patch27 -p1
|
%patch27 -p1
|
||||||
%patch28 -p1
|
|
||||||
%patch29 -p1
|
%patch29 -p1
|
||||||
%patch30 -p1
|
|
||||||
%patch31 -p1
|
%patch31 -p1
|
||||||
%patch32 -p1
|
%patch32 -p1
|
||||||
%patch33 -p1
|
%patch33 -p1
|
||||||
%patch34 -p1
|
%patch34 -p1
|
||||||
|
%patch35 -p1
|
||||||
%patch36 -p1
|
%patch36 -p1
|
||||||
%patch37 -p1
|
%patch37 -p1
|
||||||
|
%patch38 -p1
|
||||||
%patch64 -p1
|
%patch64 -p1
|
||||||
%patch100 -p1
|
%patch100 -p1
|
||||||
%patch101 -p1
|
%patch101 -p1
|
||||||
|
@ -16,8 +16,8 @@ index f9340aa..9d0d08f 100644
|
|||||||
--- a/tests/Makefile.am
|
--- a/tests/Makefile.am
|
||||||
+++ b/tests/Makefile.am
|
+++ b/tests/Makefile.am
|
||||||
@@ -60,7 +60,6 @@ TESTS = \
|
@@ -60,7 +60,6 @@ TESTS = \
|
||||||
t3200-resize-partition.sh \
|
|
||||||
t3200-type-change.sh \
|
t3200-type-change.sh \
|
||||||
|
t3210-gpt-type-change.sh \
|
||||||
t3300-palo-prep.sh \
|
t3300-palo-prep.sh \
|
||||||
- t3310-flags.sh \
|
- t3310-flags.sh \
|
||||||
t3400-whole-disk-FAT-partition.sh \
|
t3400-whole-disk-FAT-partition.sh \
|
||||||
|
Loading…
Reference in New Issue
Block a user