X Tutup
Skip to content

Commit b3e2232

Browse files
committed
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[].
1 parent 2caed04 commit b3e2232

File tree

2 files changed

+10
-11
lines changed

2 files changed

+10
-11
lines changed

man/repart.d.xml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -622,7 +622,9 @@
622622
<refsect1>
623623
<title>Specifiers</title>
624624

625-
<para>Specifiers may be used in the <varname>Label=</varname> setting. The following expansions are understood:</para>
625+
<para>Specifiers may be used in the <varname>Label=</varname>, <varname>CopyBlocks=</varname>,
626+
<varname>CopyFiles=</varname>, <varname>MakeDirectories=</varname> settings. The following expansions are
627+
understood:</para>
626628
<table class='specifiers'>
627629
<title>Specifiers available</title>
628630
<tgroup cols='3' align='left' colsep='1' rowsep='1'>
@@ -649,6 +651,8 @@
649651
<xi:include href="standard-specifiers.xml" xpointer="v"/>
650652
<xi:include href="standard-specifiers.xml" xpointer="w"/>
651653
<xi:include href="standard-specifiers.xml" xpointer="W"/>
654+
<xi:include href="standard-specifiers.xml" xpointer="T"/>
655+
<xi:include href="standard-specifiers.xml" xpointer="V"/>
652656
<xi:include href="standard-specifiers.xml" xpointer="percent"/>
653657
</tbody>
654658
</tgroup>

src/partition/repart.c

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -949,11 +949,6 @@ static int config_parse_type(
949949
return 0;
950950
}
951951

952-
static const Specifier specifier_table[] = {
953-
COMMON_SYSTEM_SPECIFIERS,
954-
{}
955-
};
956-
957952
static int config_parse_label(
958953
const char *unit,
959954
const char *filename,
@@ -976,7 +971,7 @@ static int config_parse_label(
976971
/* Nota bene: the empty label is a totally valid one. Let's hence not follow our usual rule of
977972
* assigning the empty string to reset to default here, but really accept it as label to set. */
978973

979-
r = specifier_printf(rvalue, GPT_LABEL_MAX, specifier_table, NULL, &resolved);
974+
r = specifier_printf(rvalue, GPT_LABEL_MAX, system_and_tmp_specifier_table, NULL, &resolved);
980975
if (r < 0) {
981976
log_syntax(unit, LOG_WARNING, filename, line, r,
982977
"Failed to expand specifiers in Label=, ignoring: %s", rvalue);
@@ -1141,7 +1136,7 @@ static int config_parse_copy_files(
11411136
if (!isempty(p))
11421137
return log_syntax(unit, LOG_ERR, filename, line, SYNTHETIC_ERRNO(EINVAL), "Too many arguments: %s", rvalue);
11431138

1144-
r = specifier_printf(source, PATH_MAX-1, specifier_table, NULL, &resolved_source);
1139+
r = specifier_printf(source, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &resolved_source);
11451140
if (r < 0) {
11461141
log_syntax(unit, LOG_WARNING, filename, line, r,
11471142
"Failed to expand specifiers in CopyFiles= source, ignoring: %s", rvalue);
@@ -1152,7 +1147,7 @@ static int config_parse_copy_files(
11521147
if (r < 0)
11531148
return 0;
11541149

1155-
r = specifier_printf(target, PATH_MAX-1, specifier_table, NULL, &resolved_target);
1150+
r = specifier_printf(target, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &resolved_target);
11561151
if (r < 0) {
11571152
log_syntax(unit, LOG_WARNING, filename, line, r,
11581153
"Failed to expand specifiers in CopyFiles= target, ignoring: %s", resolved_target);
@@ -1201,7 +1196,7 @@ static int config_parse_copy_blocks(
12011196
return 0;
12021197
}
12031198

1204-
r = specifier_printf(rvalue, PATH_MAX-1, specifier_table, NULL, &d);
1199+
r = specifier_printf(rvalue, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &d);
12051200
if (r < 0) {
12061201
log_syntax(unit, LOG_WARNING, filename, line, r,
12071202
"Failed to expand specifiers in CopyBlocks= source path, ignoring: %s", rvalue);
@@ -1249,7 +1244,7 @@ static int config_parse_make_dirs(
12491244
if (r == 0)
12501245
return 0;
12511246

1252-
r = specifier_printf(word, PATH_MAX-1, specifier_table, NULL, &d);
1247+
r = specifier_printf(word, PATH_MAX-1, system_and_tmp_specifier_table, NULL, &d);
12531248
if (r < 0) {
12541249
log_syntax(unit, LOG_WARNING, filename, line, r,
12551250
"Failed to expand specifiers in MakeDirectories= parameter, ignoring: %s", word);

0 commit comments

Comments
 (0)
X Tutup