[openwrt/openwrt] mtd-utils: Update to version 2.3.0
LEDE Commits
lede-commits at lists.infradead.org
Sat Nov 8 12:05:33 PST 2025
hauke pushed a commit to openwrt/openwrt.git, branch main:
https://git.openwrt.org/6ad9daf99aef65919bd59aa4b094dbbf7b00cc8d
commit 6ad9daf99aef65919bd59aa4b094dbbf7b00cc8d
Author: Hauke Mehrtens <hauke at hauke-m.de>
AuthorDate: Sat Oct 25 15:50:36 2025 +0200
mtd-utils: Update to version 2.3.0
See announcement mail for list of new features:
https://lists.infradead.org/pipermail/linux-mtd/2025-February/108248.html
Cherry pick some upstream commits which fix build problems in some
situations.
autoreconf fixup is needed now otherwise the build fails with:
```
mtd-utils-2.3.0/missing: line 81: automake-1.16: command not found
```
The code in tests/ubifs_tools-tests/Makemodule.am does not build because
some test data is not packaged in the tar files, do not build code from
this directory.
The size increased only very little:
61498 bin/targets/ramips/mt7621/packages/nand-utils-2.3.0-r1.apk
101643 bin/targets/ramips/mt7621/packages/ubi-utils-2.3.0-r1.apk
61243 bin/targets/ramips/mt7621/packages/nand-utils-2.2.1-r1.apk
101291 bin/targets/ramips/mt7621/packages/ubi-utils-2.2.1-r1.apk
Link: https://github.com/openwrt/openwrt/pull/20540
Signed-off-by: Hauke Mehrtens <hauke at hauke-m.de>
---
package/utils/mtd-utils/Makefile | 7 ++-
...-link-libmissing.a-in-case-execinfo.h-isn.patch | 57 ++++++++++++++++++++++
...tils-common-fix-memory-leak-in-devtable.c.patch | 32 ++++++++++++
...04-Improve-check-for-GCC-compiler-version.patch | 32 ++++++++++++
.../005-ubifs-utils-ubifs.h-Include-fcntl.h.patch | 45 +++++++++++++++++
...06-ubifs-utils-journal-Include-sys-stat.h.patch | 33 +++++++++++++
...tils-extract_files-Include-linux-limits.h.patch | 33 +++++++++++++
.../patches/100-Remove-ubifs-test-builds.patch | 30 ++++++++++++
8 files changed, 267 insertions(+), 2 deletions(-)
diff --git a/package/utils/mtd-utils/Makefile b/package/utils/mtd-utils/Makefile
index 0dc8831251..482785f2ad 100644
--- a/package/utils/mtd-utils/Makefile
+++ b/package/utils/mtd-utils/Makefile
@@ -8,18 +8,20 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mtd-utils
-PKG_VERSION:=2.2.1
+PKG_VERSION:=2.3.0
PKG_RELEASE:=1
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
PKG_SOURCE_URL:=https://infraroot.at/pub/mtd/
-PKG_HASH:=f7ae20b2eb79ee83441468f0b99d897024cd96ff853eea59106fb1952065c803
+PKG_HASH:=2db102908b232406ccb20719c0f43b61196aef4534493419fbf98a273c598c10
PKG_INSTALL:=1
PKG_FLAGS:=nonshared
PKG_BUILD_FLAGS:=gc-sections
+PKG_FIXUP:=autoreconf
+
PKG_BUILD_DEPENDS:=util-linux
PKG_LICENSE:=GPLv2
@@ -59,6 +61,7 @@ MAKE_FLAGS += LDLIBS+="$(LIBGCC_S)"
CONFIGURE_ARGS += \
--enable-tests \
+ --disable-unit-tests \
--without-crypto \
--without-xattr \
--without-zstd \
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
new file mode 100644
index 0000000000..e43e34f533
--- /dev/null
+++ b/package/utils/mtd-utils/patches/001-ubifs-utils-link-libmissing.a-in-case-execinfo.h-isn.patch
@@ -0,0 +1,57 @@
+From 8a83b306db64d6f60186d4396b0b770163b85b6e Mon Sep 17 00:00:00 2001
+From: Ross Burton <ross.burton at arm.com>
+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 <ross.burton at arm.com>
+Reviewed-by: Zhihao Cheng <chengzhihao1 at huawei.com>
+Signed-off-by: David Oberhollenzer <david.oberhollenzer at sigma-star.at>
+---
+ 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 <errno.h>
+ #include <time.h>
+ #include <assert.h>
++#if HAVE_EXECINFO_H
+ #include <execinfo.h>
+-
++#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
new file mode 100644
index 0000000000..4daaf45306
--- /dev/null
+++ b/package/utils/mtd-utils/patches/002-ubifs-utils-common-fix-memory-leak-in-devtable.c.patch
@@ -0,0 +1,32 @@
+From 2669111e3c60b8e146c174db5d2e7e9991f3dd87 Mon Sep 17 00:00:00 2001
+From: AntonMoryakov <ant.v.moryakov at gmail.com>
+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 <ant.v.moryakov at gmail.co
+Reviewed-by: Zhihao Cheng <chengzhihao1 at huawei.com>
+Signed-off-by: David Oberhollenzer <david.oberhollenzer at sigma-star.at>
+---
+ 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
new file mode 100644
index 0000000000..5b1870b1c1
--- /dev/null
+++ b/package/utils/mtd-utils/patches/004-Improve-check-for-GCC-compiler-version.patch
@@ -0,0 +1,32 @@
+From ac0ab65ebcd7b11739986b81343457469fbb43b0 Mon Sep 17 00:00:00 2001
+From: Khem Raj <raj.khem at gmail.com>
+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 <raj.khem at gmail.com>
+Signed-off-by: David Oberhollenzer <david.oberhollenzer at sigma-star.at>
+---
+ 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
new file mode 100644
index 0000000000..0bba423d7d
--- /dev/null
+++ b/package/utils/mtd-utils/patches/005-ubifs-utils-ubifs.h-Include-fcntl.h.patch
@@ -0,0 +1,45 @@
+From 12bc9ad824bd8f18a5ec9c7154ad2374cf8c7ae3 Mon Sep 17 00:00:00 2001
+From: Fabio Estevam <festevam at gmail.com>
+Date: Wed, 19 Feb 2025 10:02:41 -0300
+Subject: ubifs-utils: ubifs.h: Include <fcntl.h>
+
+Include the <fcntl.h> 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 <festevam at gmail.com>
+Reviewed-by: Zhihao Cheng <chengzhihao1 at huawei.com>
+Reviewed-by: Khem Raj <raj.khem at gmail.com>
+Signed-off-by: David Oberhollenzer <david.oberhollenzer at sigma-star.at>
+---
+ 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 <fcntl.h>
+ #include <string.h>
+
+ #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
new file mode 100644
index 0000000000..b43cef8119
--- /dev/null
+++ b/package/utils/mtd-utils/patches/006-ubifs-utils-journal-Include-sys-stat.h.patch
@@ -0,0 +1,33 @@
+From 173f9714c8da1d685bfa951d43b9310d16bbab3c Mon Sep 17 00:00:00 2001
+From: Fabio Estevam <festevam at gmail.com>
+Date: Wed, 19 Feb 2025 10:02:42 -0300
+Subject: ubifs-utils: journal: Include <sys/stat.h>
+
+Include the <sys/stat.h> 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 <festevam at gmail.com>
+Reviewed-by: Zhihao Cheng <chengzhihao1 at huawei.com>
+Signed-off-by: David Oberhollenzer <david.oberhollenzer at sigma-star.at>
+---
+ 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 <sys/stat.h>
+ #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
new file mode 100644
index 0000000000..1e99ab6f94
--- /dev/null
+++ b/package/utils/mtd-utils/patches/007-ubifs-utils-extract_files-Include-linux-limits.h.patch
@@ -0,0 +1,33 @@
+From 77981a2888c711268b0e7f32af6af159c2288e23 Mon Sep 17 00:00:00 2001
+From: Fabio Estevam <festevam at gmail.com>
+Date: Wed, 19 Feb 2025 10:02:44 -0300
+Subject: ubifs-utils: extract_files: Include <linux/limits.h>
+
+Include <linux/limits.h> 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 <festevam at gmail.com>
+Reviewed-by: Zhihao Cheng <chengzhihao1 at huawei.com>
+Signed-off-by: David Oberhollenzer <david.oberhollenzer at sigma-star.at>
+---
+ 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 <getopt.h>
+ #include <sys/stat.h>
+
++#include <linux/limits.h>
++
+ #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
new file mode 100644
index 0000000000..222bf4bea4
--- /dev/null
+++ b/package/utils/mtd-utils/patches/100-Remove-ubifs-test-builds.patch
@@ -0,0 +1,30 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Hauke Mehrtens <hauke at hauke-m.de>
+Date: Sat, 25 Oct 2025 15:38:31 +0200
+Subject: Remove ubifs test builds
+
+The build from the tar file fails with:
+```
+make[3]: *** No rule to make target 'tests/ubifs_tools-tests/images/good.gz', needed by 'all-am'. Stop.
+```
+
+The tar does not contain the test data files. We do not need these
+tests, just deactivate them.
+
+A new tar file created with this upstream fix should contain the missing
+files:
+https://patchwork.ozlabs.org/project/linux-mtd/patch/20250220112554.2150046-1-m.olbrich@pengutronix.de/
+---
+ Makefile.am | 1 -
+ 1 file changed, 1 deletion(-)
+
+--- a/Makefile.am
++++ b/Makefile.am
+@@ -64,7 +64,6 @@ include tests/jittertest/Makemodule.am
+ include tests/checkfs/Makemodule.am
+ include tests/fs-tests/Makemodule.am
+ include tests/mtd-tests/Makemodule.am
+-include tests/ubifs_tools-tests/Makemodule.am
+ endif
+
+ if UNIT_TESTS
More information about the lede-commits
mailing list