aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-06-28ubi-utils: ubimkvol: add support for skipping CRC check of a static volume ↵Quentin Schulz
when opening Let's let the user create static UBI volume with CRC checking at opening disabled if desired. Introduce the `--skipcheck` or `-k` option for such feature. Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-28libubi: add volume flags to ubi_mkvol_requestQuentin Schulz
Now that we have per-UBI volume flags (for instance for skipping CRC check when opening it) from the Linux header, let's add it to the ubi_mkvol_request in libubi and assign the flags to ubi_mkvol_req from the Linux header from ubi_mkvol. Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-28UBI: update ubi-user.h and ubi-media.hQuentin Schulz
Update both header files to add support for flag specifying whether to skip the CRC check for static UBI volumes. Taken from the kernel headers. Some users of static UBI volumes implement their own integrity check, thus making the volume CRC check done at open time useless. For instance, this is the case when one use the ubiblock + dm-verity + squashfs combination, where dm-verity already checks integrity of the block device but this time at the block granularity instead of verifying the whole volume. Skipping this test drastically improves the boot-time. Suggested-by: Boris Brezillon <boris.brezillon@bootlin.com> Reviewed-by: Boris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: Quentin Schulz <quentin.schulz@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-18Add configure switch to disable compiling/installing lsmtdDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-18Add manpage for lsmtdDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-18Add lsmtd programDavid Oberhollenzer
This patch adds a program called "lsmtd". The program produces a pretty printed list of the hierarchy of UBI and MTD devices on a system. It tries to imitate the lsblk program from util-linux as closely as possible. A number of command line switches are available to fine tune what information should be exposed and in what output format. The goal is to have a simple way of displaying the complete MTD stack on a system in a human readable form instead of piecing details together from proc files and various UBI utilities. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-14mkfs.ubifs: Implement selinux labelling support in mkfs.ubifs.Ritesh Harjani
This implements/adds selinux labelling support to mkfs.ubifs utility. It adds an extra option in configure to enable selinux labelling support and then finally in mkfs.ubifs adds an extra option to pass the file_contexts which is looked up for filesystem file labels. - Default behavior is kept without selinux so as to not break existing support where selinux library/headers may not be present. - If this is configured with --with-selinux then XATTR from the file_contexts(passed with --selinux option while mkfs.ubifs) will be taken and not from the host file's xattr. This is done to avoid the problem where the host OS may have selinux enabled and hence same xattr names will be present in both host filesystem files and from the --selinux=file passed. So the existing behavior is kept mutually exclusive and preference is given to selinux xattrs (if configured with --with-selinux). Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-14mkfs.ubifs: add_xattr is not depending on host XATTR supportRitesh Harjani
add_xattr adds the xattr to the ubifs image and has nothing to do with host XATTR support. Now that we are adding support where selinux interfaces may use this API even when host OS(where ubi/ubifs image is being created) does not support XATTR -so remove it from WITHOUT_XATTR #ifdef. Signed-off-by: Ritesh Harjani <riteshh@codeaurora.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-09Revert "Return correct error number in ubi_get_vol_info1"David Oberhollenzer
This reverts commit dede98ffb706676309488d7cc660f569548d5930. The original commit tried to fix a descrepancy between the implementation and the documentation by making the implementation comply. When making the change, it was overlooked, that ubinfo and ubirename were written against the implementation instead of the behaviour specified by the documentation. So were further internal functions like ubi_get_vol_info1_nm which further breaks ubirmvol. A report with an outline of a resulting problem can be read on the mailing list: http://lists.infradead.org/pipermail/linux-mtd/2018-June/081562.html From the report: steps to reproduce: have mtd-utils 2.0.1 or 2.0.2 0. make a bunch of ubi volumes in sequential order ubimkvol /dev/ubi0 -s 64KiB -N test1 ubimkvol /dev/ubi0 -s 64KiB -N test2 ubimkvol /dev/ubi0 -s 64KiB -N test3 ubimkvol /dev/ubi0 -s 64KiB -N test4 .. 1. delete the test1 volume, making a hole in the volume table ubirmvol /dev/ubi0 -N test1 2. try an affected tool (i.e. "ubirmvol /dev/ubi0 -N test4" ) |root at mr24:/# ubirmvol /dev/ubi0 -N test4 |ubirmvol: error!: cannot find UBI volume "test4" | error 19 (No such device) or "ubinfo -a" | root at mr24:/# ubinfo -a | UBI version: 1 | Count of UBI devices: 1 | UBI control device major/minor: 10:59 | Present UBI devices: ubi0 | | ubi0 | Volumes count: 11 | Logical eraseblock size: 15872 bytes, 15.5 KiB | Total amount of logical eraseblocks: 1952 (30982144 bytes, 29.5 MiB) | Amount of available logical eraseblocks: 75 (1190400 bytes, 1.1 MiB) | Maximum count of volumes 92 | Count of bad physical eraseblocks: 0 | Count of reserved physical eraseblocks: 40 | Current maximum erase counter value: 984 | Minimum input/output unit size: 512 bytes | Character device major/minor: 251:0 | ubinfo: error!: libubi failed to probe volume 5 on ubi0 | error 19 (No such device) | Present volumes: 0, 1, 2, 3, 4root at mr24:/# Reported-by: Christian Lamparter <chunkeey@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-05-12mtd-utils: make sure pkg-config is installed in configure scriptDavid Oberhollenzer
This patch adds a check to configure.ac that tests if pkg-config is available on the system. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-05-12ubiformat: remove no-volume-table optionDavid Oberhollenzer
Using the -n or --no-volume-table flags, ubiformat can format an mtd device to a broken UBI that does not attach on recent kernel. Only very old UBIs had no volume table. This patch removes the option entirely from ubiformat. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-05-12ubiformat: process command line arguments firstDavid Oberhollenzer
If libmtd_open fails, the program always exists with failure status and prints "MTD subsystem is not present". Even `ubiformat --help` produces the same result, which is definitely undesired. This patch moves command line option processing first to get the desired behavior. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-04-16Release mtd-utils-2.0.2v2.0.2David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-04-16Fix unit-test header and file paths for out of tree buildsDavid Oberhollenzer
If we build mtd-utils outside the source path, we cannot use relative paths to refere to headers in the source tree. We have to specify absoulte paths using the top_srcdir variable. This was done right for the utility binaries, but overlooked for the unit test porgrams. This patch fixes the header paths and SYSROOT variable for the unit tests, so they build and run propperly outside the source tree. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-04-16Fix unit test mockup for oobavail sysfs fileDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-04-10misc-utils: flash_erase: Fix Jffs2 type flash erase problemXiaolei Li
Currently, Jffs2 clean marker is not written actually, because the oob write length is set to 0 when do mtd_write(). So, get OOB available size at first, and set the correct clean marker length, then program clean marker to free OOB area. Fixes: d7e86124d55b ("mtd-utils: Support jffs2 flash-erase for large OOB (>32b)") Signed-off-by: Xiaolei Li <xiaolei.li@mediatek.com> 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>
2018-04-05mtd-utils: ubifs: fix typo in without_lzo definitionKoen Vandeputte
Fixes: 1d04b4d5361a ("fix build when WITHOUT_LZO is set") Signed-off-by: Koen Vandeputte <koen.vandeputte@ncentric.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-03-07mkfs.ubifs: Allow root entry in device tableDavid Engraf
When using a local root folder the permissions, user and group settings are taken from the local folder. These permissions might be incorrect if the folder has been created for the local user. Creating an UBIFS image on my local system resulted in the following output on the target: drwx------ 17 1000 1000 1264 Jan 1 00:00 . drwx------ 17 1000 1000 1264 Jan 1 00:00 .. drwxr-xr-x 2 root root 9104 May 30 2017 bin drwxr-xr-x 7 root root 2760 Jan 1 00:00 dev ... mkfs.ubifs aborts with an error message when the device table contains a root entry. This patch allows setting the root folder permissions, user and group to overwrite local configurations. Signed-off-by: David Engraf <david.engraf@sysgo.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-03-05mtd: tests: check erase block count in page testStefan Agner
When there is only a single erase block, the cross erase test does not report sensible errors. Warn in case there is only a single erase block instead of executing the test. Signed-off-by: Stefan Agner <stefan@agner.ch> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-02-14mtd: unittests: Stop testing stat() callsBalint Reczey
Sometimes __xstat is called instead that makes tests fragile. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-02-14mtd: unittests: Decode arg size from ioctl requestBalint Reczey
Signed-off-by: Balint Reczey <balint.reczey@canonical.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-02-14mtd: unittests: Use proper unsigned long type for ioctl requestsBalint Reczey
This fixes tests on s390x Signed-off-by: Balint Reczey <balint.reczey@canonical.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-01-30ubi-utils: ubiformat.c: convert to integer arithmeticAndrea Adami
Do not cast percent to double, it is just used as upper limit. Avoid floating point to fix compilation for aarch64 against klibc: error: '-mgeneral-regs-only' is incompatible with floating-point code | int percent = ((double)si->ok_cnt)/si->good_cnt * 100; | ^~~~~~~ Notes: * The checks in the code above this line ensure that si->good_cnt is not 0. * The code assumes si->good_cnt * 100 will not overflow, then we can use (si->ok_cnt * 100) safely because the former is bigger. * The truncated result does not affect the logic: i.e. a value of 49.9 is truncated to 49 and is still <50. Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-01-30mtd-utils: common.c: convert to integer arithmeticAndrea Adami
We use floating point just to print out KiB, MiB, GiB. Avoid that to be klibc friendly. Fixes compilation for aarch64 against klibc: error: '-mgeneral-regs-only' is incompatible with floating-point argument | printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024)); etc. Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-12-05Run unit test programs through "make check"David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-22mtd: tests: Fix check on ebcnt in nandpagetestPaul HENRYS
If the number of erase blocks to use is not specified, ebcnt originally set to -1 leads the program to exit with: "Cannot run with less than two blocks." If the number of erase blocks to use is not specified and thus ebcnt is equal to -1, the expected behaviour is to perform the test on all the erase blocks of the mtd partition. This fixes the change introduced in 4458ad6481f60d9884925d5bc62a7954880d181b. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-18libscan: fix a comment typo in libscan.hRock Lee
Signed-off-by: Rock Lee <rockdotlee@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-15libmtd: fix a comment typo in dev_node2numRock Lee
Signed-off-by: Rock Lee <rockdotlee@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-03ubi-utils: ubicrc32: process command line arguments firstDavid Oberhollenzer
When a command line option is used (e.g. --version), the tool tries to open it as a file first, then *uppon success* attempts to process the command line options (including what it assumed to be an input file) which is obviously broken. This patch moves command line processing first and then attempts to open *the first unprocessed* argument. Reported-by: Uwe Kleine-König <ukleinek@debian.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-03nandbiterrs: Fix copy & paste failDavid Oberhollenzer
When porting some of the mtd-tests to user space, some code was simplified. Among others, a while loop that iterates of page contents was replaced with a for loop, but the old increment was left in place, so every second byte was skipped. This patch removes the erroneous second increment. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-03Enable further warning flags, address new warningsDavid Oberhollenzer
mtd_debug: Remove a duplicate if case. MTD_CAP_NANDFLASH has only one flag set (MTD_WRITEABLE). Directly below, we had a check for MTD_WRITEABLE in the else branch which can't possible ever have triggered. Checking for MTD_WRITEABLE in addition to the CAP constants was probably not intended anyway, given the check for the individual flags if all else fails. integck: We already established that "r" is less than the number of elements in the list, so the loop condition doesn't need to check if w is NULL in addition. At least this way, the compiler "gets" that w cannot be NULL below and doesn't issue warnings. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-03jittertest: Use the appropriate versions of abs()David Oberhollenzer
When passing a long argument, actually use labs(). The other case of passing a float to "int abs(int)" and casting the result to an int doesn't really make sense. Pull the cast inside the abs(). Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-02Mark or fix switch cases that fall throughDavid Oberhollenzer
Now that C++17 introduced a special fallthrough keyword for explicitly tagging switch cases that are supposed to fall through, newer gcc versions also implement a feature request from 2002 to warn about maybe unwanted fall-throughs in switch cases in other languages (like C). For C code, we can either add a gcc specific attribute at the end of the switch case, or use a special comment that gcc checks for, indicating that the fall-through behaviour is indeed intended. This patch adds a "/* fall-through */" comment at the end of various case blocks to silence gcc warnings and in some cases a break, where fall-through was probably not intended. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-02Add no-return attribute to usage() style functionsDavid Oberhollenzer
A common pattern in command line processing is having a usage() function that prints out how to use the command line options and then terminates. The function is typically used inside a switch block for command line options like `-h' or unknown options. In a lot of places, the break keyword is omitted, because the function exits anyway. However, this triggers gcc warnings about implicit fall-through. Rather than adding a phony "/* fall-through */" this patch flags the usage() style function with a gcc attribute, indicating that they do not return and removes further superfluous break statements. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-11-02Remove self-assignments of unused paramtersDavid Oberhollenzer
Use casts to void instead. Clang generates warnings about that by default. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-10-30mkfs.ubifs: ignore EOPNOTSUPP when listing extended attributesPavel Roskin
Systems that don't support extended attributes should still be able to create ubifs images. Signed-off-by: Pavel Roskin <plroskin@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-10-05tests: checkfs: Remove unused source file from makefilesDavid Oberhollenzer
The file comm.c was erroneously compiled into makefiles. This patch fixes that in the Automake file. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-10-05misc-utils: initialize "ip" in docfdisk to NULLDavid Oberhollenzer
Technically it is initializied in the for loop right before being used. From the conditional above, we know that the for loop is executed at least once and the variable is always initialized, but gcc doesn't appear to perform the same reasoning. This patch adds an initialization of the variable for the sake of making the compiler happy. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-10-05ubi-tests: io_update: fix missleading indentationDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-10-04mkfs.ubifs: Apply squash-uids to the root nodeRomain Izard
The root node of the file system needs to be handled as a special case when removing the owner information from the input. Signed-off-by: Romain Izard <romain.izard.pro@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-08-28Add ctags files to .gitignoreUwe Kleine-König
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-08-24Release mtd-utils-2.0.1v2.0.1David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-08-24mtd-utils: tests: Avoid using less than two blocks in nandpagetestMiquel Raynal
Forbid the use of less than 2 eraseblocks in nandpagetest. It is obvious that the test cannot run on zero block, but it cannot run on only one block neither. The reason is: get_first_and_last_block() will return the same id for both the first and the last blocks. In erasecrosstest(), the logic is: - erase/write/read/verify first block - erase/write again first block - erase *last* block - read/verify first block When using only one block, 'first' refers to the same block as 'last', leading to erasing the block before reading it. Hence, the test would fail with no actual reason. Signed-off-by: Miquel Raynal <miquel.raynal@free-electrons.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-08-10mtd-utils: ubinfo: add parameter checkAaron Marcher
Adds a check if the UBI device number is specified when passing a volume name as parameter. This fixes an issue, where by default an inexistent UBI device named "ubi-1" is selected because of missing checks. Signed-off-by: Aaron Marcher <me@drkhsh.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-07-10mkfs-ubifs: fix inclusion of uuid.hRolf Eike Beer
The include directory exported by uuid.pc is */include/uuid, so uuid.h must be included without any directory in the path. This usually works out because uuid is installed in the normal prefix, so the parent directory of what uuid has as include dir ends up in the include path anyway. In case one uses a custom uuid outside of the regular include path this breaks. Signed-off-by: Rolf Eike Beer <eb@emlix.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-07-03mtd-utils: tests: Add Erased Pages Bit Flip TestHarpreet Eli Sangha
Bit flip detection for written and erased pages tend to have different implementations. Where written pages are detected and corrected using ECC, erased pages are typically detected by ensuring that the number of zeros is less than a specified threshold. As such, it's necessary to have the 'nandbiterrs' test support the testing of written and erased pages. Bit flips in erased pages are emulated by rewriting the page in raw mode, to prevent the use of ECC. Signed-off-by: Harpreet Eli Sangha <harpreet@nestlabs.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-28Add const modifier to read only strings and string constantsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2017-06-28Silence warnings about unused argumentsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>