aboutsummaryrefslogtreecommitdiff
path: root/ubi-utils/mtdinfo.c
AgeCommit message (Collapse)Author
2016-11-17Merge rest of ubiutils-common into libmtd commonDavid Oberhollenzer
This patch moves the remaining 3 functions from ubiutils-common.{c,h} into libmtd common.{c,h}. The functions are only generic utility functions that other mtd-utils programs may also find usefull and every program that uses libubi links against libmtd anyway so there is no real reason for keeping around a seperate ubiutils-common with only generic helper functions. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2014-11-04libmtd: don't ignore "region index" parameter in mtd_regioninfo()Brian Norris
ioctl(MEMGETREGIONINFO) has one input parameter (regionindex) and three output parameters (info about the erase region). There are two problems in mtdinfo/libmtd here: 1. mtdinfo.c doesn't initialize its region_info_user struct, instead passing uninitialized data to mtd_regioninfo() 2. mtd_regioninfo() fails to utilize the 'regidx' parameter to fill out the regionindex parameter properly, so the garbage from mtdinfo.c is propagated to the ioctl() This means that mtdinfo will continuously probe the same (possibly out-of-range) erase region, instead of looping over the valid regions. Let's fix this in the mtd_regioninfo() helper, and at the same time, let's zero out the mtdinfo.c buffer, as an additional precaution to keep from using uninitialized data. Initial error report from Yang, when running "mtdinfo /dev/mtd0" on a Cavium 6100 board: root@CN61XX:~# mtdinfo /dev/mtd0 mtd0 Name: phys_mapped_flash Type: nor Eraseblock size: 65536 bytes, 64.0 KiB Amount of eraseblocks: 128 (8388608 bytes, 8.0 MiB) Minimum input/output unit size: 1 byte Sub-page size: 1 byte Additional erase regions: 0 Character device major/minor: 90:0 Bad blocks are allowed: false Device is writable: true libmtd: error!: MEMGETREGIONINFO ioctl failed for erase region 0 error 22 (Invalid argument) Eraseblock region 0: info is unavailable libmtd: error!: MEMGETREGIONINFO ioctl failed for erase region 1 error 22 (Invalid argument) Eraseblock region 1: info is unavailable Reported-by: Yang Wei <Wei.Yang@windriver.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2013-10-22check the MLC nand typeHuang Shijie
In the current code, the MTD_NANDFLASH stands for both the SLC and MLC. In the kernel, the MTD_NANDFLASH only stands for the SLC now, so in order to keep the logic unchanged, we should also check the MLC NAND by MTD_MLCNANDFLASH. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2012-02-14mtdinfo: correct grammar on error messageBrian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-02-02mtdinfo: fix `--all' for non-consecutive device numbersBrian Norris
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>
2011-11-18mtdinfo: provide info when used without argumentsBrian Norris
If the user specifies neither a MTD argument nor the `-a' flag, we print a cryptic message; i.e., # mtdinfo libmtd: error!: cannot get information about "(null)" error 14 (Bad address) mtdinfo: error!: cannot get information about MTD device "(null)" error 14 (Bad address) This is a regression; previously, mtdinfo would give some short info about number of devices, etc. when used without arguments. To fix this, we revert commit d53c03b0989f8354a7e4dbb947a150fc7fe3f6d1 and call print_general_info() when no device is specified. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@intel.com>
2011-08-16mtdinfo: consolidate help as display_help()Brian Norris
The help message for mtdinfo is unnecessarily disjointed. It is split into three strings which reuse the PROGRAM_NAME string inefficiently and don't have a consistent style. This fixup should provide a cleaner look with aligned columns and easier-to-read source code. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-08-16mtdinfo: fixup "example usage" help sectionBrian Norris
Line up columns better so that everything is more readable. Remove "Example 1" since `mtdinfo' does not print information when not given any arguments. Remove "...UBI layout information" from description of Example 4, since Example 4 (now 3) doesn't include the `-u' flag. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-08-16mtdinfo: restructure help messageBrian Norris
We weren't very consistent in how we listed our options in the mtdinfo help string (listing short options, long options, or both). Plus, not all options are inter-operable, so we should distinguish this somewhat. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-08-16mtdinfo: refactor code to remove "args.all" dependencyBrian Norris
Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-08-16mtdinfo: don't open NULL pointer when getting region_info with `-a'Brian Norris
This "fixes" a regression found in: commit 266061ebd5d72391f0a0e831b018e8fc7fea68a1 mtdinfo: add regioninfo/eraseblock map display On certain flash (NOR flash that have eraseblock region info), `mtdinfo -a' tries to open the MTD node file, for use with the ioctl MEMGETREGIONINFO; however, we didn't supply a device node path to `mtdinfo -a', so it's using NULL, resulting in errors like: mtdinfo: error!: couldn't open MTD dev: (null) error 14 (Bad address) For now, we can just skip dumping region_info with the `-a' flag. If we find a better way to do this (e.g., export via sysfs, find device nodes via automatic routines, etc.), then we can kill the workaround and this FIXME should be removed. The regression was first reported at: http://lists.infradead.org/pipermail/linux-mtd/2011-July/037232.html The result of recent changes is that we cannot get region_info for devices via the `--all' option. We add a note in the help message warning that mtdinfo may find more info when given a device patch, e.g., /dev/mtdX. Reported-by: Brian Foster <brian.foster@maxim-ic.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@intel.com>
2011-06-30mtdinfo: remove -m leftoversArtem Bityutskiy
We have removed the -m option, but did not remove args.mtdn which represents the -m parameters. Kill args.mtdn as well. Tweaked by Brian Norris. Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2011-06-29mtdinfo: kill -m optionBrian Norris
According to feature-removal-schedule, we shouldn't use `-m', since it relies on a specific device-naming pattern. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-29mtd-utils: switch more utils to unified versioningBrian Norris
More utilities now use the common VERSION system. For utils that printed a very simple message, we use the new common_print_version() "function." Signed-off-by: Brian Norris <computersforpeace@gmail.com> Acked-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>
2011-06-27rewrite build system to avoid recursionMike Frysinger
The ubi-utils/src/ subdir is tossed as it just complicates things for no real gain. The dictionary.h header is relocated to the ubi-utils/include/ since other headers in there need it. The top level clean is replaced with a `find -delete` on objects, so it might prune more than necessary, but many projects now do this sort of thing and no one complained there. A "mkdep" helper generates the actual rule, and the variables are used with "foreach" to expand these automatically. The tests subdir is updated only to reflect the ubi-utils source move. Otherwise, it is left untouched as making that non-recursive isn't really worth the effort. While we're gutting things, also through in kbuild style output while building to make things more legible. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <dedekind1@gmail.com>