parted/parted-add-ignore-busy-option.patch
Marcus Meissner 5631eac2bb Accepting request 760713 from home:anicka:branches:Base:System
- fix crash in do_resizepart
  + parted-fix-end_input-usage.patch: Fix end_input usage in
    do_resizepart 

- update to version 3.3, noteworthy changes:
 - s390: Re-enabled virtio-attached DASD heuristics by using
   HDIO_GETGEO when probing device geometry. Fixes a bug with
   KVM virtio-blk backed by a DASD.
   Parted now recognizes NVMe devices, NVDIMM, and RAM drives.
 - Fix atari disklabel false positives by probing other labels first.
 - Fix resizepart to adjust the end to be -1 sector when using iec
   power of 2 units so that the next partition can start immediately
   following the new end, just like mkpart does.
 - Fix set and disk_set to not crash when there are no flags to set.
 - Fix a udev cookie leak when using resizepart on device-mapper devices.
 - Fix a gettext crash/error sometimes when using localized languages.
 - Fix fat resize to preverve boot code, and thus not render the
   filesystem unreconized by Windows.
 - Fix rescue command: the rescue command often failed to find
   filesystems due to leaving on cylinder alignment.
 - libparted-fs-resize: Prevent crash resizing FAT file systems with very
   deep directories with path names over 512 bytes long.
 - Use 512b sector size when communicating with device-mapper. Fixes
   problems with partitions being created too small on dm devices
   with sector sizes > 5121b
 - Don't crash in the disk_set command when a disk label is not found
 - libparted-fs-resize: Prevent crash resizing FAT16 file systems.
 - libparted-fs-resize: Prevent crash resizing FAT16 file systems.
 - If the user specifies start/end of the partition as cylinders
   and a cylinder has a size which is power of 2, then such address

OBS-URL: https://build.opensuse.org/request/show/760713
OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=144
2020-01-12 13:40:37 +00:00

107 lines
3.8 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,7 +76,8 @@ 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,
};
enum
@@ -118,6 +119,7 @@ static struct option const options[] = {
{"script", 0, NULL, 's'},
{"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 []
{"script", N_("never prompts for user intervention")},
{"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 pretend_input_tty = 0;
int wipesignatures = 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;