From 74cfd0921c01c464b79548467e909e577bfc25ac Mon Sep 17 00:00:00 2001 From: Lennart Poettering Date: Thu, 20 Mar 2025 17:23:52 +0100 Subject: [PATCH] gpt-auto-generator: parse systemd.image_filter= from kernel cmdline --- src/gpt-auto-generator/gpt-auto-generator.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/gpt-auto-generator/gpt-auto-generator.c b/src/gpt-auto-generator/gpt-auto-generator.c index f1a4f9cca53..fbd036343c0 100644 --- a/src/gpt-auto-generator/gpt-auto-generator.c +++ b/src/gpt-auto-generator/gpt-auto-generator.c @@ -57,6 +57,7 @@ static int arg_root_rw = -1; static char *arg_usr_fstype = NULL; static char *arg_usr_options = NULL; static ImagePolicy *arg_image_policy = NULL; +static ImageFilter *arg_image_filter = NULL; STATIC_DESTRUCTOR_REGISTER(arg_image_policy, image_policy_freep); STATIC_DESTRUCTOR_REGISTER(arg_root_fstype, freep); @@ -1103,7 +1104,7 @@ static int enumerate_partitions(dev_t devnum) { /* verity= */ NULL, /* mount_options= */ NULL, image_policy, - /* image_filter= */ NULL, + arg_image_filter, DISSECT_IMAGE_GPT_ONLY| DISSECT_IMAGE_USR_NO_ROOT| DISSECT_IMAGE_DISKSEQ_DEVNODE| @@ -1252,8 +1253,17 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat arg_root_rw = false; else if (proc_cmdline_key_streq(key, "systemd.image_policy")) return parse_image_policy_argument(value, &arg_image_policy); + else if (proc_cmdline_key_streq(key, "systemd.image_filter")) { + _cleanup_(image_filter_freep) ImageFilter *f = NULL; - else if (streq(key, "systemd.swap")) { + r = image_filter_parse(value, &f); + if (r < 0) + return log_error_errno(r, "Failed to parse image filter: %s", value); + + image_filter_free(arg_image_filter); + arg_image_filter = TAKE_PTR(f); + + } else if (streq(key, "systemd.swap")) { r = value ? parse_boolean(value) : 1; if (r < 0) -- 2.47.3