From b3e22322b6ba7728e0698c6945b2bb191e18bb4a Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Wed, 26 May 2021 17:10:56 +0200 Subject: [PATCH] repart: resolve $TMP specifiers too This might be useful for CopyFiles=, to reference some subdir of $TMP in a generic way. This allows us to use the new common system_and_tmp_specifier_table[]. --- man/repart.d.xml | 6 +++++- src/partition/repart.c | 15 +++++---------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/man/repart.d.xml b/man/repart.d.xml index 6e3322e064b..8f86c41547f 100644 --- a/man/repart.d.xml +++ b/man/repart.d.xml @@ -622,7 +622,9 @@ Specifiers - Specifiers may be used in the Label= setting. The following expansions are understood: + Specifiers may be used in the Label=, CopyBlocks=, + CopyFiles=, MakeDirectories= settings. The following expansions are + understood: Specifiers available @@ -649,6 +651,8 @@ + + diff --git a/src/partition/repart.c b/src/partition/repart.c index 877d2a091d7..cd2d02a3b89 100644 --- a/src/partition/repart.c +++ b/src/partition/repart.c @@ -949,11 +949,6 @@ static int config_parse_type( return 0; } -static const Specifier specifier_table[] = { - COMMON_SYSTEM_SPECIFIERS, - {} -}; - static int config_parse_label( const char *unit, const char *filename, @@ -976,7 +971,7 @@ static int config_parse_label( /* Nota bene: the empty label is a totally valid one. Let's hence not follow our usual rule of * assigning the empty string to reset to default here, but really accept it as label to set. */ - r = specifier_printf(rvalue, GPT_LABEL_MAX, specifier_table, NULL, &resolved); + r = specifier_printf(rvalue, GPT_LABEL_MAX, system_and_tmp_specifier_table, NULL, &resolved); if (r < 0) { log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to expand specifiers in Label=, ignoring: %s", rvalue); @@ -1141,7 +1136,7 @@ static int config_parse_copy_files( if (!isempty(p)) return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), "Too many arguments: %s", rvalue); - r = specifier_printf(source, PATH_MAX-1, specifier_table, NULL, &resolved_source); + r = specifier_printf(source, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &resolved_source); if (r < 0) { log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to expand specifiers in CopyFiles= source, ignoring: %s", rvalue); @@ -1152,7 +1147,7 @@ static int config_parse_copy_files( if (r < 0) return 0; - r = specifier_printf(target, PATH_MAX-1, specifier_table, NULL, &resolved_target); + r = specifier_printf(target, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &resolved_target); if (r < 0) { log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to expand specifiers in CopyFiles= target, ignoring: %s", resolved_target); @@ -1201,7 +1196,7 @@ static int config_parse_copy_blocks( return 0; } - r = specifier_printf(rvalue, PATH_MAX-1, specifier_table, NULL, &d); + r = specifier_printf(rvalue, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &d); if (r < 0) { log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to expand specifiers in CopyBlocks= source path, ignoring: %s", rvalue); @@ -1249,7 +1244,7 @@ static int config_parse_make_dirs( if (r == 0) return 0; - r = specifier_printf(word, PATH_MAX-1, specifier_table, NULL, &d); + r = specifier_printf(word, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &d); if (r < 0) { log_syntax(unit, LOG_WARNING, filename, line, r, "Failed to expand specifiers in MakeDirectories= parameter, ignoring: %s", word); -- 2.47.3