]> www.infradead.org Git - mtd-utils.git/commitdiff
mtdinfo: fix `--all' for non-consecutive device numbers
authorBrian Norris <computersforpeace@gmail.com>
Fri, 27 Jan 2012 18:30:46 +0000 (10:30 -0800)
committerArtem Bityutskiy <artem.bityutskiy@linux.intel.com>
Thu, 2 Feb 2012 11:25:14 +0000 (13:25 +0200)
When we have assigned non-consecutive device numbers to our MTD devices,
then we run `mtdinfo --all', we get errors once mtdinfo tries to process
the devices in the "hole". For instance, suppose that at boot time, we have
one MTD (/dev/mtd0) then perform a sequence like the following:

 # modprobe mtdram
 # modprobe nandsim
 # rmmod mtdram

Then at this point, we have should have devices 0 and 2 without 1. Then:

 # mtdinfo --all
 ...
 mtdinfo: error!: mtd1 does not correspond to any existing MTD device

We add 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/mtdinfo.c

index ead4bce2620ff2bda42e0d29be1ef3348852c749..d25595a5667aea3a974e9bebf603538e02f15cbf 100644 (file)
@@ -378,6 +378,8 @@ static int print_general_info(libmtd_t libmtd, const struct mtd_info *mtd_info,
 
        for (i = mtd_info->lowest_mtd_num;
             i <= mtd_info->highest_mtd_num; i++) {
+               if (!mtd_dev_present(libmtd, i))
+                       continue;
                err = print_dev_info(libmtd, mtd_info, i);
                if (err)
                        return err;