parted/parted-add-ignore-busy-option.patch
Arvin Schnell c34e26e7e1 Accepting request 971201 from home:aschnell:branches:Base:System
- 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

OBS-URL: https://build.opensuse.org/request/show/971201
OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=152
2022-04-21 05:58:32 +00:00

108 lines
3.9 KiB
Diff

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;