aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2018-11-01mkfs.ubifs: Implement fscrypto context store as xattrRichard Weinberger
Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Implement basic fscrypto context passingRichard Weinberger
Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Implement UBIFS_FLG_ENCRYPTIONRichard Weinberger
...and set UBIFS format version Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Add basic fscrypto functionsRichard Weinberger
...maybe we should add them to crypto.c? Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Add fscrypto definesRichard Weinberger
most of them should be UAPI, therefore check using #ifndef Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Make r5 hash binary string awareRichard Weinberger
As of now all filenames known by UBIFS are strings with a NUL terminator. With encrypted filenames a filename can be any binary string and the r5 function cannot search for the NUL terminator. UBIFS always knows how long a filename is, therefore we can change the hash function to iterate over the filename length to work correctly with binary strings. Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Implement UBIFS_FLG_DOUBLE_HASHDavid Oberhollenzer
Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01mkfs.ubifs: Add crypto helper functionsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at> Signed-off-by: Richard Weinberger <richard@nod.at>
2018-11-01common: Add round functionsRichard Weinberger
Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-11-01Import latest ubifs-media.hRichard Weinberger
Signed-off-by: Richard Weinberger <richard@nod.at> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-10-02mkfs.ubifs: Fix xattr nlink valueSascha Hauer
The nlink value of a xattr node must always be one, it has nothing to do with the nlink value of the inode the attribute belongs to. The bug can be observed when mounting a mkfs.ubifs generated image which contains xattrs on directories or files with hardlinks to them. When mounting such an image with chk_fs = 1 it fails with: UBIFS error (ubi0:0 pid 1833): dbg_check_filesystem: inode 3308 nlink is 3, but calculated nlink is 1 Another bug that can be triggered is an assertion in ubifs_xattr_remove() which assures that the xattr i_nlink count should be one when the xattr is removed. Fixes: 50044ef ("mkfs.ubifs: Add extended attribute support") Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-10-02mtd-utils: Instead of doing preprocessor magic, just output off_t as long longThorsten Glaser
Fix warnings abot PRIdoff_t in libmtd.c, in mtd_read (and mtd_write): In file included from ../git/lib/libmtd.c:40:0: ../git/lib/libmtd.c: In function 'mtd_read': ../git/include/common.h:110:18: warning: format '%ld' expects argument of type 'long int', but argument 5 has type 'off_t {aka long long int}' [-Wformat=] ../git/include/common.h:120:2: note: in expansion of macro 'errmsg' errmsg(fmt, ##__VA_ARGS__); \ ^~~~~~ ../git/lib/libmtd.c:1082:10: note: in expansion of macro 'sys_errmsg' return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t, ^~~~~~~~~~ /usr/lib/klibc/include/inttypes.h:28:17: note: format string is defined here #define PRId32 "d" Signed-off-by: Thorsten Glaser <tg@mirbsd.org> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-09-20mtd-utils: common.h: fix prompt functionDavid Oberhollenzer
The prompt() function is intended to query a yes/no reply from a command line user by reading in an entire line of text using getline() and checking the first character. If the line is empty, a default value is returned. First of all, this patch replaces the usage of getline() with fgets() to avoid compilation problems on some smaller C libraries, like klibc, that do not have a getline() implementation. Since we now have a static line length, this may break some build setups that input lengthy giberish instead of 'y' or 'n'. Second, this patch fixes a more severe bug in prompt(), replacing a 'while' keyword with the 'if' that was most likely intended. In the old version, if getline() reported an error, it would print an error message inside a while loop, immediately followed by a break and then march on and process the erroneous input instead of using the default value as printed to stdout. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
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-09-08ubi-tests: io_paral: Fix error handling of update_volume()Martin Lund
The io_paral test returns success even in case it throws e.g. the following error message: [io_paral] update_volume():125: written and read data are different This patch fixes so that the io_paral application returns a non-zero error code when an error is detected. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-07-27ubi-utils: ubimkvol: Initialize req to zero to make sure no flags are set by ↵Boris Brezillon
default The program expects req.flags to be zero-initialized, but it's not the case. Let's explicitly initialize req to zero at declaration time. Fixes: 7b4a65a27d26 ("ubi-utils: ubimkvol: add support for skipping CRC check of a static volume when opening") Reviewed-by: Quentin Schulz <quentin.schulz@bootlin.com> Signed-off-by: Boris Brezillon <boris.brezillon@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2018-06-28ubi-utils: ubinize: add support for skipping CRC check of a static volume ↵Quentin Schulz
when opening Let's let the user configure static UBI volume with CRC checking at opening disabled if desired. Introduce the skip-check setting for vol_flags configuration of a volume. There is no point in having both autoresize and skip-check set as skip-check is reserved for static volumes only and it's useless to have a static volume's size set to autoresize. 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-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>