aboutsummaryrefslogtreecommitdiff
path: root/lib/libmtd_legacy.c
AgeCommit message (Collapse)Author
2018-09-20libmtd: don't print an error message for devices without ecc supportDavid Oberhollenzer
The libmtd library tries to obtain the available OOB size via the sysfs with a fallback to the ECCGETLAYOUT ioctl. For some devices (e.g. plat-ram), the fallback path is always taken and prints an error message to stderr since the ioctl fails. This patch fixes the fallback path by suppressing the error message if errno is set to EOPNOTSUPP (i.e. the device simply doesn't support that). Fixes: a10353584f93 ("libmtd: Add support to access OOB available size") Reported-by: Chris Packham <Chris.Packham@alliedtelesis.co.nz> Reviewed-by: Xiaolei Li <xiaolei.li@mediatek.com> Tested-by: Chris Packham <Chris.Packham@alliedtelesis.co.nz> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-04-10libmtd_legacy: Fix some function description mismatchesXiaolei Li
Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-04-10libmtd: Add support to access OOB available sizeXiaolei Li
This patch exposes OOB available size to user. Then user can use OOB free area according to OOB available size. Steps to get OOB available size: First, access /sys/class/mtd/mtdX/oobavail. If not exist, then try to get ecc layout by ioctl "ECCGETLAYOUT". If none of them work, set OOB available size to 0. Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-03-15Fix libmtd behaviour if MTD is not present on the systemDavid Oberhollenzer
The documentation of libmtd_open says, if it returns NULL and errno is zero, MTD is not present. However, the current version always returns a libmtd_t object. The function internally checks, if it can access the MTD sysfs files and, if not, sets a flag to use the procfs fallback. This patch adds an additional check to libmtd_open, to test if the MTD procfs file can be read and fails with errno cleared if it does not exist. Furhtermore, mtd_get_info is documented to fail with errno set to ENODEV if MTD is not present. First of all, this was broken in the original version. It was implemented to specification for the sysfs code path, but if MTD is not present, that won't be executed, because of the flag set by libmtd_open. This makes the check not only redundant, but masks an actual error (the sysfs paths suddenly not being readable anymore). The legacy path that was used if the sysfs files are not avaible fails with ENOENT if it cannot read the procfs file. With the above changes in addition, we don't have a libmtd_t object if neither sysfs nor procfs is readable, so this error status no longer makes sense. This patch removes the documentation on the ENODEV errno, and makes sure that mtd_get_info always returns with apropriate errno on failure. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-11-17Remove unused legacy_libmtd_open internal libmtd functionDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2013-10-22add the MTD_MLCNANDFLASH caseHuang Shijie
The MTD_MLCNANDFLASH case is missed in the current code. This patch adds it. Signed-off-by: Huang Shijie <b32955@freescale.com> Signed-off-by: Brian Norris <computersforpeace@gmail.com>
2012-02-29libmtd_legacy: don't open device in R/WBrian Norris
On legacy kernels with ROM devices, we can get mtdinfo errors like: libmtd: error!: cannot open "/dev/mtd4" error 13 (Permission denied) mtdinfo: error!: libmtd failed get MTD device 4 information error 13 (Permission denied) We don't need O_RDRW access for informational ioctls(), so make this O_RDONLY. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2012-02-14limbtd: implement mtd_dev_present for old kernelsArtem Bityutskiy
Implement the 'legacy_dev_present()' function which will check whether an MTD device is present by scanning the /proc/mtd file when the MTD subsystem does not support sysfs (the case for pre-2.6.30 kernels). This patch also moves the 'mtd_dev_present()' function to a slightly more logical position. Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
2010-11-29libmtd: fix OOB size initialization in legacy codeKetil Froyn
legacy_get_dev_info() forgot to set the OOB size Signed-off-by: Ketil Froyn <ketil@froyn.name> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-10-02libmtd: make malloc failures fatalMike Frysinger
This converts libmtd to the common xalloc helpers and in doing so, makes memory allocation failures fatal rather than returning an error to the caller. I think this is acceptable behavior. Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-10-01libmtd: fix "fount" typoMike Frysinger
Signed-off-by: Mike Frysinger <vapier@gentoo.org> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>
2010-07-13mtd-utils: move libmtd source files to lib/ subdirectoryKevin Cernekee
Source files for libmtd, crc32, and fec are scattered throughout the tree. Move them to a central location so they can be built into a common "libmtd.a" library used by all mtd-utils programs. This patch only renames/deletes files and does not change the content. Also modify the build system and source code so that libmtd.a can be built from a "common" location (lib/). Statically link all utilities at the top level with libmtd.a . Minor changes to mkfs.ubifs to allow using the common crc32 implementation. Signed-off-by: Kevin Cernekee <cernekee@gmail.com> Signed-off-by: Artem Bityutskiy <Artem.Bityutskiy@nokia.com>