summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2017-03-29libubi.c: add klibc specific fixes for ioctlAndrea Adami
First issue is that ioctl() in klibc doesn't expect a constant as arg3. Second issue is that arg3 in klibc ioctl() implementation is not optional. Fixes: | ubi-utils/libubi.c: In function 'do_attach': | ubi-utils/libubi.c:698:8: warning: passing argument 3 of 'ioctl' discards | 'const' qualifier from pointer target type | ret = ioctl(fd, UBI_IOCATT, r); | ^ | In file included from ubi-utils/libubi.c:32:0: | .../lib/klibc/include/sys/ioctl.h:15:14: note: expected 'void *' but argument | is of type 'const struct ubi_attach_req *' | __extern int ioctl(int, int, void *); | ^ | ubi-utils/libubi.c: In function 'ubi_vol_block_create': | ubi-utils/libubi.c:1118:9: error: too few arguments to function 'ioctl' | return ioctl(fd, UBI_IOCVOLCRBLK); | ^ | In file included from ubi-utils/libubi.c:32:0: | .../lib/klibc/include/sys/ioctl.h:15:14: note: declared here | __extern int ioctl(int, int, void *); | ^ | ubi-utils/libubi.c: In function 'ubi_vol_block_remove': | ubi-utils/libubi.c:1123:9: error: too few arguments to function 'ioctl' | return ioctl(fd, UBI_IOCVOLRMBLK); | ^ | In file included from ubi-utils/libubi.c:32:0: | .../usr/lib/klibc/include/sys/ioctl.h:15:14: note: declared here | __extern int ioctl(int, int, void *); | ^ Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-03-22Return correct error number in ubi_get_vol_info1David Oberhollenzer
If the specified UBI device or volume does not exist, the function is supposed to set errno to ENODEV. This patch adds a check to ubi_get_vol_info1 to change the errno to ENODEV if vol_get_major cannot access the underlying sysfs file, so the function propperly returns that the device or volume does not exist, instead of failing with errno set to ENOENT. 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>
2017-03-02Fix build with muslKhem Raj
Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-03-02Replace rpmatch() usage with checking first character of lineDavid Oberhollenzer
This is based on the patch from Khem Raj used by openembedded. In addition to the original patch, this also removes the fallback implementation that was provided for C libraries that don't implement rpmatch. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-03-02Fix alignment trap triggered by NEON instructionsYuanjie Huang
NEON instruction VLD1.64 was used to copy 64 bits data after type casting, and they will trigger alignment trap. This patch uses memcpy to avoid alignment problem. Signed-off-by: Yuanjie Huang <Yuanjie.Huang@windriver.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-21mtd-utils: Support jffs2 flash-erase for large OOB (>32b)Manikandan Ramachandran
"flash_erase" fails on nand flash with JFFS2 that has OOB size greater than 32 bytes. "flash_erase" uses "MEMGETOOSEL" to determine OOB size. This ioctl call is obsolete and returns error if OOB size is more than 32 bytes. This patch fixes this issue by using "mtd_write" to update clean-marker instead of mtd_oob_write. This fix is based on the discussion: http://lists.infradead.org/pipermail/linux-mtd/2011-September/037958.html. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-21ubi: tests: Speedup io_paral by using rand_r()Richard Weinberger
rand() is not thread safe, but glibc seems to use a shared state which is protected by a mutex. io_paral spawns a few threads and they call rand() more or less in parallel, which causes heavy lock contention. That makes the test extremely slow on some setups. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Gstir <david@sigma-star.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-21ubi: tests: Support up to 65k NAND page sizeRichard Weinberger
io_read and io_update of mtd-utils support NAND with 4k page size only. Increase that to support up to 65k page size. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Gstir <david@sigma-star.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-21ubi: tests: Replace variable-length array with malloc()David Gstir
io_read and io_update of mtd-utils use variable-length arrays for test data. Since this could result in allocating many megabytes using alloca(), switch to malloc(). Signed-off-by: David Gstir <david@sigma-star.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-20Remove README.udev from ubi-tests extra distDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-20ubirename: trivial fixes to the help textLuca Ceresoli
Add a missing space after PROGRAM_NAME and fix a typo. Signed-off-by: Luca Ceresoli <luca@lucaceresoli.net> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-20Remove UDEV_SETTLE_HACKRichard Weinberger
UDEV_SETTLE_HACK addresses a problem which does no longer exist on Linux. These days we have devtmpfs. New devices will automatically created on the kernel side and user space has no longer to wait for udev. As udev has a hard dependency on devtmpfs we can depend on it too. People which don't use udev nor plain devtmpfs are anyways on their own. Android, I'm looking at you... Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-20mtd-utils: serve_image: Use PRIdoff_t as format specifier.Torsten Fleischer
To be independent on the size of off_t the format specifier determined of common.h should be used instead of PRIu64. Signed-off-by: Torsten Fleischer <torfl6749@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-02-20mtd-utils: Fix format specifier definitions for off_t and loff_t.Torsten Fleischer
On 32bit systems (e.g. ARM) the size of off_t can be 4 byte and the size of loff_t 8 byte. This causes compiler warnings like the following: flash_erase.c: In function 'show_progress': flash_erase.c:56:22: warning: format '%llx' expects argument of type 'long long unsigned int', but argument 3 has type 'off_t {aka long int}' [-Wformat=] bareverbose(!quiet, "\rErasing %d Kibyte @ %"PRIxoff_t" -- %2i %% complete ", and an output like this: ~# flash_erase /dev/mtd2 0 1 Erasing 64 Kibyte @ 6400000000 -- 0 % complete ~# Since the size of off_t and loff_t can differ from each other, the printf format specifier should be determined separately for both. Further the format specifiers should be based directly on the size of the particular data type. Signed-off-by: Torsten Fleischer <torfl6749@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-01-18nanddump: Add --skip-bad-blocks-to-start optionMike Crowe
The --skip-bad-blocks-to-start option will increase the start address by the size of each bad block encountered between the start of the partition and the specified start address. This can be useful if other readers of the partition will be reading using a simple bad-block-skipping algorithm. Signed-off-by: Mike Crowe <mac@mcrowe.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-01-18nandwrite: Add --skip-bad-blocks-to-start optionMike Crowe
The --skip-bad-blocks-to-start option will increase the seek offset by the size of each bad block encountered between the start of the partition and the specified start address. This can be useful when writing part way through a partition that will be read using a simple bad-block-skipping algorithm. Signed-off-by: Mike Crowe <mac@mcrowe.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-01-12nandwrite: fix/cleanup bad block skippingDavid Oberhollenzer
JFFS2 supports clustering erase blocks to virtual erase blocks. nandwrite supports this, but previously mixed up virtual and physical erase block numbers when checking for bad blocks. This patch adds a function for checking if a virtual erase block is bad and replaces the broken mtd_is_bad loop. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-01-12nandwrite: replace erase loop with mtd_erase_multiDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-01-12nandwrite: add stricter sanity checking for blockalignDavid Oberhollenzer
This patch makes sure that a virtual erase block is always composed of a postivie number of erase blocks (i.e. 1 or more) and enforces the block alignment to be a power of two as suggested by the help text and assumed throughout the program. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-12-22Release mtd-utils-2.0.0v2.0.0David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-12-22mtd-utils: Add configure switches to disable jffsX or ubifs toolsDavid Oberhollenzer
For some applications, like building a root filesystem for an embedded device, it may be desireable to only build and install a subset of the mtd-utils. This can be done throught the targets of the generated Makefile and hand picking executables, however the jffsX and ubifs utilities have external build dependencies that may not be needed. This patch adds configure switches to disable building the jffsX and ubifs utilities. Their respective build dependencies (zlib, lzo, uuid) are only requested if the tools are being built. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Reviewed-by: Richard Weinberger <richard@nod.at>
2016-12-14Release mtd-utils-2.0.0-rc2v2.0.0-rc2David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-12-14Enable tests so they are included in the make dist targetDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-12-14mtd-utils: Correct casting for final status report in flashcpJonathan Fether
Add correct casting for filestat.st_size in flashcp.c. While the interim status updates had correct casting from commit 08b243, the final update was not. Signed-off-by: Jonathan Fether <jonf@mds.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-12-13Fix packaging of unit test filesDavid Oberhollenzer
Previously, the unit test sysfs mock files and headers were not added to the distribution packag. Not packaging the header leads to compilation of the unit tests failing. Not packaging the stub files caueses the unit tests themselves to fail. This patch explicitly adds the header and sysfs mock files to the distribution target, allowing the unit tests to be used outside the git tree. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-12-09nandwrite: Factor out buffer checking codeMarek Vasut
Pull the buffer content checking code into separate function and simplify the code invoking it slightly. Signed-off-by: Marek Vasut <marex@denx.de> Reviewed-by: Boris Brezillon <boris.brezillon@free-electrons.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-12-07Release mtd-utils-2.0.0-rc1v2.0.0-rc1David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-12-06common: Fix 'unchecked return code' warningsBoris Brezillon
Several tools are simply not checking return code of functions marked with 'warn_unused_result'. Provide wrappers for the read/write functions to avoid patching old code and providing proper error handling. Fix the remaining ones (calls to fgets() and system()). Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2016-12-06common: Fix PRI{x,d}off definitions for x86_64 platformBoris Brezillon
Compiling for x86_64 generates a lot of warning because the PRIxoff_t and PRIdoff_t are not properly defined, which comes from the missing SIZEOF_LONG definition. Use the autotools to generate a config.h header, include this header from common.h and ask autoheader to generate the SIZEOF_LONG and SIZEOF_LOFF_T definitions. Use these new definitions to assign the proper descriptors to PRIxoff_t and PRIdoff_t. Signed-off-by: Boris Brezillon <boris.brezillon@free-electrons.com>
2016-12-06nandwrite: add skip-all-ff-pages-optionKees Trommel
Signed-off-by: Kees Trommel <ctrommel@linvm302.aimsys.nl> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-11-29Define WITHOUT_XATTR if sys/acl.h or sys/xattr.h is missingDavid Oberhollenzer
The programs mkfs.jffs2 and mkfs.ubifs include those two headers if WITHOUT_XATTR is not defined. Up to now, this macro is only defined if the configure script is run with --without-xattr. If the headers are not present on a system and the configure script is run without special flags set, the build fails. This patch adds a check for the presence of those headers and disables the feature if one of the headers is missing. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-11-17Allow version string to have a release candidate suffixDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-11-17Move ubi-utils libraries to common library locationDavid Oberhollenzer
Historically, the mtd-utils and ubi-utils were seperate packages. The ubi-utils were at some point merged into the mtd-utils. They first appeared in the release tar-ball in version 1.1.0 in their own sub-hirarchy with their own buildsystem, readme, documentation, etc. A lot of the duplicated stuff got centralized/removed over time. This patch further cleans up the directory hirarchy duplication by moving common libraries from the ubi-utils/ into the central lib/ and include/ directories in the top directory of the mtd-utils package. This includes: - libuib.a & libubigen.a used by the ubi utilities - libscan.a currently only used by ubiformat - libiniparser.a used by ubinize Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
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>
2016-11-17Remove unused ubiutils_print_text from ubi-utils commonDavid Oberhollenzer
The function ubiutils_print_text was previously used by ubinize to pretty-print parts of the help text. Since the help text has been moved to a man page, the function is no longer used/needed. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-11-17Add ubinize manpageDavid Oberhollenzer
This patch removes the lengthy help text from the ubinize utility that attempted to describte the file format and every minor detail, and reformats it into a more readable man page. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-11-17Add Makefile for unittestsDaniel Walter
Signed-off-by: Daniel Walter <dwalter@sigma-star.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2016-11-17Add unittests for libubiDaniel Walter
Add unittests for most functions provided by libubi Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
2016-11-17Add unittest for libmtdDaniel Walter
unit tests for most functions provided by libmtd. Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
2016-11-17Add sysfs tree for unittestsDaniel Walter
add mocked sysfs used by libmtd and libubi unittests Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
2016-11-17Add support for sysfs mockingDaniel Walter
In order to use test files, allow sysfs root to be set during compile time Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
2016-11-17Add unit test helpersDaniel Walter
Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
2016-11-17Fix uninitialized buffersDaniel Walter
Uninitialized buffers lead to failing unittests, since padding was not set to 0. Additionally this stops valgrind from complaining as well. Signed-off-by: Daniel Walter <dwalter@sigma-star.at>
2016-11-17mtd-utils: Add nand sub-page test utilityDavid Oberhollenzer
Basically a user space port of the mtd sub page test kernel module. In addition to the module parameters, the utility supports using only a sub-range of the flash erase blocks with a configurable stride and can restore the block contents after the test. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2016-11-17mtd-utils: Add nand page test utilityDavid Oberhollenzer
Basically a user space port of the mtd page test kernel module. In addition to the module parameters, the utility supports using only a sub-range of the flash erase blocks with a configurable stride. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2016-11-17mtd-utils: Add flash read test utilityDavid Oberhollenzer
Basically a user space port of the mtd read test kernel module. In addition to the module parameters, the utility can scan only a sub-range of the flash erase block with a configurable stride. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2016-11-17mtd-utils: Add nand flash bit errors testDavid Oberhollenzer
Basically a user space port of the mtd speed test kernel module. In addition to the module parameters, the utility can resture the block contents after test and allows setting the maxium writes for the test. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2016-11-17mtd-utils: Add flash speed test utilityDavid Oberhollenzer
Basically a user space port of the mtd speed test kernel module. In addition to the block offset and count module parameters, the utility supports a block stride and can restore the block contents after test. Furthermore, a flag can be used to disable destructive tests (i.e. only perform read speed tests). Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2016-11-17mtd-utils: Add flash stress test utilityDavid Oberhollenzer
Basically a user space port of the mtd stress test kernel module. In addition to the block offset and count module parameters, the utility supports a block stride and can restore the block contents after test. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>