summaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2024-03-29Update CHANGELOG.mdDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-02-19Update README.txtDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-02-19Add a build summary to configure.acDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-02-19Unify handling of configure switchesDavid Oberhollenzer
Remove the strict check of the with or enable value and use the generated variable instead of our own. Also, don't use WITH_GETRANDOM as an implicit WITH_UBIHEALTHD, split the two autoconf/automake variables and handle them separately. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-02-18Cleanup: Unify handling of OpenSSL dependencyDavid Oberhollenzer
This commit modifes the handling of the OpenSSL dependency to work the same as the other optional dependencies, except that the variable "with_crypto" is used instead of "with_openssl". Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-02-18Make zlib an optional dependencyDavid Oberhollenzer
Now that we have plumbing in place for both jffsX-utils and mkfs.ubifs, add the missing autoconf and automake changes to allow mtd-utils to be built without a hard dependency on zlib. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-02-18Make it possible to compile mkfs.ubifs without zlibDavid Oberhollenzer
This one is a bit trickier than adding WITH_ZLIB ifdefs. Some parts of the code assume that zlib is always present and have complicated fallback behavior. Particularly the "favor_lzo" compression method that uses either zlib or lzo, whichever produces the better result. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-02-18Make it possible to compile jffsX-utils without zlibDavid Oberhollenzer
The jffsX-utils already have a CONFIG_JFFS2_ZLIB define, but it is statically defined in a header and not used consistently. This patch first replaces it with a "WITH_ZLIB" define, provided via automake, to bring it in line with the already existing "WITH_LZO". Then, the missing checks and typedefs are added in jffs2reader.c. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-02-17Fix optional compilation of lzo compressorsDavid Oberhollenzer
- Simple fixup in autoconf.ac - Make compilation of jffsX-utils compr_lzo.c optional. Simply don't compile it if we built without LZO and remove the place holders. They are not used anyway if we build without LZO. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-02-15Cleanup handling of optional dependenciesDavid Oberhollenzer
Don't use super pedantic parsing of the argument and work with the generated variable instead of assigning it to our own and set it to "check" if not value is assigned. Then search for a dependency if the with variable is anything other than "no" and fail if it was set to "yes". In addition, the WITHOUT_xxx defines are replaced with WITH_xxx defines. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-02-14Add missing autoconf check for ARDavid Oberhollenzer
After removing libtool, there is no more cross-check for AR. Because some slightly older versions of autoconf don't have AC_PROG_AR, simply insert the implementation one-liner. We already tried bumping the minimum autoconf version once in the past, but apparently that is an issue for a number of distros. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-12-19mkfs.ubifs: fix xattr scanning for builds with selinux supportDavid Oberhollenzer
mkfs.uibfs can add Selinux xattrs from a labeling file using libselinux to parse it. The commit that added this feature simply introduced a separate function, inode_add_selinux_xattr, which is called instead of inode_add_xattr. If no --selinux argument is specified for mkfs.ubifs, this is a no-op. The problem is, that this breaks xattr scanning for any build with Selinux enabled. The Selinux version is always called and it does not scan for xattrs on the filesystem, or dispatch to the original. This commit fixes the xattr scanning behavior. We unconditionally call both functions (they each have no-op implementations if the feature is missing) and in the regular xattr scanning code, we skip selinux attributes, if the --selinux option was given. Fixes: f1feccec5ad8 ("mkfs.ubifs: Implement selinux labelling support") Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <goliath@infraroot.at>
2023-11-20ubiattach: introduce need_resv_pool in UBI_IOCATTZhihao Cheng
The ioctl UBI_IOCATT has been extended with need_resv_pool parameter in [1]. This parameter is used for deciding whether to reserve PEBs for filling pool/wl_pool for target ubi device. This parameter will be effective when fastmap is enabled, which will slow down the frequency of updating fastmap by filling more free PEBs in pool/wl_pool. See details in [2]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ac085cfe57df2cc1d7a5c4c5e64b8780c8ad452f [2] https://bugzilla.kernel.org/show_bug.cgi?id=217787 Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-11-20ubiattach: introduce disable_fm in UBI_IOCATTZhihao Cheng
The ioctl UBI_IOCATT has been extended with disable_fm parameter after [1]. This parameter is used for disabling fastmap for target ubi device. If 'disable_fm' is set, ubi doesn't create new fastmap even the module param 'fm_autoconvert' is set, and existed old fastmap will be destroyed after attaching process. A simple test case in [2]. [1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=669d204469c46e91d99da24914130f78277a71d3 [2] https://bugzilla.kernel.org/show_bug.cgi?id=216278 Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-11-13mtd-utils: flash_erase: Add an option for JFFS2 cleanmarker sizeTakahiro Kuwano
JFFS2 supports buffer mode for ECC'd NOR Flash that cleanmarker size is rounded up to mtd->writesize, while the '-j' option in flash_erase utility uses fixed 12 bytes. That makes flash program ops unaligned to mtd->writesize and causes program error or disables ECC. The mkfs.jffs2 utility supports '-c' option that allows users to specify cleanmarker size. This patch implements '-c' option in the flash_erase that can be used along with '-j' option. Signed-off-by: Takahiro Kuwano <Takahiro.Kuwano@infineon.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-09-08flashcp: Add write last option.Piotr Esden-Tempski
This option is useful for power fail resilient bootloader updates, for systems that check only the partition header for validity before attempting to load the bootloader. For example zynq. Postponing the write of a specified amount of bytes at the beginning of a bootloader makes sure a written bootloader slot is not considered valid until all the data is written. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-09-04Cleanup: remove self assignDavid Oberhollenzer
This no-op was remarked by coverity. According to git-blame, it has been this way since the initial commit in 2006. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-09-03Add a README fileDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-09-03Pull the bulk of the pre 2.0.0 changes from the git treeDavid Oberhollenzer
For the most part, this was straight forward. For the very old releases, there were lots of changes that are not straight forward to untangle. The following two releases posed issues: - Version 1.4.1 does not have a tag. The release tarball on FTP is from 2010-10-19 and appears to contain 1.4.0 with commit b864c387e8f16273aad1453d6457d847e29c3d25 cherry-picked on top of it (except for one line that was fixed in the release, but broken in the repo). - Version 1.4.6 also does not have a tag. The release tarball is from 2011-08-19. This _presumably_ corresponds with commit b602ab59b9782003d1179488d8c1580bc8563738 that bumps the version number. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-09-02Piece together a CHANGELOG file from the release announcmentsDavid Oberhollenzer
The CHANGELOG tries to summarize the change history of the project and currently contains changes from 2.0.0 onwards that could easily be extracted from the release mails. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-09-02jffs2dump: check return value of lseekDavid Oberhollenzer
On error, lseek returns a negative value. We need to check for that and abort, instead of passing -1 to malloc and later on to read_nocheck. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-08-30Release mtd-utils-2.1.6v2.1.6David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-08-24Fix printf format specifiers for 64 bit integer typesDavid Oberhollenzer
In nandflipbits, nandtest and ubiscan, uint64_t integers are printed to stdout using "%llu" as a format specifier, but on platforms like x86_64, uint64_t is actually typedef'd as `unsigned long` only. For compatibillity across platforms, simply use the C99 printfs macros instead. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-08-24Make sure ubi-media structures are visible for libubigenDavid Oberhollenzer
The libubigen.h header relies on external declarations in ubi-media.h. While not technically needed, it generates warnings in mtdinfo.c if those are not visible. All other places where libubigen is used include the header first. This is primarily to silence compiler warnings related to the missing declrations. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-08-24Remove unused symbolsDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-08-24Update ax_pthreadDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-08-24Remove libtool usage from configure.acDavid Oberhollenzer
We do not build any shared libraries, there is no reason to use libtool or disable static. We do build static libraries, for which we need ranlib. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-08-23mtd-utils: nandtest: handle large nand devicesChristian Wendt he/him
Running nandtest on devices with sizes of 4Gb or more does not work, as the size returned in mtd_info_user is reported as 0 for 4Gb devices for example. The patch uses sysfs to figure out the size of the nand device (as recommended in a comment in include/mtd/mtd-abi.h) and changes sizes and offsets to 64 bit values. [From: Christian Wendt <cw@brainaid.de>] Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-05-30mtd-utils: Add new syntax to get devices by nameBrandon Maier
This introduces a new feature to the MTD command line utilities that allows MTD devices to be referenced by name instead of device node. For example this looks like: > # Display info for the MTD device with name "data" > mtdinfo mtd:data > # Copy file to MTD device with name "data" > flashcp /my/file mtd:data This follows the syntax supported by the kernel which allows MTD device's to be mounted by name[1]. Add the function mtd_find_dev_node() that accepts an MTD "identifier" and returns the MTD's device node. The function accepts a string starting with "mtd:" which it treats as the MTD's name. It then attempts to search for the MTD, and if found maps it back to the /dev/mtdX device node. If the string does not start with "mtd:", then assume it's the old style and refers directly to a MTD device node. The function is then hooked into existing tools like flashcp, mtdinfo, flash_unlock, etc. To load in the new MTD parsing code in a consistent way across programs. [1] http://www.linux-mtd.infradead.org/faq/jffs2.html#L_mtdblock Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-05-30libmtd: Add function to get MTD info by device nameBrandon Maier
This is a convenience function for end users. In some situations it's easier to reference MTD device's by their name then by MTD number, as the name may be more reliable if device partitioning is dynamic or for porting between systems. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-05-30mkfs.ubifs: Fix mkfs.ubifs failure with option selinuxZijun Hu
Below failure happens when mkfs.ubifs --selinux=FILE ... "Error: bad file context FILE 1" "No such file or directory (error 2)" It is fixed by this change. Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2023-04-24misc-utils: flashcp: correct casting for percent displaycchoux
Add correct casting for written to prevent overflow that size_t is only 32 bits on a 32-bit platform. Signed-off-by: cchoux <chou.cosmo@gmail.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-18mtd-utils: flash_speed: Measure read while write latencyMiquel Raynal
The Read While Write (RWW) feature allows to perform reads from the flash array into cache while a program (from cache) or an erase operation happens, provided that the two areas are located on different banks. The main benefit is the possible reduced latency when requesting to read a page while a much longer operation is ongoing, like a write or an erase. We can try to compare the positive impact of such a feature by enhancing the flash_speed test tool with the following test: - Measure the time taken by an eraseblock write in parallel with an eraseblock read. - Measure when the read operation ends. - Compare the two to get the latency saved with the RWW feature. To be sure the mtd_write actually starts (and acquires the necessary locks) before the mtd_read does, we use SCHED_FIFO at rather high (arbitrary) priorities, respectively 42 and 41. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-18mtd-utils: flash_speed: Rework the time counting helpersMiquel Raynal
In order to be able to have interleaved measures, let's not use the start and finish global variables from the time helpers directly, provide parameters for these variables so that we can provide either the global entries, or more specific ones when relevant. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: mtdpart: document partition of size 0Brandon Maier
If the partition size passed in to the BLKPG_ADD_PARTITION ioctl is 0, Linux will make the partition fill to the end of the device[1]. Document this feature in the help. [1] https://elixir.bootlin.com/linux/v6.0.6/source/drivers/mtd/mtdpart.c#L254 Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: abort on --partition and --erase-allBrandon Maier
Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: verify data in --partitionBrandon Maier
The --partition mode is not verifying that data is being written successfully. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: fix buffer overflowBrandon Maier
The DIFF_BLOCKS code requires that src and dest buffers be large enough to hold one MTD erasesize. This is because each loop operates on one eraseblock so that it can erase and write one whole sector. But the src and dest buffers are fixed at BUFSIZE, so on platforms where the MTD erasesize are larger then BUFSIZE it will overflow the buffers. Instead allocate the buffers dynamically so that they can be sized to fit the erasesize. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: simplify loggingBrandon Maier
Most of the uses of log_printf fall into two styles > if (flags & FLAG_VERBOSE) > log_printf(LOG_NORMAL, ...); or > log_printf(LOG_ERROR, ...) > exit(EXIT_FAILURE); Replace them with log_verbose and log_failure respectively. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: add safe_memeraseBrandon Maier
Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: check for lseek errorsBrandon Maier
Add a safe_lseek wrapper to check for lseek errors. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-11-07misc-utils: flashcp: add safe_writeBrandon Maier
Share the writing code between the two write implementations. Signed-off-by: Brandon Maier <brandon.maier@collins.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-10-07Release mtd-utils-2.1.5v2.1.5David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-10-07Fix warning about unaligned pointer in jffs2readerFrederic Germain
gcc 9.3.0-17ubuntu1~20.04 warning on time_t ctime value is : Fix taking address of packed member of ‘struct jffs2_raw_inode’ may result in an unaligned pointer value [-Waddress-of-packed-member]. Signed-off-by: Frederic Germain <frederic.germain@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-10-07.gitignore: add new ubiscan utilityFrederic Germain
Signed-off-by: Frederic Germain <frederic.germain@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-10-04nor-utils: fix memory leakliaohua
This patch replace "free(rfd.sector_map)" with "free(rfd.header)" to fix memory leak. Signed-off-by: liaohua <liaohua4@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-09-27libmtd: do not ignore non-zero eraseblock size when MTD_NO_ERASE is setEnrico Jorns
In 54d68799, mtd->eb_cnt was enforced to be '1' if MTD_NO_ERASE is set. This was done with the aim of preventing divisions by zero. However, even if MTD_NO_ERASE is set, mtd->eb_size (eraseblock size) can still be set to a non-zero value which would not cause a division by zero. Instead, enforcing an eraseblock count of '1' here even leads to inconsistent eraseblock counting in mtd-utils and lets for example a 'flash_erase' on an mtdnand device fail: | # flash_erase /dev/mtd0 0 0 | Erasing 32768 Kibyte @ 0 -- 0 % complete libmtd: error!: bad eraseblock number 255, mtd0 has 1 eraseblocks | flash_erase: error!: /dev/mtd0: MTD Erase entire chip failureTrying one by one each sector. | error 22 (Invalid argument) | Erasing 128 Kibyte @ 0 -- 0 % complete libmtd: error!: bad eraseblock number 1, mtd0 has 1 eraseblocks | flash_erase: error!: /dev/mtd0: MTD get bad block failed | error 22 (Invalid argument) Also mtdinfo would look inconsistent (eraseblock size vs amount): | # mtdinfo /dev/mtd0 | mtd0 | Name: mtdram test device | Type: ram | Eraseblock size: 131072 bytes, 128.0 KiB | Amount of eraseblocks: 1 (33554432 bytes, 32.0 MiB) | Minimum input/output unit size: 1 byte | Sub-page size: 1 byte | Character device major/minor: 90:0 | Bad blocks are allowed: false | Device is writable: true Fix this by enforcing mtd->eb_cnt to be '1' only when mtd->eb_size is actually zero and would lead to a division by zero otherwise. Fixes: 54d68799 ("libmtd: avoid divide by zero") Signed-off-by: Enrico Jorns <ejo@pengutronix.de> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-09-27mtd-utils: flash_otp_dump make offset optionalMichael Walle
Commit 0a5e2fa5c1e4 ("mtd-utils: add optional offset parameter to flash_otp_dump") introduced an offset parameter. This should have been optional, but there was a typo. Fix it. Reported-by: Sergei Antonov <saproj@gmail.com> Fixes: 0a5e2fa5c1e4 ("mtd-utils: add optional offset parameter to flash_otp_dump") Signed-off-by: Michael Walle <michael@walle.cc> Reviewed-by: Sergei Antonov <saproj@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-09-27mkfs.jffs2: fix spelling of --compression-mode parameter in help textAlex Henrie
--compr-mode is not accepted as an alias of --compression-mode. Signed-off-by: Alex Henrie <alexhenrie24@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2022-08-08tests: Remove unused linux/fs.h header from includesKhem Raj
This header is not needed, moreover it includes linux/mount.h which is now in conflict[1] with glibc provided sys/mount.h from glibc 2.36 onwards [1] https://sourceware.org/glibc/wiki/Release/2.36 Signed-off-by: Khem Raj <raj.khem@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>