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 1/2] bbu: fix bbu_register_std_file_update regression for file systems
Date: Thu, 12 Dec 2024 08:53:07 +0100	[thread overview]
Message-ID: <20241212075308.2499846-1-a.fatoum@pengutronix.de> (raw)

The code used to handle any path equally well, but then it was broken
for paths that don't start with /dev, i.e. anything in a filesystem.

Add an explicit /dev check before going into the newer code, so
bbu_register_std_file_update can once again be called with paths
that start with /mnt for example. Previously, this resulted in following
error message:

  bbu: Skipping handler bbu-MLO.fat.emmc: /dev//mnt/mmc1.0/barebox.bin unavailable

Fixes: df22a22f84b6 ("bbu: fix exporting i.MX NAND bbu handler over fastboot")
Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
---
 common/bbu.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/common/bbu.c b/common/bbu.c
index 9ea8a1a3f247..ba550f925608 100644
--- a/common/bbu.c
+++ b/common/bbu.c
@@ -43,14 +43,18 @@ void bbu_append_handlers_to_file_list(struct file_list *files)
 	struct bbu_handler *handler;
 
 	list_for_each_entry(handler, &bbu_image_handlers, list) {
-		const char *cdevname;
+		const char *cdevname, *devpath;
+		char *buf = NULL;
 		struct stat s;
-		char *devpath;
 
-		cdevname = devpath_to_name(handler->devicefile);
-		device_detect_by_name(cdevname);
+		devpath = handler->devicefile;
 
-		devpath = basprintf("/dev/%s", cdevname);
+		if (strstarts(devpath, "/dev/")) {
+			cdevname = devpath_to_name(devpath);
+			device_detect_by_name(cdevname);
+
+			devpath = buf = basprintf("/dev/%s", cdevname);
+		}
 
 		if (stat(devpath, &s) == 0) {
 			append_bbu_entry(handler->name, devpath, files);
@@ -59,7 +63,7 @@ void bbu_append_handlers_to_file_list(struct file_list *files)
 				handler->name, devpath);
 		}
 
-		free(devpath);
+		free(buf);
 	}
 }
 
-- 
2.39.5




             reply	other threads:[~2024-12-12  7:54 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-12  7:53 Ahmad Fatoum [this message]
2024-12-12  7:53 ` [PATCH 2/2] ARM: beaglebone: register bbu handlers for FAT partition Ahmad Fatoum
2024-12-16  8:30 ` [PATCH 1/2] bbu: fix bbu_register_std_file_update regression for file systems Sascha Hauer

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=20241212075308.2499846-1-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