[PATCH 2/3] cmd: ubi: allow creating volume with all free spaces in ubi_create_vol

Weijie Gao weijie.gao at mediatek.com
Fri Apr 17 04:35:29 CEST 2026


Although the ubi command itself supports creating volume with all
free spaces, the api ubi_create_vol() does not.

Since negative size in invalid, this patch replaces negative size
with all free space size in ubi_create_vol().

Signed-off-by: Weijie Gao <weijie.gao at mediatek.com>
---
 cmd/ubi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cmd/ubi.c b/cmd/ubi.c
index e7fd7165457..3a1d47d1942 100644
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -226,7 +226,11 @@ int ubi_create_vol(char *volume, int64_t size, int dynamic, int vol_id,
 
 	req.vol_id = vol_id;
 	req.alignment = 1;
-	req.bytes = size;
+
+	if (size < 0)
+		req.bytes = ubi->avail_pebs * ubi->leb_size;
+	else
+		req.bytes = size;
 
 	strcpy(req.name, volume);
 	req.name_len = strlen(volume);
-- 
2.45.2



More information about the U-Boot mailing list