core: change mount options settings so that last defined wins

Currently mount options are handled in such a way that the first
definition for a given partition wins, and documented as such.
Change them so that they behave like other options, and the
last specified wins.
Applies to RootImageOptions=, MountImages= and ExtensionImages=.
Switch from a linked list to an array indexed by the partition
specifier to store them.
This commit is contained in:
Luca Boccassi
2026-01-06 17:59:10 +01:00
parent 9573ad4e76
commit 9de41f677c
14 changed files with 311 additions and 378 deletions
+16 -15
View File
@@ -1167,13 +1167,10 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
fprintf(f, "%sRootImage: %s\n", prefix, c->root_image);
if (c->root_image_options) {
fprintf(f, "%sRootImageOptions:", prefix);
LIST_FOREACH(mount_options, o, c->root_image_options)
if (!isempty(o->options))
fprintf(f, " %s:%s",
partition_designator_to_string(o->partition_designator),
o->options);
fprintf(f, "\n");
_cleanup_free_ char *opts_str = NULL;
if (mount_options_to_string(c->root_image_options, &opts_str) >= 0 && !isempty(opts_str))
fprintf(f, "%sRootImageOptions: %s\n", prefix, opts_str);
}
if (iovec_is_set(&c->root_hash)) {
@@ -1580,10 +1577,12 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
mount->ignore_enoent ? "-": "",
mount->source,
mount->destination);
LIST_FOREACH(mount_options, o, mount->mount_options)
fprintf(f, ":%s:%s",
partition_designator_to_string(o->partition_designator),
strempty(o->options));
if (mount->mount_options) {
_cleanup_free_ char *opts = NULL;
if (mount_options_to_string(mount->mount_options, &opts) >= 0 && !isempty(opts))
fprintf(f, " %s", opts);
}
fprintf(f, "\n");
}
@@ -1591,10 +1590,12 @@ void exec_context_dump(const ExecContext *c, FILE* f, const char *prefix) {
fprintf(f, "%sExtensionImages: %s%s", prefix,
mount->ignore_enoent ? "-": "",
mount->source);
LIST_FOREACH(mount_options, o, mount->mount_options)
fprintf(f, ":%s:%s",
partition_designator_to_string(o->partition_designator),
strempty(o->options));
if (mount->mount_options) {
_cleanup_free_ char *opts = NULL;
if (mount_options_to_string(mount->mount_options, &opts) >= 0 && !isempty(opts))
fprintf(f, " %s", opts);
}
fprintf(f, "\n");
}