[RFC PATCH 05/20] cmd: ubi: export ubi_find_volume()
Daniel Golle
daniel at makrotopia.org
Mon Feb 16 22:21:58 CET 2026
Remove the static qualifier from ubi_find_volume() and add a
declaration to include/ubi_uboot.h so that other translation units
can look up a UBI volume by name.
The function now refers to ubi_devices[0] directly instead of the
file-local 'ubi' pointer, and takes a const char * for the volume
name.
Signed-off-by: Daniel Golle <daniel at makrotopia.org>
---
cmd/ubi.c | 10 +++++++---
include/ubi_uboot.h | 1 +
2 files changed, 8 insertions(+), 3 deletions(-)
diff --git a/cmd/ubi.c b/cmd/ubi.c
index 93de6f3aea2..ca7d657aa07 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -247,13 +247,17 @@ static int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id,
return ubi_create_volume(ubi, &req);
}
-static struct ubi_volume *ubi_find_volume(char *volume)
+struct ubi_volume *ubi_find_volume(const char *volume)
{
+ struct ubi_device *dev = ubi_devices[0];
struct ubi_volume *vol;
int i;
- for (i = 0; i < ubi->vtbl_slots; i++) {
- vol = ubi->volumes[i];
+ if (!dev)
+ return NULL;
+
+ for (i = 0; i < dev->vtbl_slots; i++) {
+ vol = dev->volumes[i];
if (vol && !strcmp(vol->name, volume))
return vol;
}
diff --git a/include/ubi_uboot.h b/include/ubi_uboot.h
index ea0db69c72a..92892704d0a 100644
--- a/include/ubi_uboot.h
+++ b/include/ubi_uboot.h
@@ -50,6 +50,7 @@ extern void ubi_exit(void);
extern int ubi_part(char *part_name, const char *vid_header_offset);
extern int ubi_volume_write(char *volume, void *buf, loff_t offset, size_t size);
extern int ubi_volume_read(char *volume, char *buf, loff_t offset, size_t size);
+struct ubi_volume *ubi_find_volume(const char *volume);
extern struct ubi_device *ubi_devices[];
int cmd_ubifs_mount(char *vol_name);
--
2.53.0
More information about the U-Boot
mailing list