aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
11 daysubifs-utils: Decouple mkfs.ubifs.h out of other modulesZhihao Cheng
Header file mkfs.ubifs.h is included in other modules(eg. compr.c, lpt.c, fscrypt.h, sign.c), decouple it out of other modules. There are two parts in mkfs.ubifs.h: 1. common functions, for example dbg_msg, err_msg and write_leb, move these functions into common/defs.h and common/ubifs.h. 2. devtable related definations, move them into a new header file common/devtable.h. Splitting common functions from mkfs.ubifs.h is also a preparation for importing libubifs(from linux kernel) to replace current UBIFS libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
11 daysubifs-utils: Split common source files from mkfs.ubifsZhihao Cheng
Split common source files into common dir from mkfs.ubifs, this is a preparation for importing libubifs(from linux kernel) to replace current UBIFS libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mkfs.jffs2: fix segfault when parsing dev tableRosen Penev
Make sure that the first item is parsed correctly. One issue otherwise is a null pointer dereference when the first item is not found. Signed-off-by: Rosen Penev <rosenp@gmail.com> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Benchmark continuous readsMiquel Raynal
Currently the read throuput test tries: - 1 page - 2 pages - 1 block (64 or more pages, usually) But it might be interesting to see how the speed gradually increases, eg. testing all number of pages from 1 to maybe 16, and then arbitrarilly 32 and 64. Let's add a -C parameter to enable this additional test. The 2-page read/write tests are also moved under this new option. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Drop read_eraseblock_by_page()Miquel Raynal
The read_eraseblock_by_2pages() has been generalized so it became read_eraseblock_by_npages(), but there is no limitation (besides 0) regarding the number of pages. Hence, drop the _by_page() helper and replace it with the _by_npages(), using 'npages = 1'. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Generalize read_eraseblock_by_2pages()Miquel Raynal
Right now there are only 2 pages that may be read continuously, but why not trying more? At least when the continuous feature is out, this type of benchmarking will be interesting. In order to facilitate later additions, lets make this helper more generic and accept a global 'npages' variable as parameter (because this function is called in a macro, it is simpler like that). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Clarify the number of pages in each set while measuringMiquel Raynal
So far speed calculations have only be done 1 page at a time or 2 pages at a time in a block; so basically all the block was always read because all blocks are multiple of 2. But in the future, if we want to extend the number of pages in a single read, the final number of pages actually read might be less than an erase block size, hence failing the throuput calculations. Make the number of pages in a set explicit. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: flash_speed: Drop an apparently useless blockMiquel Raynal
I know no device without a multiple of 2 number of pages in each block. Even though it might be the case, it is clearly not a big deal and we don't really care about reading the last page, we are doing a speed benchmark; so as long as the throughput calculation knows how much data has been read it's fine. Eitherway, I don't think we ever have fallen in this block because we would read the content of two pages (so one past the block) and put it in a page-wide buffer, which would probably lead to an out-of-bound abort. Just drop the block. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: nandbiterrs: Add support for testing continuous readsMiquel Raynal
In order to trigger a continuous read, the user needs to request at least two pages at the same time. So far the tool would only read single pages, so let's extend its capabilities to test continuous read output when the -c option is passed. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08mtd-tests: nandbiterrs: Store the chunks size in an intermediate variableMiquel Raynal
'pagesize' is used for two purposes: - accessing the size of a page - getting the size of the test buffer, which happen to be the size of a page for now. Use an intermediate variable when getting the size of the test buffer, as we will later increase its size. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08nand-utils: nanddump: Add support for testing continuous readsMiquel Raynal
In order to trigger a continuous read, the user needs to request more than one data page. So far the tool would split the length into page chunks. This is no longer the case when the -C option is passed (-c is already used for the canonical output style). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08nand-utils: nanddump: Explicitely use the page size when relevantMiquel Raynal
Using bs when skipping the bad sector is abusive as what we want is using the size of a block and the size of a page. The fact that bs currently is the size of a page is misleading here, has I intend to make this amount grow. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-10-08nand-utils: nanddump: Use a specific variable for the buffer sizeMiquel Raynal
The read buffer size happen to be as big as the bs variable, but this is going to change. When accessing the buffer size, use a specific variable instead. Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25Release mtd-utils-2.2.1v2.2.1David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25Update CHANGELOGDavid Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mtd-utils: Extract rbtree implementation to common libZhihao Cheng
Current rbtree implementation code is put under jffs utils, extract it into common lib, and add more rbtree operations(eg. rb_first_postorder, rb_next_postorder, etc.). This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mtd-utils: Extract list implementation to common lib and add list_sort supportZhihao Cheng
Current list implementation code is put under jffs utils, extract it into common lib, and add more list operations(eg. list_move, list_splice, etc.). Besides, add list sorting support in new source file lib/list_sort.c. This is a preparation for replacing implementation of UBIFS utils with linux kernel libs. Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mkfs.ubifs: Fix memleak for 'output' in error pathsZhihao Cheng
The 'output' is allocated in get_options(), don't forget to free it in error paths, move 'output' freeing out of close_target(), which simplifies the logic of close_target(). Fixes: 36ec51948e0ec ("Add mkfs.ubifs") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mkfs.ubifs: Fix missed closing out_fdZhihao Cheng
Closing 'out_fd' is missed in handling paths in open_target(), fix it by adding closing operations before returning. Fixes: a48340c335dab ("mkfs.ubifs: use libubi to format UBI volume") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mkfs.ubifs: Close libubi in error handling pathsZhihao Cheng
The libubi could be opened in get_options(), don't forget to close it in error handling paths in main(). Also close libubi in error handling paths in open_ubi(). To implement that, extract libubi_close() into a new helper function close_ubi(). Besides, invoke crypto_cleanup() in error handling paths in main(). Fixes: a48340c335dab ("mkfs.ubifs: use libubi to format UBI volume") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mkfs.ubifs: Fix incorrect dir size calculation in encryption scenarioZhihao Cheng
The size of directory should be the total length of encrypted entry name, otherwise it could trigger errors while checking filesystem: dbg_check_filesystem [ubifs]: directory inode 89 size is 352, but calculated size is 400 Fixes: 4c55918dd747d ("Implement filename encryption") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mkfs.ubifs: Fix wrong xattr entry typeZhihao Cheng
The type of xattr entry should be regular file, otherwise xattr entry and xattr inode have inconsistent types. Fixes: 50044efbd6e713 ("mkfs.ubifs: Add extended attribute support") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mkfs.ubifs: Initialize 'cipher_name' as NULLZhihao Cheng
Variable 'cipher_name' is defined on stack without initialization, when an user invokes mkfs with '--key' and without '-C', 'cipher_name' is a random value, which could cause init_fscrypt_context() failed to find a valid cipher. Fix it by initializing 'cipher_name' as NULL when it is declared. Fixes: cc4c5e295f546 ("mkfs.ubifs: Enable support for building without crypto") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mkfs.ubifs: Clear direct_write property when closing targetZhihao Cheng
Direct writing is not allowd on an UBI volume, unless the volume is set with direct_write property. The open_target sets direct_write property, don't forget to clear direct_write property for UBI volume when closing target. Fixes: a48340c335dab ("mkfs.ubifs: use libubi to format UBI volume") Signed-off-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25mtd-utils: also check for static libuuidRosen Penev
PKG_CHECK_MODULES confusingly does not check to see if a static version of the library is available. Actually with older glibc, it might fail as lpthread needs to be passed to linker flags (Libs.private in pc files) which can only be obtained if --static is passed to pkg-config. Signed-off-by: Rosen Penev <rosenp@gmail.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25fs-tests: integck: Refactor: split out common remount logicCsókás, Bence
remount_tested_fs() and recover_tested_fs() both have almost the same code for remounting the target FS RO then RW. Split this sequence into a new function called remount_ro_rw(). Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Link: https://lore.kernel.org/linux-mtd/5530437c-b564-461f-26af-85bde1a00cb3@huawei.com/T/#mad1d043095b3f64a1f1eddd2d87b1545e329e141 Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25fs-tests: integck: Refactor: split out common remount logicCsókás, Bence
remount_tested_fs() and recover_tested_fs() both have almost the same code for umount'ing the target FS and mount'ing it back. Split this sequence into a new function called umount_and_remount(). Signed-off-by: Csókás, Bence <csokas.bence@prolan.hu> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-09-25libubi: ubi_update_start: slightly improve documentationChristian Eggers
Calling ubi_update_start() may fail if exclusive access to the UBI volume cannot be established by the kernel. This is likely to happen if an UBI volume is updated directly after creation, because current versions of (systemd-)udevd run their internal 'blkid' also for UBI volumes as soon as they appear (trying to read the UBIFS UUID). There are mainly to options for this case: 1. Don't allow udevd to read UBI volumes at all (means loosing functionatlity) 2. Wait until udevd has finished accessing a new volume (requires cooperation with udevd) 3. Simply retry after short time in case of EBUSY For using option 3, the documentation should state that the concrete error code can be read via errno (this has always been the case since libubi has been introduced). Link: https://groups.google.com/g/swupdate/c/8NVooKjD9oo Signed-off-by: Christian Eggers <ceggers@arri.de> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-04-13mtd-utils: fectest: Fix time formatting with _TIME_BITS=64 on 32-bit systemBen Hutchings
fectest.c formats a struct timeval with the assumption that time_t and suseconds_t are aliases for long, but some 32-bit systems now define them as long long in order to support timestamps beyond 2038. As this is an elapsed time and not a timestamp, both fields should be within the range of long, so cast them to long before formatting rather than moving to long long. Signed-off-by: Ben Hutchings <ben.hutchings@mind.be> Reviewed-by: Zhihao Cheng <chengzhihao1@huawei.com> Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
2024-03-29Release mtd-utils-2.2.0v2.2.0David Oberhollenzer
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
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>