From 214ddd398850d003dcd1943da6a039f324646b5b Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Tue, 2 Sep 2008 16:46:48 +0300 Subject: ubimkvol: check for free LEBs Check for free LEBs before trying to create a volume. This fixes the following issue: $ ubimkvol /dev/ubi0 -n 0 -N test_fs -m ubimkvol: error!: cannot UBI create volume error 22 (Invalid argument) Error: cannot create UBI volume "Invalid argument" ? Not understandable. But the thing is that -m makes ubimkvol use available space, which is zero, then it passes zero to the ioctl, which fails in request validation code, because 0 invalid volume size. Signed-off-by: Artem Bityutskiy --- ubi-utils/new-utils/src/ubimkvol.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'ubi-utils/new-utils/src') diff --git a/ubi-utils/new-utils/src/ubimkvol.c b/ubi-utils/new-utils/src/ubimkvol.c index fd8c568..ad072c4 100644 --- a/ubi-utils/new-utils/src/ubimkvol.c +++ b/ubi-utils/new-utils/src/ubimkvol.c @@ -261,6 +261,11 @@ int main(int argc, char * const argv[]) goto out_libubi; } + if (dev_info.avail_bytes == 0) { + errmsg("UBI device does not have free logical eraseblocks"); + goto out_libubi; + } + if (args.maxavs) { args.bytes = dev_info.avail_bytes; printf("Set volume size to %lld\n", args.bytes); -- cgit v1.2.3