]> www.infradead.org Git - mtd-utils.git/commitdiff
ubimkvol: check for free LEBs
authorArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 2 Sep 2008 13:46:48 +0000 (16:46 +0300)
committerArtem Bityutskiy <Artem.Bityutskiy@nokia.com>
Tue, 2 Sep 2008 13:50:58 +0000 (16:50 +0300)
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>
ubi-utils/new-utils/src/ubimkvol.c

index fd8c56852bc3ca59252e3411da66d610f8aaf570..ad072c4a5cfd1d9df1c8813aee9df2c18fbede31 100644 (file)
@@ -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);