parted/parted-type.patch
Marcus Meissner 5b97712c80 Accepting request 712877 from home:anicka:branches:Base:System
- port fixes for various bugs from upstream (bsc#1136245)
 - add: libparted-dasd-correct-the-offset-where-the-first-pa.patch
   4126d02, correct the offset where the first partition begins. 
   This patch implements libparted-dasd-do-not-use-first-tracks.patch 
 - remove: libparted-dasd-do-not-use-first-tracks.patch
 - add: parted-fix-crash-due-to-improper-partition-number-in.patch
   149f009, fix crash due to improper partition number input,
   changed call to strtol, use base 0 to fit our parted-type.patch
 - modify: parted-type.patch (removed ui.c part)
 - add: parted-check-the-name-of-partition-first-when-to-nam.patch
   d7a2ff1, check the name of partition first when to name a partition
 - add: libparted-dasd-add-test-cases-for-the-new-fdasd-func.patch 
   c11f5c0, 571e078, add test cases for the new fdasd functions
 - add: libparted-dasd-add-an-exception-for-changing-DASD-LD.patch
   ee2c0c2, add an exception for changing DASD-LDL partition table
 - add: libpartd-dasd-improve-flag-processing-for-DASD-LDL.patch
   1545d6d, improve flag processing for DASD-LDL
 - add: clean-the-disk-information-when-commands-fail-in-int.patch
   5a61f15, clean the disk information when commands fail in 
   interactive mode
 - add: parted-ui-remove-unneccesary-information-of-command.patch
   0b7946a, remove unneccesary information of command line
 - add: parted-fix-wrong-error-label-jump-in-mkpart.patch
   af150f6, fix wrong error label jump in mkpart
 - refresh: libparted-dasd-unify-vtoc-handling-for-cdl-ldl.patch
   4f25d54, unify vtoc handling for cdl/ldl
 - refresh: libparted-dasd-update-and-improve-fdasd-functions.patch
   db37c8c, update and improve fdasd functions
 - refresh: libparted-dasd-add-new-fdasd-functions.patch
   b9e1281, add new fdasd functions

OBS-URL: https://build.opensuse.org/request/show/712877
OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=142
2019-07-08 12:12:35 +00:00

165 lines
5.9 KiB
Diff

From: Petr Uzel <petr.uzel@suse.cz>
Subject: parted: Introduce a type flag
Patch-mainline: no, required by YaST
YaST requires a type flag in order to check the current partition
type for msdos partition tables.
---
include/parted/disk.in.h | 5 ++-
libparted/disk.c | 2 +
libparted/labels/dos.c | 8 ++++++
parted/parted.c | 61 ++++++++++++++++++++++++++++++-----------------
parted/ui.c | 3 ++
5 files changed, 56 insertions(+), 23 deletions(-)
Index: parted-3.2/include/parted/disk.in.h
===================================================================
--- parted-3.2.orig/include/parted/disk.in.h
+++ parted-3.2/include/parted/disk.in.h
@@ -75,10 +75,11 @@ enum _PedPartitionFlag {
PED_PARTITION_LEGACY_BOOT=15,
PED_PARTITION_MSFT_DATA=16,
PED_PARTITION_IRST=17,
- PED_PARTITION_ESP=18
+ PED_PARTITION_ESP=18,
+ PED_PARTITION_TYPE=19
};
#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG PED_PARTITION_ESP
+#define PED_PARTITION_LAST_FLAG PED_PARTITION_TYPE
enum _PedDiskTypeFeature {
PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */
Index: parted-3.2/libparted/disk.c
===================================================================
--- parted-3.2.orig/libparted/disk.c
+++ parted-3.2/libparted/disk.c
@@ -2388,6 +2388,8 @@ ped_partition_flag_get_name (PedPartitio
return N_("lba");
case PED_PARTITION_HPSERVICE:
return N_("hp-service");
+ case PED_PARTITION_TYPE:
+ return N_("type");
case PED_PARTITION_PALO:
return N_("palo");
case PED_PARTITION_PREP:
Index: parted-3.2/libparted/labels/dos.c
===================================================================
--- parted-3.2.orig/libparted/labels/dos.c
+++ parted-3.2/libparted/labels/dos.c
@@ -1550,6 +1550,10 @@ msdos_partition_set_flag (PedPartition*
disk = part->disk;
switch (flag) {
+ case PED_PARTITION_TYPE:
+ dos_data->system = state;
+ return 1;
+
case PED_PARTITION_HIDDEN:
if (part->type == PED_PARTITION_EXTENDED) {
ped_exception_throw (
@@ -1657,6 +1661,9 @@ msdos_partition_get_flag (const PedParti
case PED_PARTITION_LBA:
return dos_data->lba;
+ case PED_PARTITION_TYPE:
+ return dos_data->system;
+
case PED_PARTITION_PALO:
return dos_data->palo;
@@ -1689,6 +1696,7 @@ msdos_partition_is_flag_available (const
case PED_PARTITION_RAID:
case PED_PARTITION_LVM:
case PED_PARTITION_LBA:
+ case PED_PARTITION_TYPE:
case PED_PARTITION_PALO:
case PED_PARTITION_PREP:
case PED_PARTITION_IRST:
Index: parted-3.2/parted/parted.c
===================================================================
--- parted-3.2.orig/parted/parted.c
+++ parted-3.2/parted/parted.c
@@ -887,28 +887,40 @@ error:
static char*
partition_print_flags (PedPartition const *part)
{
- char *res = xstrdup ("");
- if (!part)
- return res;
-
- PedPartitionFlag flag;
- size_t res_buf_len = 1;
- char const *sep = "";
- for (flag = ped_partition_flag_next (0); flag;
- flag = ped_partition_flag_next (flag))
- {
- if (ped_partition_get_flag (part, flag))
+ int xtype;
+ char *res = xstrdup ("");
+ if (!part)
+ return res;
+
+ PedPartitionFlag flag;
+ size_t res_buf_len = 1;
+ char const *sep = "";
+ for (flag = ped_partition_flag_next (0); flag;
+ flag = ped_partition_flag_next (flag))
{
- const char *name = _(ped_partition_flag_get_name (flag));
- size_t new_len = res_buf_len + strlen (sep) + strlen (name);
- res = xrealloc (res, new_len);
- stpcpy (stpcpy (res + res_buf_len - 1, sep), name);
- res_buf_len = new_len;
- sep = ", ";
+ if (xtype = ped_partition_get_flag (part, flag))
+ {
+ if (flag == PED_PARTITION_TYPE) {
+ char tmpstr[21];
+ int len = snprintf(tmpstr, sizeof(tmpstr) - 1, "type=%02x", xtype);
+ 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 = ", ";
+ }
+ else {
+ const char *name = _(ped_partition_flag_get_name (flag));
+ size_t new_len = res_buf_len + strlen (sep) + strlen (name);
+ res = xrealloc (res, new_len);
+ stpcpy (stpcpy (res + res_buf_len - 1, sep), name);
+ res_buf_len = new_len;
+ sep = ", ";
+ }
+ }
}
- }
- return res;
+ return res;
}
static int
@@ -1726,12 +1738,19 @@ do_set (PedDevice** dev, PedDisk **diskp
goto error;
if (!command_line_get_part_flag (_("Flag to Invert?"), part, &flag))
goto error;
- state = (ped_partition_get_flag (part, flag) == 0 ? 1 : 0);
+ if( flag == PED_PARTITION_TYPE )
+ state = ped_partition_get_flag (part, flag);
+ else
+ state = (ped_partition_get_flag (part, flag) == 0 ? 1 : 0);
- if (!is_toggle_mode) {
+ if (!is_toggle_mode && flag != PED_PARTITION_TYPE ) {
if (!command_line_get_state (_("New state?"), &state))
goto error;
}
+ else if( flag == PED_PARTITION_TYPE ) {
+ if (!command_line_get_integer (_("New type?"), &state))
+ goto error;
+ }
if (!ped_partition_set_flag (part, flag, state))
goto error;