Skip to content

Commit 6ad9daf

Browse files
committed
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: openwrt/openwrt#20540 Signed-off-by: Hauke Mehrtens <[email protected]>
1 parent 52c0e90 commit 6ad9daf

8 files changed

+267
-2
lines changed

package/utils/mtd-utils/Makefile

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,18 +8,20 @@
88
include $(TOPDIR)/rules.mk
99

1010
PKG_NAME:=mtd-utils
11-
PKG_VERSION:=2.2.1
11+
PKG_VERSION:=2.3.0
1212
PKG_RELEASE:=1
1313

1414
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.bz2
1515
PKG_SOURCE_URL:=https://infraroot.at/pub/mtd/
16-
PKG_HASH:=f7ae20b2eb79ee83441468f0b99d897024cd96ff853eea59106fb1952065c803
16+
PKG_HASH:=2db102908b232406ccb20719c0f43b61196aef4534493419fbf98a273c598c10
1717

1818
PKG_INSTALL:=1
1919

2020
PKG_FLAGS:=nonshared
2121
PKG_BUILD_FLAGS:=gc-sections
2222

23+
PKG_FIXUP:=autoreconf
24+
2325
PKG_BUILD_DEPENDS:=util-linux
2426

2527
PKG_LICENSE:=GPLv2
@@ -59,6 +61,7 @@ MAKE_FLAGS += LDLIBS+="$(LIBGCC_S)"
5961

6062
CONFIGURE_ARGS += \
6163
--enable-tests \
64+
--disable-unit-tests \
6265
--without-crypto \
6366
--without-xattr \
6467
--without-zstd \
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
From 8a83b306db64d6f60186d4396b0b770163b85b6e Mon Sep 17 00:00:00 2001
2+
From: Ross Burton <[email protected]>
3+
Date: Wed, 26 Feb 2025 18:24:00 +0000
4+
Subject: ubifs-utils: link libmissing.a in case execinfo.h isn't present
5+
6+
On musl execinfo.h doesn't exist, but ubifs-utils uses backtrace() when
7+
reporting errors. This results in build failures under musl.
8+
9+
Handily, libmissing.a already exists with a stub implementation of
10+
backtrace().
11+
12+
Guard the execinfo.h include and if it isn't available instead include
13+
libmissing.h, and link to libmissing.a to provide backtrace() if needed.
14+
15+
Signed-off-by: Ross Burton <[email protected]>
16+
Reviewed-by: Zhihao Cheng <[email protected]>
17+
Signed-off-by: David Oberhollenzer <[email protected]>
18+
---
19+
ubifs-utils/Makemodule.am | 4 ++--
20+
ubifs-utils/common/defs.h | 5 ++++-
21+
2 files changed, 6 insertions(+), 3 deletions(-)
22+
23+
--- a/ubifs-utils/Makemodule.am
24+
+++ b/ubifs-utils/Makemodule.am
25+
@@ -72,7 +72,7 @@ mkfs_ubifs_SOURCES = \
26+
ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
27+
28+
mkfs_ubifs_LDADD = libmtd.a libubi.a $(ZLIB_LIBS) $(LZO_LIBS) $(ZSTD_LIBS) $(UUID_LIBS) $(LIBSELINUX_LIBS) $(OPENSSL_LIBS) \
29+
- $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread
30+
+ $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread libmissing.a
31+
mkfs_ubifs_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) $(ZSTD_CFLAGS) $(UUID_CFLAGS) $(LIBSELINUX_CFLAGS) \
32+
-I$(top_srcdir)/ubi-utils/include -I$(top_srcdir)/ubifs-utils/common -I $(top_srcdir)/ubifs-utils/libubifs
33+
34+
@@ -90,7 +90,7 @@ fsck_ubifs_SOURCES = \
35+
ubifs-utils/fsck.ubifs/handle_disconnected.c
36+
37+
fsck_ubifs_LDADD = libmtd.a libubi.a $(ZLIB_LIBS) $(LZO_LIBS) $(ZSTD_LIBS) $(UUID_LIBS) $(LIBSELINUX_LIBS) $(OPENSSL_LIBS) \
38+
- $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread
39+
+ $(DUMP_STACK_LD) $(ASAN_LIBS) -lm -lpthread libmissing.a
40+
fsck_ubifs_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) $(ZSTD_CFLAGS) $(UUID_CFLAGS) $(LIBSELINUX_CFLAGS) \
41+
-I$(top_srcdir)/ubi-utils/include -I$(top_srcdir)/ubifs-utils/common -I $(top_srcdir)/ubifs-utils/libubifs \
42+
-I$(top_srcdir)/ubifs-utils/fsck.ubifs
43+
--- a/ubifs-utils/common/defs.h
44+
+++ b/ubifs-utils/common/defs.h
45+
@@ -13,8 +13,11 @@
46+
#include <errno.h>
47+
#include <time.h>
48+
#include <assert.h>
49+
+#if HAVE_EXECINFO_H
50+
#include <execinfo.h>
51+
-
52+
+#else
53+
+#include "libmissing.h"
54+
+#endif
55+
#include "ubifs.h"
56+
57+
/* common.h requires the PROGRAM_NAME macro */
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
From 2669111e3c60b8e146c174db5d2e7e9991f3dd87 Mon Sep 17 00:00:00 2001
2+
From: AntonMoryakov <[email protected]>
3+
Date: Thu, 24 Apr 2025 21:19:22 +0300
4+
Subject: ubifs-utils: common: fix memory leak in devtable.c
5+
6+
Report of the static analyzer:
7+
Dynamic memory, referenced by 'line', is allocated at devtable.c:356
8+
by calling function 'getline' and lost at devtable.c:388.
9+
(line: while (getline(&line, &len, f) != -1) {)
10+
11+
Correct explained:
12+
Now line is freed in any exit scenario via out_close which eliminates this error.
13+
14+
Triggers found by static analyzer Svace.
15+
16+
Signed-off-by: Anton Moryakov <[email protected]
17+
Reviewed-by: Zhihao Cheng <[email protected]>
18+
Signed-off-by: David Oberhollenzer <[email protected]>
19+
---
20+
ubifs-utils/common/devtable.c | 1 +
21+
1 file changed, 1 insertion(+)
22+
23+
--- a/ubifs-utils/common/devtable.c
24+
+++ b/ubifs-utils/common/devtable.c
25+
@@ -392,6 +392,7 @@ int parse_devtable(const char *tbl_file)
26+
27+
out_close:
28+
fclose(f);
29+
+ free(line);
30+
free_devtable_info();
31+
return -1;
32+
}
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
From ac0ab65ebcd7b11739986b81343457469fbb43b0 Mon Sep 17 00:00:00 2001
2+
From: Khem Raj <[email protected]>
3+
Date: Sat, 22 Mar 2025 21:01:32 -0700
4+
Subject: Improve check for GCC compiler version
5+
6+
When using unreleased compiler has version like
7+
15.0.1 and that test fails because __GNUC_MINOR__ < 1
8+
becomes true, therefore check for full version string
9+
which is more rubust.
10+
11+
Signed-off-by: Khem Raj <[email protected]>
12+
Signed-off-by: David Oberhollenzer <[email protected]>
13+
---
14+
ubifs-utils/common/atomic.h | 6 +++++-
15+
1 file changed, 5 insertions(+), 1 deletion(-)
16+
17+
--- a/ubifs-utils/common/atomic.h
18+
+++ b/ubifs-utils/common/atomic.h
19+
@@ -2,8 +2,12 @@
20+
#ifndef __ATOMIC_H__
21+
#define __ATOMIC_H__
22+
23+
+#define GCC_VERSION (__GNUC__ * 10000 \
24+
+ + __GNUC_MINOR__ * 100 \
25+
+ + __GNUC_PATCHLEVEL__)
26+
+
27+
/* Check GCC version, just to be safe */
28+
-#if !defined(__GNUC__) || (__GNUC__ < 4) || (__GNUC_MINOR__ < 1)
29+
+#if GCC_VERSION < 40100
30+
# error atomic.h works only with GCC newer than version 4.1
31+
#endif /* GNUC >= 4.1 */
32+
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
From 12bc9ad824bd8f18a5ec9c7154ad2374cf8c7ae3 Mon Sep 17 00:00:00 2001
2+
From: Fabio Estevam <[email protected]>
3+
Date: Wed, 19 Feb 2025 10:02:41 -0300
4+
Subject: ubifs-utils: ubifs.h: Include <fcntl.h>
5+
6+
Include the <fcntl.h> header file to fix the following error
7+
when building with musl:
8+
9+
| In file included from ../git/ubifs-utils/common/compr.c:42:
10+
| ../git/ubifs-utils/libubifs/ubifs.h:313:9: error: unknown type name 'loff_t'; did you mean 'off_t'?
11+
| 313 | loff_t ui_size;
12+
| | ^~~~~~
13+
| | off_t
14+
| ../git/ubifs-utils/libubifs/ubifs.h:1341:9: error: unknown type name 'loff_t'; did you mean 'off_t'?
15+
| 1341 | loff_t i_size;
16+
| | ^~~~~~
17+
| | off_t
18+
| ../git/ubifs-utils/libubifs/ubifs.h:1342:9: error: unknown type name 'loff_t'; did you mean 'off_t'?
19+
| 1342 | loff_t d_size;
20+
| | ^~~~~~
21+
| | off_t
22+
| ../git/ubifs-utils/libubifs/ubifs.h:1899:44: error: unknown type name 'loff_t'; did you mean 'off_t'?
23+
| 1899 | int deletion, loff_t new_size);
24+
| | ^~~~~~
25+
| | off_t
26+
| make: *** [Makefile:4878: ubifs-utils/common/mkfs_ubifs-compr.o] Error 1
27+
28+
Signed-off-by: Fabio Estevam <[email protected]>
29+
Reviewed-by: Zhihao Cheng <[email protected]>
30+
Reviewed-by: Khem Raj <[email protected]>
31+
Signed-off-by: David Oberhollenzer <[email protected]>
32+
---
33+
ubifs-utils/libubifs/ubifs.h | 1 +
34+
1 file changed, 1 insertion(+)
35+
36+
--- a/ubifs-utils/libubifs/ubifs.h
37+
+++ b/ubifs-utils/libubifs/ubifs.h
38+
@@ -11,6 +11,7 @@
39+
#ifndef __UBIFS_H__
40+
#define __UBIFS_H__
41+
42+
+#include <fcntl.h>
43+
#include <string.h>
44+
45+
#include "linux_types.h"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From 173f9714c8da1d685bfa951d43b9310d16bbab3c Mon Sep 17 00:00:00 2001
2+
From: Fabio Estevam <[email protected]>
3+
Date: Wed, 19 Feb 2025 10:02:42 -0300
4+
Subject: ubifs-utils: journal: Include <sys/stat.h>
5+
6+
Include the <sys/stat.h> header file to fix the following error
7+
when building with musl:
8+
9+
| ../git/ubifs-utils/libubifs/journal.c: In function 'ubifs_get_dent_type':
10+
| ../git/ubifs-utils/libubifs/journal.c:414:24: error: 'S_IFMT' undeclared (first use in this function)
11+
| 414 | switch (mode & S_IFMT) {
12+
| | ^~~~~~
13+
| ../git/ubifs-utils/libubifs/journal.c:414:24: note: each undeclared identifier is reported only once for each function it appears in
14+
| ../git/ubifs-utils/libubifs/journal.c:415:14: error: 'S_IFREG' undeclared (first use in this function)
15+
| 415 | case S_IFREG:
16+
17+
Signed-off-by: Fabio Estevam <[email protected]>
18+
Reviewed-by: Zhihao Cheng <[email protected]>
19+
Signed-off-by: David Oberhollenzer <[email protected]>
20+
---
21+
ubifs-utils/libubifs/journal.c | 1 +
22+
1 file changed, 1 insertion(+)
23+
24+
--- a/ubifs-utils/libubifs/journal.c
25+
+++ b/ubifs-utils/libubifs/journal.c
26+
@@ -46,6 +46,7 @@
27+
* all the nodes.
28+
*/
29+
30+
+#include <sys/stat.h>
31+
#include "bitops.h"
32+
#include "kmem.h"
33+
#include "ubifs.h"
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
From 77981a2888c711268b0e7f32af6af159c2288e23 Mon Sep 17 00:00:00 2001
2+
From: Fabio Estevam <[email protected]>
3+
Date: Wed, 19 Feb 2025 10:02:44 -0300
4+
Subject: ubifs-utils: extract_files: Include <linux/limits.h>
5+
6+
Include <linux/limits.h> to fix the following build error when building
7+
with musl:
8+
9+
| ../git/ubifs-utils/fsck.ubifs/extract_files.c: In function 'parse_ino_node':
10+
| ../git/ubifs-utils/fsck.ubifs/extract_files.c:144:47: error: 'XATTR_LIST_MAX' undeclared (first use in this function)
11+
| 144 | if (ino_node->xnms + ino_node->xcnt > XATTR_LIST_MAX) {
12+
| | ^~~~~~~~~~~~~~
13+
| ../git/ubifs-utils/fsck.ubifs/extract_files.c:144:47: note: each undeclared identifier is reported only once for each function it appears in
14+
| make: *** [Makefile:4374: ubifs-utils/fsck.ubifs/fsck_ubifs-extract_files.o] Error 1
15+
16+
Signed-off-by: Fabio Estevam <[email protected]>
17+
Reviewed-by: Zhihao Cheng <[email protected]>
18+
Signed-off-by: David Oberhollenzer <[email protected]>
19+
---
20+
ubifs-utils/fsck.ubifs/extract_files.c | 2 ++
21+
1 file changed, 2 insertions(+)
22+
23+
--- a/ubifs-utils/fsck.ubifs/extract_files.c
24+
+++ b/ubifs-utils/fsck.ubifs/extract_files.c
25+
@@ -10,6 +10,8 @@
26+
#include <getopt.h>
27+
#include <sys/stat.h>
28+
29+
+#include <linux/limits.h>
30+
+
31+
#include "linux_err.h"
32+
#include "bitops.h"
33+
#include "kmem.h"
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
2+
From: Hauke Mehrtens <[email protected]>
3+
Date: Sat, 25 Oct 2025 15:38:31 +0200
4+
Subject: Remove ubifs test builds
5+
6+
The build from the tar file fails with:
7+
```
8+
make[3]: *** No rule to make target 'tests/ubifs_tools-tests/images/good.gz', needed by 'all-am'. Stop.
9+
```
10+
11+
The tar does not contain the test data files. We do not need these
12+
tests, just deactivate them.
13+
14+
A new tar file created with this upstream fix should contain the missing
15+
files:
16+
https://patchwork.ozlabs.org/project/linux-mtd/patch/[email protected]/
17+
---
18+
Makefile.am | 1 -
19+
1 file changed, 1 deletion(-)
20+
21+
--- a/Makefile.am
22+
+++ b/Makefile.am
23+
@@ -64,7 +64,6 @@ include tests/jittertest/Makemodule.am
24+
include tests/checkfs/Makemodule.am
25+
include tests/fs-tests/Makemodule.am
26+
include tests/mtd-tests/Makemodule.am
27+
-include tests/ubifs_tools-tests/Makemodule.am
28+
endif
29+
30+
if UNIT_TESTS

0 commit comments

Comments
 (0)