From 3be8b0ebb2196733bec1ef1d7db86ab9eb9deee19ea93f7c0446453d1f706a89 Mon Sep 17 00:00:00 2001 From: Sebastian Parschauer Date: Thu, 10 Aug 2017 15:18:26 +0000 Subject: [PATCH] Accepting request 515942 from home:sparschauer:branches:Base:System - parted: mkpart: Allow empty string "" for the GPT partition name in script mode (bsc#1023818, boo#1032562) - add: parted-mkpart-allow-empty-gpt-part-name.patch OBS-URL: https://build.opensuse.org/request/show/515942 OBS-URL: https://build.opensuse.org/package/show/Base:System/parted?expand=0&rev=129 --- parted-mkpart-allow-empty-gpt-part-name.patch | 59 +++++++++++++++++++ parted.changes | 7 +++ parted.spec | 2 + 3 files changed, 68 insertions(+) create mode 100644 parted-mkpart-allow-empty-gpt-part-name.patch diff --git a/parted-mkpart-allow-empty-gpt-part-name.patch b/parted-mkpart-allow-empty-gpt-part-name.patch new file mode 100644 index 0000000..00f80fa --- /dev/null +++ b/parted-mkpart-allow-empty-gpt-part-name.patch @@ -0,0 +1,59 @@ +From: Sebastian Parschauer +Date: Thu, 10 Aug 2017 14:52:47 +0200 +Subject: parted/ui: Count empty strings as words in multi_word mode +References: bsc#1023818, boo#1032562 +Patch-mainline: submitted, 2017-08-10 + +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 strings as words in multi_word mode to allow the +the following commands to set an empty partition name. + +parted -s /dev/vdb mkpart "" 1MiB 100% +parted -s /dev/vdb mkpart "" ext3 1MiB 100% + +This does not break any other parts as these all check if the +provided string is a valid value. + +Signed-off-by: Sebastian Parschauer +--- + parted/ui.c | 11 +++++------ + 1 file changed, 5 insertions(+), 6 deletions(-) + +diff --git a/parted/ui.c b/parted/ui.c +index 752860baa087..b7e593bf12da 100644 +--- a/parted/ui.c ++++ b/parted/ui.c +@@ -712,8 +712,8 @@ _str_is_spaces (const char* str) + * In single-word mode, only one word is parsed per line. + * Leading and trailing spaces are removed. For example: " a b c " + * is a single word "a b c". The motivation for this mode is partition +- * names, etc. In single-word mode, the empty string is a word. +- * (but not in multi-word mode). ++ * names, etc. The empty string is always a word to allow empty ++ * partition names in non-interactive mode. + */ + void + command_line_push_line (const char* line, int multi_word) +@@ -755,10 +755,9 @@ command_line_push_line (const char* line, int multi_word) + + this_word [i++] = *line; + } +- if (i || !multi_word) { +- this_word [i] = 0; +- command_line_push_word (this_word); +- } ++ this_word [i] = 0; ++ command_line_push_word (this_word); ++ + } while (*line && multi_word); + } + diff --git a/parted.changes b/parted.changes index cbe7890..a0247b3 100644 --- a/parted.changes +++ b/parted.changes @@ -1,3 +1,10 @@ +------------------------------------------------------------------- +Thu Aug 10 16:44:57 CEST 2017 - sparschauer@suse.de + +- parted: mkpart: Allow empty string "" for the GPT partition name + in script mode (bsc#1023818, boo#1032562) + - add: parted-mkpart-allow-empty-gpt-part-name.patch + ------------------------------------------------------------------- Thu Jun 15 20:28:08 CEST 2017 - sparschauer@suse.de diff --git a/parted.spec b/parted.spec index 00d6908..014f992 100644 --- a/parted.spec +++ b/parted.spec @@ -79,6 +79,7 @@ Patch47: libparted-dasd-improve-lvm-raid-flag-handling.patch Patch48: parted-mkpart-set-a-swap-flag-if-available.patch Patch49: libparted-set-swap-flag-on-GPT-partitions.patch Patch50: libparted-dasd-add-swap-flag-handling-for-DASD-CDL.patch +Patch51: parted-mkpart-allow-empty-gpt-part-name.patch Patch100: parted-fatresize-autoconf.patch BuildRequires: check-devel BuildRequires: device-mapper-devel >= 1.02.33 @@ -172,6 +173,7 @@ to develop applications that require these. %patch48 -p1 %patch49 -p1 %patch50 -p1 +%patch51 -p1 %patch100 -p1 %build