From: Artem Bityutskiy Date: Tue, 2 Sep 2008 13:46:48 +0000 (+0300) Subject: ubimkvol: check for free LEBs X-Git-Tag: v1.3.0~149 X-Git-Url: https://www.infradead.org/git/?a=commitdiff_plain;h=214ddd398850d003dcd1943da6a039f324646b5b;p=mtd-utils.git 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 --- 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);