[PATCH 1/2] bbu: fix bbu_register_std_file_update regression for file systems

Ahmad Fatoum a.fatoum at pengutronix.de
Wed Dec 11 23:53:07 PST 2024


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




More information about the barebox mailing list