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().

Signed-off-by: Weijie Gao <[email protected]>
Reviewed-by: Simon Glass <[email protected]>
---
v4: not changed
v3: not changed
v2: not changed
---
 cmd/ubi.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/cmd/ubi.c b/cmd/ubi.c
index 9b2b66b5a99..b2287c0cf0b 100644
--- 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);
-- 
2.45.2

Reply via email to