diff --git a/man/repart.d.xml b/man/repart.d.xml
index b01c0c04f00..8cd2149121f 100644
--- a/man/repart.d.xml
+++ b/man/repart.d.xml
@@ -483,18 +483,18 @@
ExcludeFiles=
ExcludeFilesTarget=
- Takes an absolute file system path referring to a source file or directory on the
- host. This setting may be used to exclude files or directories from the host from being copied into
- the file system when CopyFiles= is used. This option may be used multiple times to
- exclude multiple files or directories from host from being copied into the newly formatted file
- system.
+ Takes one or more absolute paths, separated by whitespace, each referring to a
+ source file or directory on the host. This setting may be used to exclude files or directories from
+ the host from being copied into the file system when CopyFiles= is used. This
+ option may be used multiple times to exclude multiple files or directories from host from being
+ copied into the newly formatted file system.
If the path is a directory and ends with /, only the directory's
contents are excluded but not the directory itself. If the path is a directory and does not end with
/, both the directory and its contents are excluded.
ExcludeFilesTarget= is like ExcludeFiles= except that
- instead of excluding the path on the host from being copied into the partition, we exclude any files
+ instead of excluding the path on the host from being copied into the partition, it exclude any files
and directories from being copied into the given path in the partition.
When
diff --git a/src/partition/repart.c b/src/partition/repart.c
index baef519eaf3..ac199e6856e 100644
--- a/src/partition/repart.c
+++ b/src/partition/repart.c
@@ -1742,8 +1742,9 @@ static int config_parse_exclude_files(
const char *rvalue,
void *data,
void *userdata) {
- _cleanup_free_ char *resolved = NULL;
+
char ***exclude_files = ASSERT_PTR(data);
+ const char *p = ASSERT_PTR(rvalue);
int r;
if (isempty(rvalue)) {
@@ -1751,20 +1752,34 @@ static int config_parse_exclude_files(
return 0;
}
- r = specifier_printf(rvalue, PATH_MAX-1, system_and_tmp_specifier_table, arg_root, NULL, &resolved);
- if (r < 0) {
- log_syntax(unit, LOG_WARNING, filename, line, r,
- "Failed to expand specifiers in ExcludeFiles= path, ignoring: %s", rvalue);
- return 0;
+ for (;;) {
+ _cleanup_free_ char *word = NULL, *resolved = NULL;
+
+ r = extract_first_word(&p, &word, NULL, EXTRACT_UNQUOTE);
+ if (r == -ENOMEM)
+ return log_oom();
+ if (r < 0) {
+ log_syntax(unit, LOG_WARNING, filename, line, r, "Invalid syntax, ignoring: %s", p);
+ return 0;
+ }
+ if (r == 0)
+ return 0;
+
+ r = specifier_printf(word, PATH_MAX-1, system_and_tmp_specifier_table, arg_root, NULL, &resolved);
+ if (r < 0) {
+ log_syntax(unit, LOG_WARNING, filename, line, r,
+ "Failed to expand specifiers in %s path, ignoring: %s", lvalue, word);
+ return 0;
+ }
+
+ r = path_simplify_and_warn(resolved, PATH_CHECK_ABSOLUTE|PATH_KEEP_TRAILING_SLASH, unit, filename, line, lvalue);
+ if (r < 0)
+ return 0;
+
+ if (strv_consume(exclude_files, TAKE_PTR(resolved)) < 0)
+ return log_oom();
}
- r = path_simplify_and_warn(resolved, PATH_CHECK_ABSOLUTE|PATH_KEEP_TRAILING_SLASH, unit, filename, line, lvalue);
- if (r < 0)
- return 0;
-
- if (strv_consume(exclude_files, TAKE_PTR(resolved)) < 0)
- return log_oom();
-
return 0;
}