mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH 06/15] bootm: cache os_file for appendroot purposes
Date: Tue, 27 Jan 2026 09:39:16 +0100	[thread overview]
Message-ID: <20260127084546.3751357-7-a.fatoum@pengutronix.de> (raw)
In-Reply-To: <20260127084546.3751357-1-a.fatoum@pengutronix.de>

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@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




  parent reply	other threads:[~2026-01-27  8:46 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-27  8:39 [PATCH 00/15] bootm: prepare loadable abstraction rework Ahmad Fatoum
2026-01-27  8:39 ` [PATCH 01/15] FIT: implement fit_count_images Ahmad Fatoum
2026-01-27  8:39 ` [PATCH 02/15] FIT: add image index argument to fit_open_image Ahmad Fatoum
2026-01-27  8:39 ` [PATCH 03/15] resource: implement gap-aware lookup_region Ahmad Fatoum
2026-01-27  8:39 ` [PATCH 04/15] bootm: give bootm_load_ functions an end address Ahmad Fatoum
2026-01-27 15:31   ` Ahmad Fatoum
2026-01-30 13:35     ` Sascha Hauer
2026-01-27  8:39 ` [PATCH 05/15] bootm: store separate image_type and kernel_type Ahmad Fatoum
2026-01-27  8:39 ` Ahmad Fatoum [this message]
2026-01-27  8:39 ` [PATCH 07/15] bootm: fit: move length calculation into fit_open Ahmad Fatoum
2026-01-27  8:39 ` [PATCH 08/15] libfile: factor out zero-page resistant read_file as __read_full_anywhere Ahmad Fatoum
2026-01-27  8:39 ` [PATCH 09/15] resource: implement resize_region Ahmad Fatoum
2026-01-30 12:38   ` Sascha Hauer
2026-01-27  8:39 ` [PATCH 10/15] bootm: rename image_data::os/initrd with _uimage suffix Ahmad Fatoum
2026-01-27  8:39 ` [PATCH 11/15] uimage: record original file name in uimage_handle Ahmad Fatoum
2026-01-27  8:39 ` [PATCH 12/15] bootm: factor out file detection into helper Ahmad Fatoum
2026-01-27  8:39 ` [PATCH 13/15] efi: payload: bootm: add dry run support Ahmad Fatoum
2026-01-27  8:39 ` [PATCH 14/15] efi: payload: bootm: fix memory corruption on initrd load error Ahmad Fatoum
2026-01-27  8:39 ` [PATCH 15/15] efi: initrd: make efi_initrd_register initrd pointer param const Ahmad Fatoum

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20260127084546.3751357-7-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox