summaryrefslogtreecommitdiffstats
path: root/meta-initramfs
diff options
context:
space:
mode:
authorAndrea Adami <andrea.adami@gmail.com>2018-05-23 22:15:46 +0200
committerKhem Raj <raj.khem@gmail.com>2018-05-26 21:10:55 -0700
commit9f38fa5ae1df01673ad652f6bc92fffe78148ee4 (patch)
tree28e46e054b4e4c024606ec4c55f3ed900c8a52bf /meta-initramfs
parentef537dcfef67dd397a82de1c881b76097b5a5554 (diff)
downloadmeta-openembedded-9f38fa5ae1df01673ad652f6bc92fffe78148ee4.tar.gz
ubi-utils-klibc: update from v. 1.5.2 to 2.0.2
Update to new version and drop accepted patches. Use autotools and packageconfig (for xattrs). Signed-off-by: Andrea Adami <andrea.adami@gmail.com> Signed-off-by: Khem Raj <raj.khem@gmail.com>
Diffstat (limited to 'meta-initramfs')
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0001-Makefile-build-ubi-utils-only.patch87
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0002-common.mk-for-klibc-CC-is-klcc.patch27
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0003-libubi.c-add-klibc-specific-fixes-for-ioctl.patch76
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0004-Restore-compatibility-to-dietlibc-klibc-musl-libc-af.patch88
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0005-common.h-more-workarounds-for-klibc-compatibility.patch52
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0006-libiniparser-remove-unused-function-needing-float.patch85
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch64
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch44
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0009-Eliminate-warnings-about-implicit-non-const-casting-.patch48
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0001-libmissing.h-fix-klibc-build-when-using-glibc-toolch.patch40
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch326
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0003-Makefile.am-only-build-ubi-utils.patch34
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0004-mtd-utils-common.h-no-features.h-for-klibc-builds.patch38
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch56
-rw-r--r--meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_2.0.2.bb (renamed from meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.2.bb)27
15 files changed, 508 insertions, 584 deletions
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0001-Makefile-build-ubi-utils-only.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0001-Makefile-build-ubi-utils-only.patch
deleted file mode 100644
index 6ac2cca9d..000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0001-Makefile-build-ubi-utils-only.patch
+++ /dev/null
@@ -1,87 +0,0 @@
1From 1c989e4c36d0bf76ab444f984bc73b98eeacd03f Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 29 Jun 2014 00:32:29 +0200
4Subject: [PATCH 1/9] Makefile: build ubi-utils only
5
6We build all the static ubi-utils but actually only ubiattach is needed in
7a minimalistic initramfs for the mount of ubi volumes.
8
9More fixes are needed in order to build the full mtd-utils.
10The first issue is:
11
12| mkfs.jffs2.c:64:20: fatal error: libgen.h: No such file or directory
13| #include <libgen.h>
14
15Removing the include then the second error is:
16
17| mkfs.jffs2.c:1570:22: error: '_SC_PAGESIZE' undeclared
18| (first use in this function)
19| page_size = sysconf(_SC_PAGESIZE);
20
21Upstream-Status: Inappropriate [embedded specific]
22
23Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
24---
25 Makefile | 26 ++------------------------
26 1 file changed, 2 insertions(+), 24 deletions(-)
27
28diff --git a/Makefile b/Makefile
29index 3ce8587..8b79f71 100644
30--- a/Makefile
31+++ b/Makefile
32@@ -16,28 +16,11 @@ endif
33
34 TESTS = tests
35
36-MTD_BINS = \
37- ftl_format flash_erase nanddump doc_loadbios \
38- ftl_check mkfs.jffs2 flash_lock flash_unlock \
39- flash_otp_info flash_otp_dump flash_otp_lock flash_otp_write \
40- mtd_debug flashcp nandwrite nandtest mtdpart \
41- jffs2dump \
42- nftldump nftl_format docfdisk \
43- rfddump rfdformat \
44- serve_image recv_image \
45- sumtool jffs2reader
46 UBI_BINS = \
47 ubiupdatevol ubimkvol ubirmvol ubicrc32 ubinfo ubiattach \
48 ubidetach ubinize ubiformat ubirename mtdinfo ubirsvol ubiblock
49
50-BINS = $(MTD_BINS)
51-BINS += mkfs.ubifs/mkfs.ubifs
52-BINS += $(addprefix ubi-utils/,$(UBI_BINS))
53-SCRIPTS = flash_eraseall
54-
55-TARGETS = $(BINS)
56-TARGETS += lib/libmtd.a
57-TARGETS += ubi-utils/libubi.a
58+BINS = $(addprefix ubi-utils/,$(UBI_BINS))
59
60 OBJDEPS = $(BUILDDIR)/include/version.h
61
62@@ -61,12 +44,9 @@ endif
63 rm -f $(BUILDDIR)/include/version.h
64 $(MAKE) -C $(TESTS) clean
65
66-install:: $(addprefix $(BUILDDIR)/,${BINS}) ${SCRIPTS}
67+install:: $(addprefix $(BUILDDIR)/,${BINS})
68 mkdir -p ${DESTDIR}/${SBINDIR}
69 install -m 0755 $^ ${DESTDIR}/${SBINDIR}/
70- mkdir -p ${DESTDIR}/${MANDIR}/man1
71- install -m 0644 mkfs.jffs2.1 ${DESTDIR}/${MANDIR}/man1/
72- -gzip -9f ${DESTDIR}/${MANDIR}/man1/*.1
73
74 tests::
75 $(MAKE) -C $(TESTS)
76@@ -91,8 +71,6 @@ LDLIBS_mkfs.jffs2 = -lz $(LZOLDLIBS)
77 LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
78 LDLIBS_jffs2reader = -lz $(LZOLDLIBS)
79
80-$(foreach v,$(MTD_BINS),$(eval $(call mkdep,,$(v))))
81-
82 #
83 # Common libmtd
84 #
85--
862.7.4
87
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0002-common.mk-for-klibc-CC-is-klcc.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0002-common.mk-for-klibc-CC-is-klcc.patch
deleted file mode 100644
index c23d11f0b..000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0002-common.mk-for-klibc-CC-is-klcc.patch
+++ /dev/null
@@ -1,27 +0,0 @@
1From 89c76bbe82a2029a25b0654eb0a1d0b22d6e6877 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 29 Jun 2014 00:37:28 +0200
4Subject: [PATCH 2/9] common.mk: for klibc $(CC) is klcc
5
6Do not hardcode: assign the value to the variable if it is not already defined.
7
8Upstream-Status: Submitted
9
10Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
11---
12 common.mk | 2 +-
13 1 file changed, 1 insertion(+), 1 deletion(-)
14
15diff --git a/common.mk b/common.mk
16index ba87377..126d11a 100644
17--- a/common.mk
18+++ b/common.mk
19@@ -1,4 +1,4 @@
20-CC := $(CROSS)gcc
21+CC ?= $(CROSS)gcc
22 AR := $(CROSS)ar
23 RANLIB := $(CROSS)ranlib
24
25--
262.7.4
27
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0003-libubi.c-add-klibc-specific-fixes-for-ioctl.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0003-libubi.c-add-klibc-specific-fixes-for-ioctl.patch
deleted file mode 100644
index 9ad4a5b99..000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0003-libubi.c-add-klibc-specific-fixes-for-ioctl.patch
+++ /dev/null
@@ -1,76 +0,0 @@
1From fecbb7056d621a30f7106e67f5fe209763571b70 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 29 Jun 2014 00:40:15 +0200
4Subject: [PATCH 3/9] libubi.c: add klibc specific fixes for ioctl
5
6First issue is that ioctl() in klibc doesn't expect a constant as arg3.
7Second issue is that arg3 in klibc ioctl() implementation is not optional.
8
9Fixes:
10
11| ubi-utils/libubi.c: In function 'do_attach':
12| ubi-utils/libubi.c:698:8: warning: passing argument 3 of 'ioctl' discards
13| 'const' qualifier from pointer target type
14| ret = ioctl(fd, UBI_IOCATT, r);
15| ^
16| In file included from ubi-utils/libubi.c:32:0:
17| .../lib/klibc/include/sys/ioctl.h:15:14: note: expected 'void *' but argument
18| is of type 'const struct ubi_attach_req *'
19| __extern int ioctl(int, int, void *);
20| ^
21
22| ubi-utils/libubi.c: In function 'ubi_vol_block_create':
23| ubi-utils/libubi.c:1118:9: error: too few arguments to function 'ioctl'
24| return ioctl(fd, UBI_IOCVOLCRBLK);
25| ^
26| In file included from ubi-utils/libubi.c:32:0:
27| .../lib/klibc/include/sys/ioctl.h:15:14: note: declared here
28| __extern int ioctl(int, int, void *);
29| ^
30| ubi-utils/libubi.c: In function 'ubi_vol_block_remove':
31| ubi-utils/libubi.c:1123:9: error: too few arguments to function 'ioctl'
32| return ioctl(fd, UBI_IOCVOLRMBLK);
33| ^
34| In file included from ubi-utils/libubi.c:32:0:
35| .../usr/lib/klibc/include/sys/ioctl.h:15:14: note: declared here
36| __extern int ioctl(int, int, void *);
37| ^
38
39Upstream-Status: Accepted
40
41Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
42---
43 ubi-utils/libubi.c | 6 +++---
44 1 file changed, 3 insertions(+), 3 deletions(-)
45
46diff --git a/ubi-utils/libubi.c b/ubi-utils/libubi.c
47index 97c0434..2b49833 100644
48--- a/ubi-utils/libubi.c
49+++ b/ubi-utils/libubi.c
50@@ -687,7 +687,7 @@ void libubi_close(libubi_t desc)
51 * success and %-1 in case of failure. @r->ubi_num contains newly created UBI
52 * device number.
53 */
54-static int do_attach(const char *node, const struct ubi_attach_req *r)
55+static int do_attach(const char *node, struct ubi_attach_req *r)
56 {
57 int fd, ret;
58
59@@ -1115,12 +1115,12 @@ int ubi_rsvol(libubi_t desc, const char *node, int vol_id, long long bytes)
60
61 int ubi_vol_block_create(int fd)
62 {
63- return ioctl(fd, UBI_IOCVOLCRBLK);
64+ return ioctl(fd, UBI_IOCVOLCRBLK, NULL);
65 }
66
67 int ubi_vol_block_remove(int fd)
68 {
69- return ioctl(fd, UBI_IOCVOLRMBLK);
70+ return ioctl(fd, UBI_IOCVOLRMBLK, NULL);
71 }
72
73 int ubi_update_start(libubi_t desc, int fd, long long bytes)
74--
752.7.4
76
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0004-Restore-compatibility-to-dietlibc-klibc-musl-libc-af.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0004-Restore-compatibility-to-dietlibc-klibc-musl-libc-af.patch
deleted file mode 100644
index 2f31fb4a2..000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0004-Restore-compatibility-to-dietlibc-klibc-musl-libc-af.patch
+++ /dev/null
@@ -1,88 +0,0 @@
1From b668cb75cb7e72ff92055209130d4cd4b3cacbdb Mon Sep 17 00:00:00 2001
2From: Thorsten Glaser <tg@mirbsd.org>
3Date: Fri, 20 Jun 2014 10:56:27 +0000
4Subject: [PATCH 4/9] Restore compatibility to dietlibc, klibc, musl libc after
5 commit 4f1b108
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10Each C library has their own way to define off_t, and the <features.h>
11header is nonstandard and specific to the GNU libc and those that clone
12it (uClibc). Fefe’s dietlibc uses different flags, and klibc always uses
13a 64-bit off_t (like the BSDs); musl libc cannot be recognised using cpp
14instructions, so we assume 64 bit there (and on unknown C libraries) and
15leave it to the user to submit a follow-up fix if we guess wrong. I also
16added a static assertion to verify the 64 bit guess is correct.
17
18It would be really better using a configure script for this instead.
19
20Fixes:
21| CC lib/libmtd.o
22| In file included from ubi-utils/ubiutils-common.c:35:0:
23| ./include/common.h:29:22: fatal error: features.h: No such file or directory
24| #include <features.h>
25| ^
26| compilation terminated.
27
28Upstream-Status: Submitted
29
30Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
31Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
32---
33 include/common.h | 24 ++++++++++++++++++++++++
34 1 file changed, 24 insertions(+)
35
36diff --git a/include/common.h b/include/common.h
37index fb0ca83..5a20964 100644
38--- a/include/common.h
39+++ b/include/common.h
40@@ -26,7 +26,9 @@
41 #include <string.h>
42 #include <fcntl.h>
43 #include <errno.h>
44+#if defined(__GLIBC__) || defined(__UCLIBC__)
45 #include <features.h>
46+#endif
47 #include <inttypes.h>
48 #include "version.h"
49
50@@ -67,6 +69,21 @@ extern "C" {
51 #endif
52
53 /* define a print format specifier for off_t */
54+#if defined(__KLIBC__)
55+/* always 64 bit on klibc */
56+#define PRIxoff_t PRIx64
57+#define PRIdoff_t PRId64
58+#elif defined(__dietlibc__)
59+/* depends on compiler flags on dietlibc */
60+#if defined(_FILE_OFFSET_BITS) && (_FILE_OFFSET_BITS == 64)
61+#define PRIxoff_t PRIx64
62+#define PRIdoff_t PRId64
63+#else
64+#define PRIxoff_t "l"PRIx32
65+#define PRIdoff_t "l"PRId32
66+#endif
67+#elif defined(__GLIBC__) || defined(__UCLIBC__)
68+/* depends on compiler flags on glibc and uClibc */
69 #ifdef __USE_FILE_OFFSET64
70 #define PRIxoff_t PRIx64
71 #define PRIdoff_t PRId64
72@@ -74,6 +91,13 @@ extern "C" {
73 #define PRIxoff_t "l"PRIx32
74 #define PRIdoff_t "l"PRId32
75 #endif
76+#else
77+/* unknown libc or musl */
78+#define PRIxoff_t PRIx64
79+#define PRIdoff_t PRId64
80+/* verify our guess of 64 bit is correct */
81+static char __PRIxoff_t_static_assert[sizeof(off_t) == 8 ? 1 : -1];
82+#endif
83
84 /* Verbose messages */
85 #define bareverbose(verbose, fmt, ...) do { \
86--
872.7.4
88
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0005-common.h-more-workarounds-for-klibc-compatibility.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0005-common.h-more-workarounds-for-klibc-compatibility.patch
deleted file mode 100644
index 8309a7271..000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0005-common.h-more-workarounds-for-klibc-compatibility.patch
+++ /dev/null
@@ -1,52 +0,0 @@
1From 5d4a66b502003ef385dab31a17012246407e7364 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 29 Jun 2014 00:44:03 +0200
4Subject: [PATCH 5/9] common.h: more workarounds for klibc compatibility
5
6Patch is addressing two issues:
7* First, Klibc doesn't have rpmatch().
8* Second, Klibc lacks getline()
9
10Fixes:
11| LD ubi-utils/ubiformat
12| .../git/ubi-utils/ubiformat.o: In function `prompt':
13| .../git/./include/common.h:157: undefined reference to `getline'
14| .../git/./include/common.h:164: undefined reference to `rpmatch'
15| .../git/./include/common.h:157: undefined reference to `getline'
16| .../git/./include/common.h:164: undefined reference to `rpmatch'
17
18Upstream-Status: Submitted
19
20Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
21---
22 include/common.h | 8 +++++---
23 1 file changed, 5 insertions(+), 3 deletions(-)
24
25diff --git a/include/common.h b/include/common.h
26index 5a20964..2f51e1c 100644
27--- a/include/common.h
28+++ b/include/common.h
29@@ -161,15 +161,17 @@ static inline int __rpmatch(const char *resp)
30 */
31 static inline bool prompt(const char *msg, bool def)
32 {
33- char *line = NULL;
34- size_t len;
35+ char *line;
36 bool ret = def;
37
38+ const int sizeof_line = 2;
39+ line = malloc(sizeof_line);
40+
41 do {
42 normsg_cont("%s (%c/%c) ", msg, def ? 'Y' : 'y', def ? 'n' : 'N');
43 fflush(stdout);
44
45- while (getline(&line, &len, stdin) == -1) {
46+ while (fgets(line, sizeof_line, stdin) == NULL) {
47 printf("failed to read prompt; assuming '%s'\n",
48 def ? "yes" : "no");
49 break;
50--
512.7.4
52
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0006-libiniparser-remove-unused-function-needing-float.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0006-libiniparser-remove-unused-function-needing-float.patch
deleted file mode 100644
index d046f9505..000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0006-libiniparser-remove-unused-function-needing-float.patch
+++ /dev/null
@@ -1,85 +0,0 @@
1From 2af30e9b2988111e45ed6ea6af55e49ec7cb1cb1 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 29 Jun 2014 00:44:57 +0200
4Subject: [PATCH 6/9] libiniparser: remove unused function needing float
5
6Fixes:
7| LD ubi-utils/ubiformat
8| .../git/ubi-utils/libiniparser.a(libiniparser.o): In function
9| ` LD ubi-utils/ubirename
10| iniparser_getdouble':
11| .../git/ubi-utils/libiniparser.c:336: undefined reference to `atof'
12
13Grep doesn't reveal any occurrence of iniparser_getdouble(), using atof() so
14remove it: floating-point is not supported in klibc
15
16Upstream-Status: Accepted
17
18Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
19---
20 ubi-utils/include/libiniparser.h | 15 ---------------
21 ubi-utils/libiniparser.c | 22 ----------------------
22 2 files changed, 37 deletions(-)
23
24diff --git a/ubi-utils/include/libiniparser.h b/ubi-utils/include/libiniparser.h
25index be3c667..abd77aa 100644
26--- a/ubi-utils/include/libiniparser.h
27+++ b/ubi-utils/include/libiniparser.h
28@@ -158,21 +158,6 @@ int iniparser_getint(dictionary * d, const char * key, int notfound);
29
30 /*-------------------------------------------------------------------------*/
31 /**
32- @brief Get the string associated to a key, convert to a double
33- @param d Dictionary to search
34- @param key Key string to look for
35- @param notfound Value to return in case of error
36- @return double
37-
38- This function queries a dictionary for a key. A key as read from an
39- ini file is given as "section:key". If the key cannot be found,
40- the notfound value is returned.
41- */
42-/*--------------------------------------------------------------------------*/
43-double iniparser_getdouble(dictionary * d, char * key, double notfound);
44-
45-/*-------------------------------------------------------------------------*/
46-/**
47 @brief Get the string associated to a key, convert to a boolean
48 @param d Dictionary to search
49 @param key Key string to look for
50diff --git a/ubi-utils/libiniparser.c b/ubi-utils/libiniparser.c
51index 898f57f..ba70c08 100644
52--- a/ubi-utils/libiniparser.c
53+++ b/ubi-utils/libiniparser.c
54@@ -316,28 +316,6 @@ int iniparser_getint(dictionary * d, const char * key, int notfound)
55
56 /*-------------------------------------------------------------------------*/
57 /**
58- @brief Get the string associated to a key, convert to a double
59- @param d Dictionary to search
60- @param key Key string to look for
61- @param notfound Value to return in case of error
62- @return double
63-
64- This function queries a dictionary for a key. A key as read from an
65- ini file is given as "section:key". If the key cannot be found,
66- the notfound value is returned.
67- */
68-/*--------------------------------------------------------------------------*/
69-double iniparser_getdouble(dictionary * d, char * key, double notfound)
70-{
71- char * str ;
72-
73- str = iniparser_getstring(d, key, INI_INVALID_KEY);
74- if (str==INI_INVALID_KEY) return notfound ;
75- return atof(str);
76-}
77-
78-/*-------------------------------------------------------------------------*/
79-/**
80 @brief Get the string associated to a key, convert to a boolean
81 @param d Dictionary to search
82 @param key Key string to look for
83--
842.7.4
85
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch
deleted file mode 100644
index 36b012f90..000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch
+++ /dev/null
@@ -1,64 +0,0 @@
1From 41e7c76b0853bf5241b38b8167dfd57c27fef1eb Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 28 Jan 2018 21:47:59 +0100
4Subject: [PATCH 7/9] mtd-utils: common.c: convert to integer arithmetic
5
6We use floating point just to print out KiB, MiB, GiB.
7Avoid that to be klibc friendly.
8
9Fixes compilation for aarch64 against klibc:
10
11error: '-mgeneral-regs-only' is incompatible with floating-point argument
12| printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024));
13etc.
14
15Note:
16* In the KiB case, we could apparently multiply by 100 before dividing
17 without risking overflow. This code simply avoids multiplications.
18
19Upstream-Status: Submitted
20
21Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
22---
23 ubi-utils/ubiutils-common.c | 18 ++++++++++++------
24 1 file changed, 12 insertions(+), 6 deletions(-)
25
26diff --git a/ubi-utils/ubiutils-common.c b/ubi-utils/ubiutils-common.c
27index 6609a6b..0ded2a4 100644
28--- a/ubi-utils/ubiutils-common.c
29+++ b/ubi-utils/ubiutils-common.c
30@@ -107,6 +107,9 @@ long long ubiutils_get_bytes(const char *str)
31 void ubiutils_print_bytes(long long bytes, int bracket)
32 {
33 const char *p;
34+ int GiB = 1024 * 1024 * 1024;
35+ int MiB = 1024 * 1024;
36+ int KiB = 1024;
37
38 if (bracket)
39 p = " (";
40@@ -115,12 +118,15 @@ void ubiutils_print_bytes(long long bytes, int bracket)
41
42 printf("%lld bytes", bytes);
43
44- if (bytes > 1024 * 1024 * 1024)
45- printf("%s%.1f GiB", p, (double)bytes / (1024 * 1024 * 1024));
46- else if (bytes > 1024 * 1024)
47- printf("%s%.1f MiB", p, (double)bytes / (1024 * 1024));
48- else if (bytes > 1024 && bytes != 0)
49- printf("%s%.1f KiB", p, (double)bytes / 1024);
50+ if (bytes > GiB)
51+ printf("%s%lld.%lld GiB", p,
52+ bytes / GiB, bytes % GiB / (GiB / 10));
53+ else if (bytes > MiB)
54+ printf("%s%lld.%lld MiB", p,
55+ bytes / MiB, bytes % MiB / (MiB / 10));
56+ else if (bytes > KiB && bytes != 0)
57+ printf("%s%lld.%lld KiB", p,
58+ bytes / KiB, bytes % KiB / (KiB / 10));
59 else
60 return;
61
62--
632.7.4
64
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch
deleted file mode 100644
index 5bd05742c..000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch
+++ /dev/null
@@ -1,44 +0,0 @@
1From e6f1a85c0a3df24fe3ca9a520dc697105e75a80c Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sat, 27 Jan 2018 09:39:26 +0100
4Subject: [PATCH 8/9] ubi-utils: ubiformat.c: convert to integer arithmetic
5
6Do not cast percent to double, it is just used as upper limit.
7Avoid floating point to fix compilation for aarch64 against klibc:
8
9error: '-mgeneral-regs-only' is incompatible with floating-point code
10| int percent = ((double)si->ok_cnt)/si->good_cnt * 100;
11| ^~~~~~~
12
13Notes:
14* The checks in the code above this line ensure that si->good_cnt is not 0.
15
16* The code assumes si->good_cnt * 100 will not overflow, then we can use
17 (si->ok_cnt * 100) safely because the former is bigger.
18
19* The truncated result does not affect the logic:
20 i.e. a value of 49.9 is truncated to 49 and is still <50.
21
22Upstream-Status: Submitted
23
24Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
25---
26 ubi-utils/ubiformat.c | 2 +-
27 1 file changed, 1 insertion(+), 1 deletion(-)
28
29diff --git a/ubi-utils/ubiformat.c b/ubi-utils/ubiformat.c
30index 21409ca..d93164a 100644
31--- a/ubi-utils/ubiformat.c
32+++ b/ubi-utils/ubiformat.c
33@@ -843,7 +843,7 @@ int main(int argc, char * const argv[])
34 }
35
36 if (!args.override_ec && si->empty_cnt < si->good_cnt) {
37- int percent = ((double)si->ok_cnt)/si->good_cnt * 100;
38+ int percent = (si->ok_cnt * 100) / si->good_cnt;
39
40 /*
41 * Make sure the majority of eraseblocks have valid
42--
432.7.4
44
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0009-Eliminate-warnings-about-implicit-non-const-casting-.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0009-Eliminate-warnings-about-implicit-non-const-casting-.patch
deleted file mode 100644
index 658246add..000000000
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-1.5.2/0009-Eliminate-warnings-about-implicit-non-const-casting-.patch
+++ /dev/null
@@ -1,48 +0,0 @@
1From 2229f3b9fd4bad47794c28e558ad273173cea73d Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sat, 27 Jan 2018 09:52:46 +0100
4Subject: [PATCH 9/9] Eliminate warnings about implicit non-const casting in
5 libmtd
6
7The mtd_get_dev_info1 function reads (among other things) name and type
8string into coresponding struct mtd_dev_info fields.
9
10The struct mtd_dev_info has the string fields marked const, requiring
11them to be cast to non-const version during initialization.
12
13This cast was previously omitted from the dev_read_data calls,
14triggering warnings during compilation.
15
16Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
17Signed-off-by: Richard Weinberger <richard@nod.at>
18
19Upstream-Status: Backport
20
21Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
22---
23 lib/libmtd.c | 4 ++--
24 1 file changed, 2 insertions(+), 2 deletions(-)
25
26diff --git a/lib/libmtd.c b/lib/libmtd.c
27index 60b4782..5f0bcbc 100644
28--- a/lib/libmtd.c
29+++ b/lib/libmtd.c
30@@ -746,13 +746,13 @@ int mtd_get_dev_info1(libmtd_t desc, int mtd_num, struct mtd_dev_info *mtd)
31 if (dev_get_major(lib, mtd_num, &mtd->major, &mtd->minor))
32 return -1;
33
34- ret = dev_read_data(lib->mtd_name, mtd_num, &mtd->name,
35+ ret = dev_read_data(lib->mtd_name, mtd_num, (char *)&mtd->name,
36 MTD_NAME_MAX + 1);
37 if (ret < 0)
38 return -1;
39 ((char *)mtd->name)[ret - 1] = '\0';
40
41- ret = dev_read_data(lib->mtd_type, mtd_num, &mtd->type_str,
42+ ret = dev_read_data(lib->mtd_type, mtd_num, (char *)&mtd->type_str,
43 MTD_TYPE_MAX + 1);
44 if (ret < 0)
45 return -1;
46--
472.7.4
48
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0001-libmissing.h-fix-klibc-build-when-using-glibc-toolch.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0001-libmissing.h-fix-klibc-build-when-using-glibc-toolch.patch
new file mode 100644
index 000000000..6ed167f38
--- /dev/null
+++ b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0001-libmissing.h-fix-klibc-build-when-using-glibc-toolch.patch
@@ -0,0 +1,40 @@
1From e596ae99059c28fa9bb3461e03e7ecaacbf41727 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Wed, 23 May 2018 15:34:59 +0200
4Subject: [PATCH] libmissing.h: fix klibc build when using glibc toolchain
5
6klibc lacks execinfo.h so adda guard around it.
7Note: build with musl toolchain is ok even without this patch.
8
9Fix build error:
10
11| In file included from ../git/lib/execinfo.c:1:0:
12| ../git/include/libmissing.h:7:10: fatal error: execinfo.h:
13 No such file or directory
14
15Status: Inappropriate [klibc specific]
16
17Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
18---
19 include/libmissing.h | 2 ++
20 1 file changed, 2 insertions(+)
21
22diff --git a/include/libmissing.h b/include/libmissing.h
23index 0196033..832c372 100644
24--- a/include/libmissing.h
25+++ b/include/libmissing.h
26@@ -3,9 +3,11 @@
27
28 #include "config.h"
29
30+#ifndef __KLIBC__
31 #ifdef HAVE_EXECINFO_H
32 #include <execinfo.h>
33 #endif
34+#endif
35
36 #ifndef HAVE_EXECINFO_H
37 int backtrace(void **buffer, int size);
38--
392.7.4
40
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch
new file mode 100644
index 000000000..bb675a7be
--- /dev/null
+++ b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch
@@ -0,0 +1,326 @@
1From 01c98d5d5d044d9a125abcdbb2f3d771966365b0 Mon Sep 17 00:00:00 2001
2From: mirabilos <m@mirbsd.org>
3Date: Thu, 1 Feb 2018 15:34:07 +0100
4Subject: [PATCH 2/4] Instead of doing preprocessor magic, just output off_t as
5 long long
6
7Fix warnings abot PRIdoff_t in libmtd.c, in mtd_read (and mtd_write):
8
9In file included from ../git/lib/libmtd.c:40:0:
10../git/lib/libmtd.c: In function 'mtd_read':
11../git/include/common.h:110:18: warning: format '%ld' expects argument of
12 type 'long int', but argument 5 has type 'off_t {aka long long int}'
13 [-Wformat=]
14
15../git/include/common.h:120:2: note: in expansion of macro 'errmsg'
16 errmsg(fmt, ##__VA_ARGS__); \
17 ^~~~~~
18../git/lib/libmtd.c:1082:10: note: in expansion of macro 'sys_errmsg'
19 return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
20 ^~~~~~~~~~
21
22/usr/lib/klibc/include/inttypes.h:28:17: note: format string is defined here
23 #define PRId32 "d"
24
25Upstream-Status: Submitted
26
27Signed-off-by: Thorsten Glaser <tg@mirbsd.org>
28---
29 include/common.h | 18 ------------------
30 jffsX-utils/mkfs.jffs2.c | 20 ++++++++++----------
31 lib/libmtd.c | 8 ++++----
32 misc-utils/flash_erase.c | 6 +++---
33 misc-utils/flash_otp_write.c | 2 +-
34 misc-utils/ftl_check.c | 2 +-
35 misc-utils/mtd_debug.c | 4 ++--
36 misc-utils/serve_image.c | 4 ++--
37 tests/fs-tests/integrity/integck.c | 4 ++--
38 tests/mtd-tests/nandpagetest.c | 4 ++--
39 tests/ubi-tests/integ.c | 6 +++---
40 ubifs-utils/mkfs.ubifs/mkfs.ubifs.c | 6 +++---
41 12 files changed, 33 insertions(+), 51 deletions(-)
42
43diff --git a/include/common.h b/include/common.h
44index f8f72ea..642c212 100644
45--- a/include/common.h
46+++ b/include/common.h
47@@ -70,24 +70,6 @@ extern "C" {
48 #define O_CLOEXEC 0
49 #endif
50
51-/* define a print format specifier for off_t */
52-#if (SIZEOF_OFF_T >= 8)
53-#define PRIxoff_t PRIx64
54-#define PRIdoff_t PRId64
55-#else
56-#define PRIxoff_t "l"PRIx32
57-#define PRIdoff_t "l"PRId32
58-#endif
59-
60-/* define a print format specifier for loff_t */
61-#if (SIZEOF_LOFF_T >= 8)
62-#define PRIxloff_t PRIx64
63-#define PRIdloff_t PRId64
64-#else
65-#define PRIxloff_t "l"PRIx32
66-#define PRIdloff_t "l"PRId32
67-#endif
68-
69 /* Verbose messages */
70 #define bareverbose(verbose, fmt, ...) do { \
71 if (verbose) \
72diff --git a/jffsX-utils/mkfs.jffs2.c b/jffsX-utils/mkfs.jffs2.c
73index 9aa6c39..0661786 100644
74--- a/jffsX-utils/mkfs.jffs2.c
75+++ b/jffsX-utils/mkfs.jffs2.c
76@@ -1237,8 +1237,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
77 } else switch (e->sb.st_mode & S_IFMT) {
78 case S_IFDIR:
79 if (verbose) {
80- printf("\td %04o %9" PRIdoff_t " %5d:%-3d %s\n",
81- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
82+ printf("\td %04o %9lld %5d:%-3d %s\n",
83+ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
84 (int) (e->sb.st_uid), (int) (e->sb.st_gid),
85 e->name);
86 }
87@@ -1247,8 +1247,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
88 break;
89 case S_IFSOCK:
90 if (verbose) {
91- printf("\ts %04o %9" PRIdoff_t " %5d:%-3d %s\n",
92- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
93+ printf("\ts %04o %9lld %5d:%-3d %s\n",
94+ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
95 (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
96 }
97 write_pipe(e);
98@@ -1256,8 +1256,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
99 break;
100 case S_IFIFO:
101 if (verbose) {
102- printf("\tp %04o %9" PRIdoff_t " %5d:%-3d %s\n",
103- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
104+ printf("\tp %04o %9lld %5d:%-3d %s\n",
105+ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
106 (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
107 }
108 write_pipe(e);
109@@ -1285,8 +1285,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
110 break;
111 case S_IFLNK:
112 if (verbose) {
113- printf("\tl %04o %9" PRIdoff_t " %5d:%-3d %s -> %s\n",
114- e->sb.st_mode & ~S_IFMT, e->sb.st_size,
115+ printf("\tl %04o %9lld %5d:%-3d %s -> %s\n",
116+ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size,
117 (int) e->sb.st_uid, (int) e->sb.st_gid, e->name,
118 e->link);
119 }
120@@ -1297,8 +1297,8 @@ static void recursive_populate_directory(struct filesystem_entry *dir)
121 wrote = write_regular_file(e);
122 write_xattr_entry(e);
123 if (verbose) {
124- printf("\tf %04o %9" PRIdoff_t " (%9u) %5d:%-3d %s\n",
125- e->sb.st_mode & ~S_IFMT, e->sb.st_size, wrote,
126+ printf("\tf %04o %9lld (%9u) %5d:%-3d %s\n",
127+ e->sb.st_mode & ~S_IFMT, (long long)e->sb.st_size, wrote,
128 (int) e->sb.st_uid, (int) e->sb.st_gid, e->name);
129 }
130 break;
131diff --git a/lib/libmtd.c b/lib/libmtd.c
132index 86c89ae..f375381 100644
133--- a/lib/libmtd.c
134+++ b/lib/libmtd.c
135@@ -1079,8 +1079,8 @@ int mtd_read(const struct mtd_dev_info *mtd, int fd, int eb, int offs,
136 /* Seek to the beginning of the eraseblock */
137 seek = (off_t)eb * mtd->eb_size + offs;
138 if (lseek(fd, seek, SEEK_SET) != seek)
139- return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
140- mtd->mtd_num, seek);
141+ return sys_errmsg("cannot seek mtd%d to offset %lld",
142+ mtd->mtd_num, (long long)seek);
143
144 while (rd < len) {
145 ret = read(fd, buf + rd, len - rd);
146@@ -1188,8 +1188,8 @@ int mtd_write(libmtd_t desc, const struct mtd_dev_info *mtd, int fd, int eb,
147 if (data) {
148 /* Seek to the beginning of the eraseblock */
149 if (lseek(fd, seek, SEEK_SET) != seek)
150- return sys_errmsg("cannot seek mtd%d to offset %"PRIdoff_t,
151- mtd->mtd_num, seek);
152+ return sys_errmsg("cannot seek mtd%d to offset %lld",
153+ mtd->mtd_num, (long long)seek);
154 ret = write(fd, data, len);
155 if (ret != len)
156 return sys_errmsg("cannot write %d bytes to mtd%d "
157diff --git a/misc-utils/flash_erase.c b/misc-utils/flash_erase.c
158index 0c9449f..ec4b2e1 100644
159--- a/misc-utils/flash_erase.c
160+++ b/misc-utils/flash_erase.c
161@@ -53,8 +53,8 @@ int target_endian = __BYTE_ORDER;
162 static void show_progress(struct mtd_dev_info *mtd, off_t start, int eb,
163 int eb_start, int eb_cnt)
164 {
165- bareverbose(!quiet, "\rErasing %d Kibyte @ %"PRIxoff_t" -- %2i %% complete ",
166- mtd->eb_size / 1024, start, ((eb - eb_start) * 100) / eb_cnt);
167+ bareverbose(!quiet, "\rErasing %d Kibyte @ %llx -- %2i %% complete ",
168+ mtd->eb_size / 1024, (unsigned long long)start, ((eb - eb_start) * 100) / eb_cnt);
169 fflush(stdout);
170 }
171
172@@ -210,7 +210,7 @@ int main(int argc, char *argv[])
173 if (!noskipbad) {
174 int ret = mtd_is_bad(&mtd, fd, eb);
175 if (ret > 0) {
176- verbose(!quiet, "Skipping bad block at %08"PRIxoff_t, offset);
177+ verbose(!quiet, "Skipping bad block at %08llx", (unsigned long long)offset);
178 continue;
179 } else if (ret < 0) {
180 if (errno == EOPNOTSUPP) {
181diff --git a/misc-utils/flash_otp_write.c b/misc-utils/flash_otp_write.c
182index b02d0b0..04c96c6 100644
183--- a/misc-utils/flash_otp_write.c
184+++ b/misc-utils/flash_otp_write.c
185@@ -76,7 +76,7 @@ int main(int argc,char *argv[])
186 return errno;
187 }
188
189- printf("Writing OTP user data on %s at offset 0x%"PRIxoff_t"\n", argv[2], offset);
190+ printf("Writing OTP user data on %s at offset 0x%llx\n", argv[2], (unsigned long long)offset);
191
192 if (mtd_type_is_nand_user(&mtdInfo))
193 len = mtdInfo.writesize;
194diff --git a/misc-utils/ftl_check.c b/misc-utils/ftl_check.c
195index a853cf4..e854922 100644
196--- a/misc-utils/ftl_check.c
197+++ b/misc-utils/ftl_check.c
198@@ -131,7 +131,7 @@ static void check_partition(int fd)
199 perror("read failed");
200 break;
201 }
202- printf("\nErase unit %"PRIdoff_t":\n", i);
203+ printf("\nErase unit %lld:\n", (long long)i);
204 if ((hdr2.FormattedSize != hdr.FormattedSize) ||
205 (hdr2.NumEraseUnits != hdr.NumEraseUnits) ||
206 (hdr2.SerialNumber != hdr.SerialNumber))
207diff --git a/misc-utils/mtd_debug.c b/misc-utils/mtd_debug.c
208index ac37e23..d65ad36 100644
209--- a/misc-utils/mtd_debug.c
210+++ b/misc-utils/mtd_debug.c
211@@ -160,7 +160,7 @@ retry:
212 if (buf != NULL)
213 free(buf);
214 close(outfd);
215- printf("Copied %zu bytes from address 0x%.8"PRIxoff_t" in flash to %s\n", len, offset, filename);
216+ printf("Copied %zu bytes from address 0x%.8llx in flash to %s\n", len, (unsigned long long)offset, filename);
217 return 0;
218
219 err2:
220@@ -225,7 +225,7 @@ retry:
221 if (buf != NULL)
222 free(buf);
223 fclose(fp);
224- printf("Copied %d bytes from %s to address 0x%.8"PRIxoff_t" in flash\n", len, filename, offset);
225+ printf("Copied %d bytes from %s to address 0x%.8llx in flash\n", len, filename, (unsigned long long)offset);
226 return 0;
227 }
228
229diff --git a/misc-utils/serve_image.c b/misc-utils/serve_image.c
230index f2475d6..6c8c8fb 100644
231--- a/misc-utils/serve_image.c
232+++ b/misc-utils/serve_image.c
233@@ -129,8 +129,8 @@ int main(int argc, char **argv)
234 }
235
236 if (st.st_size % erasesize) {
237- fprintf(stderr, "Image size %" PRIdoff_t " bytes is not a multiple of erasesize %d bytes\n",
238- st.st_size, erasesize);
239+ fprintf(stderr, "Image size %lld bytes is not a multiple of erasesize %d bytes\n",
240+ (long long)st.st_size, erasesize);
241 exit(1);
242 }
243 image = mmap(NULL, st.st_size, PROT_READ, MAP_PRIVATE, rfd, 0);
244diff --git a/tests/fs-tests/integrity/integck.c b/tests/fs-tests/integrity/integck.c
245index 84753d6..0a7f142 100644
246--- a/tests/fs-tests/integrity/integck.c
247+++ b/tests/fs-tests/integrity/integck.c
248@@ -897,8 +897,8 @@ static ssize_t file_write_data(struct file_info *file, int fd, off_t offset,
249 remains = size;
250 actual = 0;
251 written = IO_BUFFER_SIZE;
252- v("write %zd bytes, offset %"PRIdoff_t", file %s",
253- size, offset, get_file_name(file));
254+ v("write %zd bytes, offset %lld, file %s",
255+ size, (long long)offset, get_file_name(file));
256 while (remains) {
257 /* Fill up buffer with random data */
258 if (written < IO_BUFFER_SIZE) {
259diff --git a/tests/mtd-tests/nandpagetest.c b/tests/mtd-tests/nandpagetest.c
260index c6812df..465e548 100644
261--- a/tests/mtd-tests/nandpagetest.c
262+++ b/tests/mtd-tests/nandpagetest.c
263@@ -232,8 +232,8 @@ static int verify_eraseblock(int ebnum)
264 return err;
265
266 if (lseek(fd, addr, SEEK_SET) != addr) {
267- fprintf(stderr, "cannot seek mtd%d to offset %"PRIdloff_t,
268- mtd.mtd_num, addr);
269+ fprintf(stderr, "cannot seek mtd%d to offset %lld",
270+ mtd.mtd_num, (long long)addr);
271 return -1;
272 }
273
274diff --git a/tests/ubi-tests/integ.c b/tests/ubi-tests/integ.c
275index 26c2ce5..1cd0649 100644
276--- a/tests/ubi-tests/integ.c
277+++ b/tests/ubi-tests/integ.c
278@@ -243,7 +243,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
279 while (size)
280 if (read_buffer[--size] != 0xff) {
281 fprintf(stderr, "block no. = %d\n" , erase_block->block_number);
282- fprintf(stderr, "offset = %"PRIdoff_t"\n" , gap_start);
283+ fprintf(stderr, "offset = %lld\n" , (long long)gap_start);
284 fprintf(stderr, "size = %ld\n" , (long) bytes_read);
285 error_exit("verify 0xff failed");
286 }
287@@ -254,7 +254,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
288 errno = 0;
289 bytes_read = read(fd, read_buffer, w->size);
290 if (bytes_read != w->size) {
291- fprintf(stderr, "offset = %"PRIdoff_t"\n" , w->offset);
292+ fprintf(stderr, "offset = %lld\n" , (long long)w->offset);
293 fprintf(stderr, "size = %ld\n" , (long) w->size);
294 fprintf(stderr, "bytes_read = %ld\n" , (long) bytes_read);
295 error_exit("read failed");
296@@ -279,7 +279,7 @@ static void check_erase_block(struct erase_block_info *erase_block, int fd)
297 while (size)
298 if (read_buffer[--size] != 0xff) {
299 fprintf(stderr, "block no. = %d\n" , erase_block->block_number);
300- fprintf(stderr, "offset = %"PRIdoff_t"\n" , gap_start);
301+ fprintf(stderr, "offset = %lld\n" , (long long)gap_start);
302 fprintf(stderr, "size = %ld\n" , (long) bytes_read);
303 error_exit("verify 0xff failed!");
304 }
305diff --git a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
306index c916f48..f0237ab 100644
307--- a/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
308+++ b/ubifs-utils/mkfs.ubifs/mkfs.ubifs.c
309@@ -772,11 +772,11 @@ int write_leb(int lnum, int len, void *buf)
310 return sys_err_msg("ubi_leb_change_start failed");
311
312 if (lseek(out_fd, pos, SEEK_SET) != pos)
313- return sys_err_msg("lseek failed seeking %"PRIdoff_t, pos);
314+ return sys_err_msg("lseek failed seeking %lld", (long long)pos);
315
316 if (write(out_fd, buf, c->leb_size) != c->leb_size)
317- return sys_err_msg("write failed writing %d bytes at pos %"PRIdoff_t,
318- c->leb_size, pos);
319+ return sys_err_msg("write failed writing %d bytes at pos %lld",
320+ c->leb_size, (long long)pos);
321
322 return 0;
323 }
324--
3252.7.4
326
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0003-Makefile.am-only-build-ubi-utils.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0003-Makefile.am-only-build-ubi-utils.patch
new file mode 100644
index 000000000..08c53d18a
--- /dev/null
+++ b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0003-Makefile.am-only-build-ubi-utils.patch
@@ -0,0 +1,34 @@
1From 139d93bc405272a3261d57be26da842e737fe4d0 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Sun, 28 Jan 2018 23:10:34 +0100
4Subject: [PATCH 3/4] Makefile.am: only build ubi-utils
5
6We only target the ubi-utils, static, small.
7
8Upstream-Status: Inappropriate [embedded specific]
9
10Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
11---
12 Makefile.am | 6 +++---
13 1 file changed, 3 insertions(+), 3 deletions(-)
14
15diff --git a/Makefile.am b/Makefile.am
16index 5a6e77c..98715dd 100644
17--- a/Makefile.am
18+++ b/Makefile.am
19@@ -34,9 +34,9 @@ EXTRA_DIST += $(GLOBAL_HEADER) $(GLOBAL_EXTRA)
20
21 include lib/Makemodule.am
22 include ubi-utils/Makemodule.am
23-include misc-utils/Makemodule.am
24-include nand-utils/Makemodule.am
25-include nor-utils/Makemodule.am
26+#include misc-utils/Makemodule.am
27+#include nand-utils/Makemodule.am
28+#include nor-utils/Makemodule.am
29
30 if BUILD_UBIFS
31 include ubifs-utils/Makemodule.am
32--
332.7.4
34
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0004-mtd-utils-common.h-no-features.h-for-klibc-builds.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0004-mtd-utils-common.h-no-features.h-for-klibc-builds.patch
new file mode 100644
index 000000000..5da05fa48
--- /dev/null
+++ b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0004-mtd-utils-common.h-no-features.h-for-klibc-builds.patch
@@ -0,0 +1,38 @@
1From ae1cf6d0eb1833e46549328a4473222c259723d7 Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Thu, 1 Feb 2018 00:25:00 +0100
4Subject: [PATCH 4/4] mtd-utils: common.h: no features.h for klibc builds
5
6Add guard around features.h to fix missing include (here first error):
7
8 ../git/include/common.h:29:10:
9 fatal error: features.h: No such file or directory
10 #include <features.h>
11 ^~~~~~~~~~~~
12 compilation terminated
13
14Upstream-Status: Submitted
15
16Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
17---
18 include/common.h | 3 +++
19 1 file changed, 3 insertions(+)
20
21diff --git a/include/common.h b/include/common.h
22index 642c212..f7c71fe 100644
23--- a/include/common.h
24+++ b/include/common.h
25@@ -26,7 +26,10 @@
26 #include <string.h>
27 #include <fcntl.h>
28 #include <errno.h>
29+#if defined(__KLIBC__)
30+#else
31 #include <features.h>
32+#endif
33 #include <inttypes.h>
34 #include <unistd.h>
35 #include <sys/sysmacros.h>
36--
372.7.4
38
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch
new file mode 100644
index 000000000..adef377b8
--- /dev/null
+++ b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc-2.0.2/0005-common.h-replace-getline-with-fgets.patch
@@ -0,0 +1,56 @@
1From 2137eb1a6cd0326510bd3b9faf8037d9bf34ca3d Mon Sep 17 00:00:00 2001
2From: Andrea Adami <andrea.adami@gmail.com>
3Date: Wed, 23 May 2018 15:52:34 +0200
4Subject: [PATCH 5/5] common.h: replace getline() with fgets
5
6There is an unofficial upstream patch adding a simple getline()
7to libmissing.h. Unfortunately the patch creates issues if the
8toolchain is using glibc (autotools cache?) so for the moment
9keep the old hack and wait for commits upstream.
10
11Fix:
12
13| ubi-utils/ubiformat.o: In function `prompt.constprop.4':
14| ubiformat.c:(.text+0x70): undefined reference to `getline'
15
16Upstrea-Status: Inappropriate [klibc specific]
17
18Signed-off-by: Andrea Adami <andrea.adami@gmail.com>
19---
20 include/common.h | 11 +++++++++++
21 1 file changed, 11 insertions(+)
22
23diff --git a/include/common.h b/include/common.h
24index a1d59d0..96b0bdb 100644
25--- a/include/common.h
26+++ b/include/common.h
27@@ -126,15 +126,26 @@ extern "C" {
28 */
29 static inline bool prompt(const char *msg, bool def)
30 {
31+
32+#ifndef __KLIBC__
33 char *line = NULL;
34 size_t len;
35+#else
36+ char *line;
37+ const int sizeof_line = 2;
38+ line = malloc(sizeof_line);
39+#endif
40 bool ret = def;
41
42 do {
43 normsg_cont("%s (%c/%c) ", msg, def ? 'Y' : 'y', def ? 'n' : 'N');
44 fflush(stdout);
45
46+#ifndef __KLIBC__
47 while (getline(&line, &len, stdin) == -1) {
48+#else
49+ while (fgets(line, sizeof_line, stdin) == NULL) {
50+#endif
51 printf("failed to read prompt; assuming '%s'\n",
52 def ? "yes" : "no");
53 break;
54--
552.7.4
56
diff --git a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.2.bb b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_2.0.2.bb
index abb0d4b84..8b0098123 100644
--- a/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_1.5.2.bb
+++ b/meta-initramfs/recipes-devtools/mtd/ubi-utils-klibc_2.0.2.bb
@@ -7,30 +7,31 @@ LICENSE = "GPLv2+"
7LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \ 7LIC_FILES_CHKSUM = "file://COPYING;md5=0636e73ff0215e8d672dc4c32c317bb3 \
8 file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c" 8 file://include/common.h;beginline=1;endline=17;md5=ba05b07912a44ea2bf81ce409380049c"
9 9
10inherit klibc 10inherit autotools pkgconfig klibc
11 11
12SRCREV = "aea36417067dade75192bafa03af70b6eb2677b1" 12SRCREV = "bc63d36e39f389c8c17f6a8e9db47f2acc884659"
13SRC_URI = "git://git.infradead.org/mtd-utils.git \ 13SRC_URI = "git://git.infradead.org/mtd-utils.git \
14 file://0001-Makefile-build-ubi-utils-only.patch \ 14 file://0001-libmissing.h-fix-klibc-build-when-using-glibc-toolch.patch \
15 file://0002-common.mk-for-klibc-CC-is-klcc.patch \ 15 file://0002-Instead-of-doing-preprocessor-magic-just-output-off_.patch \
16 file://0003-libubi.c-add-klibc-specific-fixes-for-ioctl.patch \ 16 file://0003-Makefile.am-only-build-ubi-utils.patch \
17 file://0004-Restore-compatibility-to-dietlibc-klibc-musl-libc-af.patch \ 17 file://0004-mtd-utils-common.h-no-features.h-for-klibc-builds.patch \
18 file://0005-common.h-more-workarounds-for-klibc-compatibility.patch \ 18 file://0005-common.h-replace-getline-with-fgets.patch \
19 file://0006-libiniparser-remove-unused-function-needing-float.patch \
20 file://0007-mtd-utils-common.c-convert-to-integer-arithmetic.patch \
21 file://0008-ubi-utils-ubiformat.c-convert-to-integer-arithmetic.patch \
22 file://0009-Eliminate-warnings-about-implicit-non-const-casting-.patch \
23 " 19 "
24 20
25S = "${WORKDIR}/git/" 21S = "${WORKDIR}/git/"
26 22
27EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} -I${S}include -DWITHOUT_XATTR' 'BUILDDIR=${S}'" 23EXTRA_OECONF += "--disable-tests --without-jffs --without-ubifs"
24
25PACKAGECONFIG ?= "${@bb.utils.filter('DISTRO_FEATURES', 'xattr', d)}"
26PACKAGECONFIG[xattr] = ",,acl,"
27
28EXTRA_OEMAKE = "'CC=${CC}' 'RANLIB=${RANLIB}' 'AR=${AR}' 'CFLAGS=${CFLAGS} ${@bb.utils.contains('PACKAGECONFIG', 'xattr', '', '-DWITHOUT_XATTR', d)} -I${S}/include' 'BUILDDIR=${S}'"
28 29
29do_install () { 30do_install () {
30 oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir} 31 oe_runmake install DESTDIR=${D} SBINDIR=${sbindir} MANDIR=${mandir} INCLUDEDIR=${includedir}
31} 32}
32 33
33PACKAGES = "ubi-utils-klibc-dbg" 34PACKAGES = "ubi-utils-klibc-dbg ubi-utils-klibc-doc"
34 35
35PACKAGES =+ "mtdinfo-klibc ubiattach-klibc ubiblock-klibc ubicrc32-klibc ubidetach-klibc \ 36PACKAGES =+ "mtdinfo-klibc ubiattach-klibc ubiblock-klibc ubicrc32-klibc ubidetach-klibc \
36 ubiformat-klibc ubimkvol-klibc ubinfo-klibc ubinize-klibc ubirename-klibc \ 37 ubiformat-klibc ubimkvol-klibc ubinfo-klibc ubinize-klibc ubirename-klibc \