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 <Artem.Bityutskiy@nokia.com>
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);