From 3edd2894111835a037a91e794d938a93435a6641 Mon Sep 17 00:00:00 2001 From: Shiji Yang Date: Thu, 16 Apr 2026 01:05:13 +0800 Subject: [PATCH] mtd-utils: update to v2.3.1 Fixes: - ubifs-utils: link libmissing.a in case execinfo.h isn't present - ubifs-utils: common: fix memory leak in devtable.c - Broken check for GCC compiler versions - ubifs-utils: missing header file includes - ubifs-utils: tests: missing files in release tarball - mtd-tests: flash_speed: really skip destructive tests - mtd-tests: flash_speed: wrong error message in read_eraseblock() - serve_image: fix _POSIX_C_SOURCE define - ubiattach: fix wording in usage example - fsck.ubifs: don't use pointers that reference out-of-scope variables - fsck.ubifs: fix platform dependant `ino_t` and `loff_t` formatting - docfdisk.c: fix potential arithmetic overflows in partition size - jittertest: reject overlong file names Changes: - ubirsvol: resize using all available free space if size is specified as 0 Upstreamed patches: - 001-ubifs-utils-link-libmissing.a-in-case-execinfo.h-isn.patch[1] - 002-ubifs-utils-common-fix-memory-leak-in-devtable.c.patch[2] - 004-Improve-check-for-GCC-compiler-version.patch[3] - 005-ubifs-utils-ubifs.h-Include-fcntl.h.patch[4] - 006-ubifs-utils-journal-Include-sys-stat.h.patch[5] - 007-ubifs-utils-extract_files-Include-linux-limits.h.patch[6] [1] https://git.infraroot.at/mtd-utils.git/commit/?h=v2.3.1&id=8a83b306db64d6f60186d4396b0b770163b85b6e [2] https://git.infraroot.at/mtd-utils.git/commit/?h=v2.3.1&id=2669111e3c60b8e146c174db5d2e7e9991f3dd87 [3] https://git.infraroot.at/mtd-utils.git/commit/?h=v2.3.1&id=ac0ab65ebcd7b11739986b81343457469fbb43b0 [4] https://git.infraroot.at/mtd-utils.git/commit/?h=v2.3.1&id=12bc9ad824bd8f18a5ec9c7154ad2374cf8c7ae3 [5] https://git.infraroot.at/mtd-utils.git/commit/?h=v2.3.1&id=173f9714c8da1d685bfa951d43b9310d16bbab3c [6] https://git.infraroot.at/mtd-utils.git/commit/?h=v2.3.1&id=77981a2888c711268b0e7f32af6af159c2288e23 Signed-off-by: Shiji Yang Link: https://github.com/openwrt/openwrt/pull/22946 Signed-off-by: Hauke Mehrtens --- package/utils/mtd-utils/Makefile | 4 +- ...-libmissing.a-in-case-execinfo.h-isn.patch | 57 ------------------- ...common-fix-memory-leak-in-devtable.c.patch | 32 ----------- ...prove-check-for-GCC-compiler-version.patch | 32 ----------- ...-ubifs-utils-ubifs.h-Include-fcntl.h.patch | 45 --------------- ...ifs-utils-journal-Include-sys-stat.h.patch | 33 ----------- ...extract_files-Include-linux-limits.h.patch | 33 ----------- .../100-Remove-ubifs-test-builds.patch | 2 +- 8 files changed, 3 insertions(+), 235 deletions(-) delete mode 100644 package/utils/mtd-utils/patches/001-ubifs-utils-link-libmissing.a-in-case-execinfo.h-isn.patch delete mode 100644 package/utils/mtd-utils/patches/002-ubifs-utils-common-fix-memory-leak-in-devtable.c.patch delete mode 100644 package/utils/mtd-utils/patches/004-Improve-check-for-GCC-compiler-version.patch delete mode 100644 package/utils/mtd-utils/patches/005-ubifs-utils-ubifs.h-Include-fcntl.h.patch delete mode 100644 package/utils/mtd-utils/patches/006-ubifs-utils-journal-Include-sys-stat.h.patch delete mode 100644 package/utils/mtd-utils/patches/007-ubifs-utils-extract_files-Include-linux-limits.h.patch diff --git a/package/utils/mtd-utils/Makefile b/package/utils/mtd-utils/Makefile index 482785f2ad6..131ab822584 100644 --- a/package/utils/mtd-utils/Makefile +++ b/package/utils/mtd-utils/Makefile @@ -8,12 +8,12 @@ include $(TOPDIR)/rules.mk PKG_NAME:=mtd-utils -PKG_VERSION:=2.3.0 +PKG_VERSION:=2.3.1 PKG_RELEASE:=1 PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2 PKG_SOURCE_URL:=https://infraroot.at/pub/mtd/ -PKG_HASH:=2db102908b232406ccb20719c0f43b61196aef4534493419fbf98a273c598c10 +PKG_HASH:=03d9dc58ad10ea3549d9528f6b17a44d8944e18e96c0f31474f9f977078b83dc PKG_INSTALL:=1 diff --git a/package/utils/mtd-utils/patches/001-ubifs-utils-link-libmissing.a-in-case-execinfo.h-isn.patch b/package/utils/mtd-utils/patches/001-ubifs-utils-link-libmissing.a-in-case-execinfo.h-isn.patch deleted file mode 100644 index e43e34f533f..00000000000 --- a/package/utils/mtd-utils/patches/001-ubifs-utils-link-libmissing.a-in-case-execinfo.h-isn.patch +++ /dev/null @@ -1,57 +0,0 @@ -From 8a83b306db64d6f60186d4396b0b770163b85b6e Mon Sep 17 00:00:00 2001 -From: Ross Burton -Date: Wed, 26 Feb 2025 18:24:00 +0000 -Subject: ubifs-utils: link libmissing.a in case execinfo.h isn't present - -On musl execinfo.h doesn't exist, but ubifs-utils uses backtrace() when -reporting errors. This results in build failures under musl. - -Handily, libmissing.a already exists with a stub implementation of -backtrace(). - -Guard the execinfo.h include and if it isn't available instead include -libmissing.h, and link to libmissing.a to provide backtrace() if needed. - -Signed-off-by: Ross Burton -Reviewed-by: Zhihao Cheng -Signed-off-by: David Oberhollenzer ---- - ubifs-utils/Makemodule.am | 4 ++-- - ubifs-utils/common/defs.h | 5 ++++- - 2 files changed, 6 insertions(+), 3 deletions(-) - ---- a/ubifs-utils/Makemodule.am -+++ b/ubifs-utils/Makemodule.am -@@ -72,7 +72,7 @@ mkfs_ubifs_SOURCES = \ - ubifs-utils/mkfs.ubifs/mkfs.ubifs.c - - mkfs_ubifs_LDADD = libmtd.a libubi.a $(ZLIB_LIBS) $(LZO_LIBS) $(ZSTD_LIBS) $(UUID_LIBS) $(LIBSELINUX_LIBS) $(OPENSSL_LIBS) \ -- $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread -+ $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread libmissing.a - mkfs_ubifs_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) $(ZSTD_CFLAGS) $(UUID_CFLAGS) $(LIBSELINUX_CFLAGS) \ - -I$(top_srcdir)/ubi-utils/include -I$(top_srcdir)/ubifs-utils/common -I $(top_srcdir)/ubifs-utils/libubifs - -@@ -90,7 +90,7 @@ fsck_ubifs_SOURCES = \ - ubifs-utils/fsck.ubifs/handle_disconnected.c - - fsck_ubifs_LDADD = libmtd.a libubi.a $(ZLIB_LIBS) $(LZO_LIBS) $(ZSTD_LIBS) $(UUID_LIBS) $(LIBSELINUX_LIBS) $(OPENSSL_LIBS) \ -- $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread -+ $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread libmissing.a - fsck_ubifs_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) $(ZSTD_CFLAGS) $(UUID_CFLAGS) $(LIBSELINUX_CFLAGS) \ - -I$(top_srcdir)/ubi-utils/include -I$(top_srcdir)/ubifs-utils/common -I $(top_srcdir)/ubifs-utils/libubifs \ - -I$(top_srcdir)/ubifs-utils/fsck.ubifs ---- a/ubifs-utils/common/defs.h -+++ b/ubifs-utils/common/defs.h -@@ -13,8 +13,11 @@ - #include - #include - #include -+#if HAVE_EXECINFO_H - #include -- -+#else -+#include "libmissing.h" -+#endif - #include "ubifs.h" - - /* common.h requires the PROGRAM_NAME macro */ diff --git a/package/utils/mtd-utils/patches/002-ubifs-utils-common-fix-memory-leak-in-devtable.c.patch b/package/utils/mtd-utils/patches/002-ubifs-utils-common-fix-memory-leak-in-devtable.c.patch deleted file mode 100644 index 4daaf453064..00000000000 --- a/package/utils/mtd-utils/patches/002-ubifs-utils-common-fix-memory-leak-in-devtable.c.patch +++ /dev/null @@ -1,32 +0,0 @@ -From 2669111e3c60b8e146c174db5d2e7e9991f3dd87 Mon Sep 17 00:00:00 2001 -From: AntonMoryakov -Date: Thu, 24 Apr 2025 21:19:22 +0300 -Subject: ubifs-utils: common: fix memory leak in devtable.c - -Report of the static analyzer: -Dynamic memory, referenced by 'line', is allocated at devtable.c:356 -by calling function 'getline' and lost at devtable.c:388. -(line: while (getline(&line, &len, f) != -1) {) - -Correct explained: -Now line is freed in any exit scenario via out_close which eliminates this error. - -Triggers found by static analyzer Svace. - -Signed-off-by: Anton Moryakov -Signed-off-by: David Oberhollenzer ---- - ubifs-utils/common/devtable.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/ubifs-utils/common/devtable.c -+++ b/ubifs-utils/common/devtable.c -@@ -392,6 +392,7 @@ int parse_devtable(const char *tbl_file) - - out_close: - fclose(f); -+ free(line); - free_devtable_info(); - return -1; - } diff --git a/package/utils/mtd-utils/patches/004-Improve-check-for-GCC-compiler-version.patch b/package/utils/mtd-utils/patches/004-Improve-check-for-GCC-compiler-version.patch deleted file mode 100644 index 5b1870b1c19..00000000000 --- a/package/utils/mtd-utils/patches/004-Improve-check-for-GCC-compiler-version.patch +++ /dev/null @@ -1,32 +0,0 @@ -From ac0ab65ebcd7b11739986b81343457469fbb43b0 Mon Sep 17 00:00:00 2001 -From: Khem Raj -Date: Sat, 22 Mar 2025 21:01:32 -0700 -Subject: Improve check for GCC compiler version - -When using unreleased compiler has version like -15.0.1 and that test fails because __GNUC_MINOR__ < 1 -becomes true, therefore check for full version string -which is more rubust. - -Signed-off-by: Khem Raj -Signed-off-by: David Oberhollenzer ---- - ubifs-utils/common/atomic.h | 6 +++++- - 1 file changed, 5 insertions(+), 1 deletion(-) - ---- a/ubifs-utils/common/atomic.h -+++ b/ubifs-utils/common/atomic.h -@@ -2,8 +2,12 @@ - #ifndef __ATOMIC_H__ - #define __ATOMIC_H__ - -+#define GCC_VERSION (__GNUC__ * 10000 \ -+ + __GNUC_MINOR__ * 100 \ -+ + __GNUC_PATCHLEVEL__) -+ - /* Check GCC version, just to be safe */ --#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC_MINOR__ < 1) -+#if GCC_VERSION < 40100 - # error atomic.h works only with GCC newer than version 4.1 - #endif /* GNUC >= 4.1 */ - diff --git a/package/utils/mtd-utils/patches/005-ubifs-utils-ubifs.h-Include-fcntl.h.patch b/package/utils/mtd-utils/patches/005-ubifs-utils-ubifs.h-Include-fcntl.h.patch deleted file mode 100644 index 0bba423d7d5..00000000000 --- a/package/utils/mtd-utils/patches/005-ubifs-utils-ubifs.h-Include-fcntl.h.patch +++ /dev/null @@ -1,45 +0,0 @@ -From 12bc9ad824bd8f18a5ec9c7154ad2374cf8c7ae3 Mon Sep 17 00:00:00 2001 -From: Fabio Estevam -Date: Wed, 19 Feb 2025 10:02:41 -0300 -Subject: ubifs-utils: ubifs.h: Include - -Include the header file to fix the following error -when building with musl: - -| In file included from ../git/ubifs-utils/common/compr.c:42: -| ../git/ubifs-utils/libubifs/ubifs.h:313:9: error: unknown type name 'loff_t'; did you mean 'off_t'? -| 313 | loff_t ui_size; -| | ^~~~~~ -| | off_t -| ../git/ubifs-utils/libubifs/ubifs.h:1341:9: error: unknown type name 'loff_t'; did you mean 'off_t'? -| 1341 | loff_t i_size; -| | ^~~~~~ -| | off_t -| ../git/ubifs-utils/libubifs/ubifs.h:1342:9: error: unknown type name 'loff_t'; did you mean 'off_t'? -| 1342 | loff_t d_size; -| | ^~~~~~ -| | off_t -| ../git/ubifs-utils/libubifs/ubifs.h:1899:44: error: unknown type name 'loff_t'; did you mean 'off_t'? -| 1899 | int deletion, loff_t new_size); -| | ^~~~~~ -| | off_t -| make: *** [Makefile:4878: ubifs-utils/common/mkfs_ubifs-compr.o] Error 1 - -Signed-off-by: Fabio Estevam -Reviewed-by: Zhihao Cheng -Reviewed-by: Khem Raj -Signed-off-by: David Oberhollenzer ---- - ubifs-utils/libubifs/ubifs.h | 1 + - 1 file changed, 1 insertion(+) - ---- a/ubifs-utils/libubifs/ubifs.h -+++ b/ubifs-utils/libubifs/ubifs.h -@@ -11,6 +11,7 @@ - #ifndef __UBIFS_H__ - #define __UBIFS_H__ - -+#include - #include - - #include "linux_types.h" diff --git a/package/utils/mtd-utils/patches/006-ubifs-utils-journal-Include-sys-stat.h.patch b/package/utils/mtd-utils/patches/006-ubifs-utils-journal-Include-sys-stat.h.patch deleted file mode 100644 index b43cef8119e..00000000000 --- a/package/utils/mtd-utils/patches/006-ubifs-utils-journal-Include-sys-stat.h.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 173f9714c8da1d685bfa951d43b9310d16bbab3c Mon Sep 17 00:00:00 2001 -From: Fabio Estevam -Date: Wed, 19 Feb 2025 10:02:42 -0300 -Subject: ubifs-utils: journal: Include - -Include the header file to fix the following error -when building with musl: - -| ../git/ubifs-utils/libubifs/journal.c: In function 'ubifs_get_dent_type': -| ../git/ubifs-utils/libubifs/journal.c:414:24: error: 'S_IFMT' undeclared (first use in this function) -| 414 | switch (mode & S_IFMT) { -| | ^~~~~~ -| ../git/ubifs-utils/libubifs/journal.c:414:24: note: each undeclared identifier is reported only once for each function it appears in -| ../git/ubifs-utils/libubifs/journal.c:415:14: error: 'S_IFREG' undeclared (first use in this function) -| 415 | case S_IFREG: - -Signed-off-by: Fabio Estevam -Reviewed-by: Zhihao Cheng -Signed-off-by: David Oberhollenzer ---- - ubifs-utils/libubifs/journal.c | 1 + - 1 file changed, 1 insertion(+) - ---- a/ubifs-utils/libubifs/journal.c -+++ b/ubifs-utils/libubifs/journal.c -@@ -46,6 +46,7 @@ - * all the nodes. - */ - -+#include - #include "bitops.h" - #include "kmem.h" - #include "ubifs.h" diff --git a/package/utils/mtd-utils/patches/007-ubifs-utils-extract_files-Include-linux-limits.h.patch b/package/utils/mtd-utils/patches/007-ubifs-utils-extract_files-Include-linux-limits.h.patch deleted file mode 100644 index 1e99ab6f948..00000000000 --- a/package/utils/mtd-utils/patches/007-ubifs-utils-extract_files-Include-linux-limits.h.patch +++ /dev/null @@ -1,33 +0,0 @@ -From 77981a2888c711268b0e7f32af6af159c2288e23 Mon Sep 17 00:00:00 2001 -From: Fabio Estevam -Date: Wed, 19 Feb 2025 10:02:44 -0300 -Subject: ubifs-utils: extract_files: Include - -Include to fix the following build error when building -with musl: - -| ../git/ubifs-utils/fsck.ubifs/extract_files.c: In function 'parse_ino_node': -| ../git/ubifs-utils/fsck.ubifs/extract_files.c:144:47: error: 'XATTR_LIST_MAX' undeclared (first use in this function) -| 144 | if (ino_node->xnms + ino_node->xcnt > XATTR_LIST_MAX) { -| | ^~~~~~~~~~~~~~ -| ../git/ubifs-utils/fsck.ubifs/extract_files.c:144:47: note: each undeclared identifier is reported only once for each function it appears in -| make: *** [Makefile:4374: ubifs-utils/fsck.ubifs/fsck_ubifs-extract_files.o] Error 1 - -Signed-off-by: Fabio Estevam -Reviewed-by: Zhihao Cheng -Signed-off-by: David Oberhollenzer ---- - ubifs-utils/fsck.ubifs/extract_files.c | 2 ++ - 1 file changed, 2 insertions(+) - ---- a/ubifs-utils/fsck.ubifs/extract_files.c -+++ b/ubifs-utils/fsck.ubifs/extract_files.c -@@ -10,6 +10,8 @@ - #include - #include - -+#include -+ - #include "linux_err.h" - #include "bitops.h" - #include "kmem.h" diff --git a/package/utils/mtd-utils/patches/100-Remove-ubifs-test-builds.patch b/package/utils/mtd-utils/patches/100-Remove-ubifs-test-builds.patch index 222bf4bea4b..f9a0c11d358 100644 --- a/package/utils/mtd-utils/patches/100-Remove-ubifs-test-builds.patch +++ b/package/utils/mtd-utils/patches/100-Remove-ubifs-test-builds.patch @@ -20,7 +20,7 @@ https://patchwork.ozlabs.org/project/linux-mtd/patch/20250220112554.2150046-1-m. --- a/Makefile.am +++ b/Makefile.am -@@ -64,7 +64,6 @@ include tests/jittertest/Makemodule.am +@@ -67,7 +67,6 @@ include tests/jittertest/Makemodule.am include tests/checkfs/Makemodule.am include tests/fs-tests/Makemodule.am include tests/mtd-tests/Makemodule.am -- 2.47.3