From 60bc1e38d058c2f90c89780f0e086b66ec4a76a0 Mon Sep 17 00:00:00 2001 From: Eduard Shishkin Date: Sat, 26 Jul 2025 13:30:15 +0200 Subject: [PATCH] zipl/src: Reuse data of buffer components in bootmap Don't duplicate data of components added via add_component_buffer() and friends to bootmap file. Instead, reuse data that were previously added when preparing a program table for the first mirror to create metadata (block lists, program tables, etc) specific for other mirrors. Signed-off-by: Eduard Shishkin Reviewed-by: Stefan Haberland Signed-off-by: Steffen Eiden --- zipl/src/bootmap.c | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/zipl/src/bootmap.c b/zipl/src/bootmap.c index 112e6b57..a96d44bd 100644 --- a/zipl/src/bootmap.c +++ b/zipl/src/bootmap.c @@ -480,6 +480,14 @@ static int add_component_buffer_align(struct install_set *bis, void *buffer, error_text("Could not write to bootmap file"); return -1; } + if (!bis->comp_reg[comp_id].offset) { + /* + * save component offset and size + */ + assert(offset && *offset); + bis->comp_reg[comp_id].offset = *offset; + bis->comp_reg[comp_id].len = size; + } if (component_type_by_id(comp_id) == COMPONENT_TYPE_LOAD) { /* Fill in component location */ location->addr = data.load_address; @@ -510,9 +518,26 @@ static int add_component_buffer(struct install_set *bis, void *buffer, int mirror_id, int program_table_id) { struct disk_info *info = &bis->info->base[mirror_id]; + loff_t offset; + if (bis->comp_reg[comp_id].offset > 0) { + /* + * The component data has been already written to the + * bootmap. Refer the respective region in the bootmap + * file. + */ + return add_component_file_range(bis, + bis->filename /* bootmap */, + &bis->comp_reg[comp_id], + data.load_address, + 0 /*trailer */, + component, + 0 /* do not add file data*/, + comp_id, menu_idx, mirror_id, + program_table_id); + } return add_component_buffer_align(bis, buffer, size, data, component, - info->phy_block_size, NULL, + info->phy_block_size, &offset, comp_id, menu_idx, mirror_id, program_table_id); }