]> www.infradead.org Git - mtd-utils.git/commitdiff
ubinfo: fix `--all' for non-consecutive device numbers
authorBrian Norris <computersforpeace@gmail.com>
Thu, 26 Jan 2012 07:31:50 +0000 (23:31 -0800)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Fri, 27 Jan 2012 14:55:24 +0000 (16:55 +0200)
When we have assigned non-consecutive device numbers to our UBI devices,
then we run `ubinfo --all', we get errors once ubinfo tries to process the
devices in the "hole". For instance, suppose there are two UBI devices,
/dev/ubi0 and /dev/ubi10; then, ubinfo will fail trying to open /dev/ubi1
with:

  ubinfo: error!: cannot get information about UBI device 1
         error 2 (No such file or directory)

This patch adds a check to first see if device is present, then continue
to the next ID if it doesn't exist.

Reported-by: Brian Foster <brian.foster@maxim-ic.com>
Signed-off-by: Brian Norris <computersforpeace@gmail.com>
Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
ubi-utils/ubinfo.c

index 7aa4aa4ad66a2ab652e9501b729737dee8f49b13..cb88f53c444f5b30b8c797944d863c9528c043a0 100644 (file)
@@ -362,6 +362,8 @@ static int print_general_info(libubi_t libubi, int all)
 
        for (i = ubi_info.lowest_dev_num;
             i <= ubi_info.highest_dev_num; i++) {
+               if (!ubi_dev_present(libubi, i))
+                       continue;
                if(!first)
                        printf("\n===================================\n\n");
                first = 0;