[PATCH 06/15] bootm: cache os_file for appendroot purposes

Ahmad Fatoum a.fatoum at pengutronix.de
Tue Jan 27 00:39:16 PST 2026


Even if we were to use an override, we want appendroot to follow the
original file as the root device can already be overridden by
$global.bootm.root_dev.

Therefore cache os_file to make it easier to reorder execution during
the incoming refactor.

Signed-off-by: Ahmad Fatoum <a.fatoum at pengutronix.de>
---
 common/bootm.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)

diff --git a/common/bootm.c b/common/bootm.c
index 17c94b281eb2..a2301ea72458 100644
--- a/common/bootm.c
+++ b/common/bootm.c
@@ -548,6 +548,7 @@ static int bootm_image_name_and_part(const char *name, char **filename, char **p
  */
 int bootm_boot(struct bootm_data *bootm_data)
 {
+	char *os_file;
 	struct image_data *data;
 	struct image_handler *handler;
 	int ret;
@@ -575,9 +576,11 @@ int bootm_boot(struct bootm_data *bootm_data)
 	data->os_entry = bootm_data->os_entry;
 	data->efi_boot = bootm_data->efi_boot;
 
-	ret = read_file_2(data->os_file, &size, &data->os_header, PAGE_SIZE);
+	os_file = xstrdup(data->os_file);
+
+	ret = read_file_2(os_file, &size, &data->os_header, PAGE_SIZE);
 	if (ret < 0 && ret != -EFBIG) {
-		pr_err("could not open %s: %pe\n", data->os_file, ERR_PTR(ret));
+		pr_err("could not open %s: %pe\n", os_file, ERR_PTR(ret));
 		goto err_out;
 	}
 	if (size < PAGE_SIZE)
@@ -655,11 +658,11 @@ int bootm_boot(struct bootm_data *bootm_data)
 			if (root_cdev)
 				cdev_close(root_cdev);
 		} else {
-			struct fs_device *fsdev = get_fsdevice_by_path(AT_FDCWD, data->os_file);
+			struct fs_device *fsdev = get_fsdevice_by_path(AT_FDCWD, os_file);
 			if (fsdev)
 				fsdev_get_linux_root_options(fsdev, &root, &rootopts);
 			else
-				pr_err("no fsdevice under path: %s\n", data->os_file);
+				pr_err("no fsdevice under path: %s\n", os_file);
 		}
 
 		if (!root) {
@@ -739,8 +742,7 @@ int bootm_boot(struct bootm_data *bootm_data)
 		free(hostname_bootarg);
 	}
 
-	pr_info("\nLoading %s '%s'", file_type_to_string(data->kernel_type),
-		data->os_file);
+	pr_info("\nLoading %s '%s'", file_type_to_string(data->kernel_type), data->os_file);
 	if (data->kernel_type == filetype_uimage &&
 			data->os->header.ih_type == IH_TYPE_MULTI)
 		pr_info(", multifile image %d", uimage_part_num(data->os_part));
@@ -798,6 +800,7 @@ int bootm_boot(struct bootm_data *bootm_data)
 	free(data->oftree_file);
 	free(data->initrd_file);
 	free(data->tee_file);
+	free(os_file);
 	free(data);
 
 	return ret;
-- 
2.47.3




More information about the barebox mailing list