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); }