]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
cmd: ubi: allow creating volume with all free spaces in ubi_create_vol
authorWeijie Gao <weijie.gao@mediatek.com>
Wed, 20 May 2026 08:27:40 +0000 (16:27 +0800)
committerHeiko Schocher <hs@nabladev.com>
Wed, 8 Jul 2026 09:34:44 +0000 (11:34 +0200)
Although the ubi command itself supports creating volume with all
free spaces, the api ubi_create_vol() does not.

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

Reviewed-by: Simon Glass <sjg@chromium.org>
Signed-off-by: Weijie Gao <weijie.gao@mediatek.com>
cmd/ubi.c

index eea863ac30387aa8847a64748cdbc222629c96f1..2b206141a21e28417fa572fe81a6f55254d5c18f 100644 (file)
--- a/cmd/ubi.c
+++ b/cmd/ubi.c
@@ -226,7 +226,11 @@ int ubi_create_vol(const char *volume, int64_t size, bool 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);