aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorAlexandros C. Couloumbis <alex@ozo.com>2010-10-01 16:39:08 +0000
committerAlexandros C. Couloumbis <alex@ozo.com>2010-10-01 16:39:08 +0000
commit930031c5d10ce5c4e15979ee0547eb2399709bc7 (patch)
tree42aae04dff446edc875829bc04f650da6211b7a6 /tools
parent42a49519f011d2531099fc68ce764c82c4dd84c8 (diff)
downloadupstream-930031c5d10ce5c4e15979ee0547eb2399709bc7.tar.gz
upstream-930031c5d10ce5c4e15979ee0547eb2399709bc7.tar.bz2
upstream-930031c5d10ce5c4e15979ee0547eb2399709bc7.zip
tools/mtd-utils: update to mtd-utils-20101001, fix FreeBSD (and hopefully Darwin) build issues.
SVN-Revision: 23169
Diffstat (limited to 'tools')
-rw-r--r--tools/mtd-utils/Makefile10
-rw-r--r--tools/mtd-utils/patches/100-optional_lzo.patch21
-rw-r--r--tools/mtd-utils/patches/101-ubifs-optional_lzo.patch29
-rw-r--r--tools/mtd-utils/patches/110-portability.patch10
-rw-r--r--tools/mtd-utils/patches/120-cygwin_fixes.patch8
-rw-r--r--tools/mtd-utils/patches/130-lzma_jffs2.patch17
-rw-r--r--tools/mtd-utils/patches/131-fix_lib_compile.patch11
-rw-r--r--tools/mtd-utils/patches/132-revert-zlib-cleanup.patch210
-rw-r--r--tools/mtd-utils/patches/133-error-fix.patch20
-rw-r--r--tools/mtd-utils/patches/134-freebsd_loff_t.patch13
10 files changed, 293 insertions, 56 deletions
diff --git a/tools/mtd-utils/Makefile b/tools/mtd-utils/Makefile
index 45bceaf837..7d597af901 100644
--- a/tools/mtd-utils/Makefile
+++ b/tools/mtd-utils/Makefile
@@ -7,14 +7,14 @@
include $(TOPDIR)/rules.mk
PKG_NAME:=mtd
-PKG_VERSION:=20090505
+PKG_VERSION:=20101001
PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=git://git.infradead.org/mtd-utils.git
PKG_SOURCE_PROTO:=git
-PKG_SOURCE_VERSION:=d021e049efaff50de33819b8cd2835d4b79bcfa8
+PKG_SOURCE_VERSION:=e2ddf154e1050faea5a24cf44345aec0d715a8c9
PKG_SOURCE_SUBDIR:=$(PKG_NAME)-$(PKG_VERSION)
-PKG_MD5SUM:=1f42c2cae08eb9e7b52d0c188f8d6338
+PKG_MD5SUM:=fd168f4e41614e2a819f4e49e83431bc
PKG_CAT:=zcat
HOST_BUILD_DIR:=$(BUILD_DIR_HOST)/$(PKG_NAME)-$(PKG_VERSION)
@@ -36,6 +36,10 @@ define Host/Compile
$(MAKE) -C $(HOST_BUILD_DIR) \
$(MTD_MAKEOPTS) \
TARGETS=mkfs.jffs2
+ $(MAKE) -C $(HOST_BUILD_DIR)/lib \
+ $(MTD_MAKEOPTS) \
+ TARGETS="libmtd.a libcrc32.a" \
+ LIBS="libmtd libcrc32"
$(MAKE) -C $(HOST_BUILD_DIR)/ubi-utils \
$(MTD_MAKEOPTS) \
TARGETS=ubinize
diff --git a/tools/mtd-utils/patches/100-optional_lzo.patch b/tools/mtd-utils/patches/100-optional_lzo.patch
index d9ebc3e9b4..5af0ae23e1 100644
--- a/tools/mtd-utils/patches/100-optional_lzo.patch
+++ b/tools/mtd-utils/patches/100-optional_lzo.patch
@@ -1,15 +1,14 @@
--- a/Makefile
+++ b/Makefile
-@@ -36,10 +36,16 @@ $(SYMLINKS):
+@@ -42,10 +42,15 @@ $(SYMLINKS):
ln -sf ../fs/jffs2/$@ $@
$(BUILDDIR)/mkfs.jffs2: $(addprefix $(BUILDDIR)/,\
-- crc32.o compr_rtime.o mkfs.jffs2.o compr_zlib.o compr_lzo.o \
-+ crc32.o compr_rtime.o mkfs.jffs2.o compr_zlib.o $(if $(NO_LZO),,compr_lzo.o) \
+- compr_rtime.o mkfs.jffs2.o compr_zlib.o compr_lzo.o \
++ compr_rtime.o mkfs.jffs2.o compr_zlib.o $(if $(NO_LZO),,compr_lzo.o) \
compr.o rbtree.o)
-LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
-LDLIBS_mkfs.jffs2 = -lz -llzo2
-+
+LDFLAGS_mkfs.jffs2 := $(ZLIBLDFLAGS)
+LDLIBS_mkfs.jffs2 := -lz
+ifndef NO_LZO
@@ -18,15 +17,5 @@
+CPPFLAGS += -DCONFIG_JFFS2_LZO
+endif
- $(BUILDDIR)/flash_eraseall: $(BUILDDIR)/crc32.o $(BUILDDIR)/flash_eraseall.o
-
---- a/compr.h
-+++ b/compr.h
-@@ -18,7 +18,6 @@
-
- #define CONFIG_JFFS2_ZLIB
- #define CONFIG_JFFS2_RTIME
--#define CONFIG_JFFS2_LZO
-
- #define JFFS2_RUBINMIPS_PRIORITY 10
- #define JFFS2_DYNRUBIN_PRIORITY 20
+ $(BUILDDIR)/jffs2reader: $(BUILDDIR)/jffs2reader.o
+ LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
diff --git a/tools/mtd-utils/patches/101-ubifs-optional_lzo.patch b/tools/mtd-utils/patches/101-ubifs-optional_lzo.patch
index d49c94bb28..9f797e01b7 100644
--- a/tools/mtd-utils/patches/101-ubifs-optional_lzo.patch
+++ b/tools/mtd-utils/patches/101-ubifs-optional_lzo.patch
@@ -2,48 +2,47 @@ diff --git a/mkfs.ubifs/Makefile b/mkfs.ubifs/Makefile
index a678b0a..919ce89 100644
--- a/mkfs.ubifs/Makefile
+++ b/mkfs.ubifs/Makefile
-@@ -5,7 +5,7 @@ ALL_SOURCES=*.[ch] hashtable/*.[ch]
+@@ -6,7 +6,7 @@ ALL_SOURCES=*.[ch] hashtable/*.[ch]
TARGETS = mkfs.ubifs
--LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid -L../ubi-utils/ -lubi
-+LDLIBS_mkfs.ubifs = -lz $(if,$(NO_LZO),,-llzo2) -lm -luuid -L../ubi-utils/ -lubi
-
- include ../common.mk
+-LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
++LDLIBS_mkfs.ubifs = -lz $(if,$(NO_LZO),,-llzo2) -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
+ LDLIBS_mkfs.ubifs += -L$(BUILDDIR)/../lib -lmtd -lcrc32
+ LDLIBS_mkfs.ubifs += $(ZLIBLDFLAGS) $(LZOLDFLAGS)
diff --git a/mkfs.ubifs/compr.c b/mkfs.ubifs/compr.c
index e378c5d..0208f80 100644
--- a/mkfs.ubifs/compr.c
+++ b/mkfs.ubifs/compr.c
-@@ -25,7 +25,9 @@
+@@ -24,7 +24,9 @@
+ #include <stdio.h>
#include <stdint.h>
#include <string.h>
- #include <zlib.h>
+#if CONFIG_UBIFS_LZO
#include <lzo/lzo1x.h>
+#endif
#include <linux/types.h>
- #include "compr.h"
-@@ -83,6 +85,17 @@ static int zlib_deflate(void *in_buf, size_t in_len, void *out_buf,
+ #define crc32 __zlib_crc32
+@@ -85,6 +87,16 @@ static int zlib_deflate(void *in_buf, si
return 0;
}
+static int no_compress(void *in_buf, size_t in_len, void *out_buf,
-+ size_t *out_len)
++ size_t *out_len)
+{
+ memcpy(out_buf, in_buf, in_len);
+ *out_len = in_len;
+ return 0;
+}
+
-+
+#if CONFIG_UBIFS_LZO
+
static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
size_t *out_len)
{
-@@ -101,14 +114,16 @@ static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
+@@ -103,14 +115,16 @@ static int lzo_compress(void *in_buf, si
return 0;
}
@@ -57,7 +56,7 @@ index e378c5d..0208f80 100644
- memcpy(out_buf, in_buf, in_len);
- *out_len = in_len;
- return 0;
-+ return -1;
++ return 1;
}
+#endif
@@ -65,7 +64,7 @@ index e378c5d..0208f80 100644
static char *zlib_buf;
static int favor_lzo_compress(void *in_buf, size_t in_len, void *out_buf,
-@@ -195,9 +210,11 @@ int compress_data(void *in_buf, size_t in_len, void *out_buf, size_t *out_len,
+@@ -197,9 +211,11 @@ int compress_data(void *in_buf, size_t i
int init_compression(void)
{
@@ -77,7 +76,7 @@ index e378c5d..0208f80 100644
zlib_buf = malloc(UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR);
if (!zlib_buf) {
-@@ -211,7 +228,9 @@ int init_compression(void)
+@@ -213,7 +229,9 @@ int init_compression(void)
void destroy_compression(void)
{
free(zlib_buf);
diff --git a/tools/mtd-utils/patches/110-portability.patch b/tools/mtd-utils/patches/110-portability.patch
index d35b446587..43b4faaca6 100644
--- a/tools/mtd-utils/patches/110-portability.patch
+++ b/tools/mtd-utils/patches/110-portability.patch
@@ -30,16 +30,6 @@
struct rb_node
{
-@@ -131,7 +130,9 @@ static inline void rb_set_color(struct r
-
- #define RB_ROOT (struct rb_root) { NULL, }
-
-+#ifndef offsetof
- #define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER)
-+#endif
-
- #define container_of(ptr, type, member) ({ \
- const typeof( ((type *)0)->member ) *__mptr = (ptr); \
--- a/include/mtd/ubi-media.h
+++ b/include/mtd/ubi-media.h
@@ -30,7 +30,15 @@
diff --git a/tools/mtd-utils/patches/120-cygwin_fixes.patch b/tools/mtd-utils/patches/120-cygwin_fixes.patch
index 61a6d5ef2d..2b6cafedd3 100644
--- a/tools/mtd-utils/patches/120-cygwin_fixes.patch
+++ b/tools/mtd-utils/patches/120-cygwin_fixes.patch
@@ -9,10 +9,10 @@
+endif
+
+ifneq ($(shell uname -o),Cygwin)
- SUBDIRS = ubi-utils mkfs.ubifs
+ SUBDIRS = lib ubi-utils mkfs.ubifs
- TARGETS = ftl_format flash_erase flash_eraseall nanddump doc_loadbios \
-@@ -17,6 +22,10 @@ TARGETS = ftl_format flash_erase flash_e
+ TARGETS = ftl_format flash_erase nanddump doc_loadbios \
+@@ -17,6 +22,10 @@ TARGETS = ftl_format flash_erase nanddum
rfddump rfdformat \
serve_image recv_image \
sumtool #jffs2reader
@@ -20,9 +20,9 @@
+SUBDIRS =
+TARGETS = mkfs.jffs2
+endif
+ SCRIPTS = flash_eraseall
SYMLINKS =
-
--- /dev/null
+++ b/include/cygwin/bits-byteswap.h
@@ -0,0 +1,132 @@
diff --git a/tools/mtd-utils/patches/130-lzma_jffs2.patch b/tools/mtd-utils/patches/130-lzma_jffs2.patch
index 0f2b8af561..d75ad31397 100644
--- a/tools/mtd-utils/patches/130-lzma_jffs2.patch
+++ b/tools/mtd-utils/patches/130-lzma_jffs2.patch
@@ -1,5 +1,5 @@
--- a/Makefile
-+++ b/Makefile
++++ b/Makefile
@@ -1,7 +1,7 @@
# -*- sh -*-
@@ -9,17 +9,17 @@
ifeq ($(WITHOUT_XATTR), 1)
CPPFLAGS += -DWITHOUT_XATTR
-@@ -45,7 +45,9 @@
+@@ -51,7 +51,9 @@ $(SYMLINKS):
ln -sf ../fs/jffs2/$@ $@
$(BUILDDIR)/mkfs.jffs2: $(addprefix $(BUILDDIR)/,\
-- crc32.o compr_rtime.o mkfs.jffs2.o compr_zlib.o $(if $(NO_LZO),,compr_lzo.o) \
-+ crc32.o compr_rtime.o mkfs.jffs2.o compr_zlib.o \
+- compr_rtime.o mkfs.jffs2.o compr_zlib.o $(if $(NO_LZO),,compr_lzo.o) \
++ compr_rtime.o mkfs.jffs2.o compr_zlib.o \
+ $(if $(NO_LZO),,compr_lzo.o) \
-+ compr_lzma.o lzma/LzFind.o lzma/LzmaEnc.o lzma/LzmaDec.o\
++ compr_lzma.o lzma/LzFind.o lzma/LzmaEnc.o lzma/LzmaDec.o \
compr.o rbtree.o)
-
LDFLAGS_mkfs.jffs2 := $(ZLIBLDFLAGS)
+ LDLIBS_mkfs.jffs2 := -lz
--- a/compr.c 2009-06-05 16:59:08.000000000 +0200
+++ b/compr.c 2010-03-20 23:16:14.556367000 +0100
@@ -520,6 +520,9 @@
@@ -43,10 +43,11 @@
}
--- a/compr.h 2010-03-20 23:08:46.289595000 +0100
+++ b/compr.h 2010-03-20 23:51:41.953345921 +0100
-@@ -18,12 +18,14 @@
+@@ -18,13 +18,14 @@
#define CONFIG_JFFS2_ZLIB
#define CONFIG_JFFS2_RTIME
+-#define CONFIG_JFFS2_LZO
+#define CONFIG_JFFS2_LZMA
#define JFFS2_RUBINMIPS_PRIORITY 10
@@ -60,7 +61,7 @@
#define JFFS2_COMPR_MODE_NONE 0
#define JFFS2_COMPR_MODE_PRIORITY 1
-@@ -114,5 +116,10 @@
+@@ -115,5 +116,10 @@ void jffs2_rtime_exit(void);
int jffs2_lzo_init(void);
void jffs2_lzo_exit(void);
#endif
diff --git a/tools/mtd-utils/patches/131-fix_lib_compile.patch b/tools/mtd-utils/patches/131-fix_lib_compile.patch
new file mode 100644
index 0000000000..f40a5b6c56
--- /dev/null
+++ b/tools/mtd-utils/patches/131-fix_lib_compile.patch
@@ -0,0 +1,11 @@
+--- a/Makefile
++++ b/Makefile
+@@ -68,8 +68,6 @@ $(BUILDDIR)/jffs2reader: $(BUILDDIR)/jff
+ LDFLAGS_jffs2reader = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
+ LDLIBS_jffs2reader = -lz -llzo2
+
+-$(BUILDDIR)/lib/libmtd.a: subdirs_lib_all ;
+-
+ install:: ${TARGETS} ${SCRIPTS}
+ mkdir -p ${DESTDIR}/${SBINDIR}
+ install -m 0755 ${TARGETS} ${SCRIPTS} ${DESTDIR}/${SBINDIR}/
diff --git a/tools/mtd-utils/patches/132-revert-zlib-cleanup.patch b/tools/mtd-utils/patches/132-revert-zlib-cleanup.patch
new file mode 100644
index 0000000000..d9ee178b01
--- /dev/null
+++ b/tools/mtd-utils/patches/132-revert-zlib-cleanup.patch
@@ -0,0 +1,210 @@
+diff -Nrup a/compr_zlib.c b/compr_zlib.c
+--- a/compr_zlib.c
++++ b/compr_zlib.c
+@@ -35,9 +35,7 @@
+ #define PROGRAM_NAME "compr_zlib"
+
+ #include <stdint.h>
+-#define crc32 __zlib_crc32
+ #include <zlib.h>
+-#undef crc32
+ #include <stdio.h>
+ #include <linux/jffs2.h>
+ #include "common.h"
+diff -Nrup a/jffs2reader.c b/jffs2reader.c
+--- a/jffs2reader.c
++++ b/jffs2reader.c
+@@ -76,6 +76,7 @@ BUGS:
+ #include <sys/stat.h>
+ #include <sys/param.h>
+ #include <dirent.h>
++#include <zlib.h>
+ #include <linux/jffs2.h>
+
+ #define SCRATCH_SIZE (5*1024*1024)
+diff -Nrup a/mkfs.jffs2.c b/mkfs.jffs2.c
+--- a/mkfs.jffs2.c
++++ b/mkfs.jffs2.c
+@@ -71,6 +71,9 @@
+ #include <sys/acl.h>
+ #endif
+ #include <byteswap.h>
++#define crc32 __zlib_crc32
++#include <zlib.h>
++#undef crc32
+ #include <crc32.h>
+ #include "rbtree.h"
+
+@@ -725,7 +728,7 @@ static void write_dirent(struct filesyst
+ rd.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
+ rd.nodetype = cpu_to_je16(JFFS2_NODETYPE_DIRENT);
+ rd.totlen = cpu_to_je32(sizeof(rd) + strlen(name));
+- rd.hdr_crc = cpu_to_je32(mtd_crc32(0, &rd,
++ rd.hdr_crc = cpu_to_je32(crc32(0, &rd,
+ sizeof(struct jffs2_unknown_node) - 4));
+ rd.pino = cpu_to_je32((e->parent) ? e->parent->ino : 1);
+ rd.version = cpu_to_je32(version++);
+@@ -735,8 +738,8 @@ static void write_dirent(struct filesyst
+ rd.type = IFTODT(statbuf->st_mode);
+ //rd.unused[0] = 0;
+ //rd.unused[1] = 0;
+- rd.node_crc = cpu_to_je32(mtd_crc32(0, &rd, sizeof(rd) - 8));
+- rd.name_crc = cpu_to_je32(mtd_crc32(0, name, strlen(name)));
++ rd.node_crc = cpu_to_je32(crc32(0, &rd, sizeof(rd) - 8));
++ rd.name_crc = cpu_to_je32(crc32(0, name, strlen(name)));
+
+ pad_block_if_less_than(sizeof(rd) + rd.nsize);
+ full_write(out_fd, &rd, sizeof(rd));
+@@ -822,15 +825,15 @@ static unsigned int write_regular_file(s
+ }
+
+ ri.totlen = cpu_to_je32(sizeof(ri) + space);
+- ri.hdr_crc = cpu_to_je32(mtd_crc32(0,
++ ri.hdr_crc = cpu_to_je32(crc32(0,
+ &ri, sizeof(struct jffs2_unknown_node) - 4));
+
+ ri.version = cpu_to_je32(++ver);
+ ri.offset = cpu_to_je32(offset);
+ ri.csize = cpu_to_je32(space);
+ ri.dsize = cpu_to_je32(dsize);
+- ri.node_crc = cpu_to_je32(mtd_crc32(0, &ri, sizeof(ri) - 8));
+- ri.data_crc = cpu_to_je32(mtd_crc32(0, wbuf, space));
++ ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri) - 8));
++ ri.data_crc = cpu_to_je32(crc32(0, wbuf, space));
+
+ full_write(out_fd, &ri, sizeof(ri));
+ totcomp += sizeof(ri);
+@@ -855,11 +858,11 @@ static unsigned int write_regular_file(s
+
+ ri.version = cpu_to_je32(++ver);
+ ri.totlen = cpu_to_je32(sizeof(ri));
+- ri.hdr_crc = cpu_to_je32(mtd_crc32(0,
++ ri.hdr_crc = cpu_to_je32(crc32(0,
+ &ri, sizeof(struct jffs2_unknown_node) - 4));
+ ri.csize = cpu_to_je32(0);
+ ri.dsize = cpu_to_je32(0);
+- ri.node_crc = cpu_to_je32(mtd_crc32(0, &ri, sizeof(ri) - 8));
++ ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri) - 8));
+
+ full_write(out_fd, &ri, sizeof(ri));
+ padword();
+@@ -894,7 +897,7 @@ static void write_symlink(struct filesys
+ ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
+ ri.nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
+ ri.totlen = cpu_to_je32(sizeof(ri) + len);
+- ri.hdr_crc = cpu_to_je32(mtd_crc32(0,
++ ri.hdr_crc = cpu_to_je32(crc32(0,
+ &ri, sizeof(struct jffs2_unknown_node) - 4));
+
+ ri.ino = cpu_to_je32(e->ino);
+@@ -908,8 +911,8 @@ static void write_symlink(struct filesys
+ ri.version = cpu_to_je32(1);
+ ri.csize = cpu_to_je32(len);
+ ri.dsize = cpu_to_je32(len);
+- ri.node_crc = cpu_to_je32(mtd_crc32(0, &ri, sizeof(ri) - 8));
+- ri.data_crc = cpu_to_je32(mtd_crc32(0, e->link, len));
++ ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri) - 8));
++ ri.data_crc = cpu_to_je32(crc32(0, e->link, len));
+
+ pad_block_if_less_than(sizeof(ri) + len);
+ full_write(out_fd, &ri, sizeof(ri));
+@@ -936,7 +939,7 @@ static void write_pipe(struct filesystem
+ ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
+ ri.nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
+ ri.totlen = cpu_to_je32(sizeof(ri));
+- ri.hdr_crc = cpu_to_je32(mtd_crc32(0,
++ ri.hdr_crc = cpu_to_je32(crc32(0,
+ &ri, sizeof(struct jffs2_unknown_node) - 4));
+
+ ri.ino = cpu_to_je32(e->ino);
+@@ -950,7 +953,7 @@ static void write_pipe(struct filesystem
+ ri.version = cpu_to_je32(1);
+ ri.csize = cpu_to_je32(0);
+ ri.dsize = cpu_to_je32(0);
+- ri.node_crc = cpu_to_je32(mtd_crc32(0, &ri, sizeof(ri) - 8));
++ ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri) - 8));
+ ri.data_crc = cpu_to_je32(0);
+
+ pad_block_if_less_than(sizeof(ri));
+@@ -976,7 +979,7 @@ static void write_special_file(struct fi
+ ri.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
+ ri.nodetype = cpu_to_je16(JFFS2_NODETYPE_INODE);
+ ri.totlen = cpu_to_je32(sizeof(ri) + sizeof(kdev));
+- ri.hdr_crc = cpu_to_je32(mtd_crc32(0,
++ ri.hdr_crc = cpu_to_je32(crc32(0,
+ &ri, sizeof(struct jffs2_unknown_node) - 4));
+
+ ri.ino = cpu_to_je32(e->ino);
+@@ -990,8 +993,8 @@ static void write_special_file(struct fi
+ ri.version = cpu_to_je32(1);
+ ri.csize = cpu_to_je32(sizeof(kdev));
+ ri.dsize = cpu_to_je32(sizeof(kdev));
+- ri.node_crc = cpu_to_je32(mtd_crc32(0, &ri, sizeof(ri) - 8));
+- ri.data_crc = cpu_to_je32(mtd_crc32(0, &kdev, sizeof(kdev)));
++ ri.node_crc = cpu_to_je32(crc32(0, &ri, sizeof(ri) - 8));
++ ri.data_crc = cpu_to_je32(crc32(0, &kdev, sizeof(kdev)));
+
+ pad_block_if_less_than(sizeof(ri) + sizeof(kdev));
+ full_write(out_fd, &ri, sizeof(ri));
+@@ -1104,15 +1107,15 @@ static xattr_entry_t *create_xattr_entry
+ rx.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
+ rx.nodetype = cpu_to_je16(JFFS2_NODETYPE_XATTR);
+ rx.totlen = cpu_to_je32(PAD(sizeof(rx) + xe->name_len + 1 + xe->value_len));
+- rx.hdr_crc = cpu_to_je32(mtd_crc32(0, &rx, sizeof(struct jffs2_unknown_node) - 4));
++ rx.hdr_crc = cpu_to_je32(crc32(0, &rx, sizeof(struct jffs2_unknown_node) - 4));
+
+ rx.xid = cpu_to_je32(xe->xid);
+ rx.version = cpu_to_je32(1); /* initial version */
+ rx.xprefix = xprefix;
+ rx.name_len = xe->name_len;
+ rx.value_len = cpu_to_je16(xe->value_len);
+- rx.data_crc = cpu_to_je32(mtd_crc32(0, xe->xname, xe->name_len + 1 + xe->value_len));
+- rx.node_crc = cpu_to_je32(mtd_crc32(0, &rx, sizeof(rx) - 4));
++ rx.data_crc = cpu_to_je32(crc32(0, xe->xname, xe->name_len + 1 + xe->value_len));
++ rx.node_crc = cpu_to_je32(crc32(0, &rx, sizeof(rx) - 4));
+
+ pad_block_if_less_than(sizeof(rx) + xe->name_len + 1 + xe->value_len);
+ full_write(out_fd, &rx, sizeof(rx));
+@@ -1138,7 +1141,7 @@ static xattr_entry_t *find_xattr_entry(i
+ formalize_posix_acl(xvalue, &value_len);
+
+ name_len = strlen(xname);
+- index = (mtd_crc32(0, xname, name_len) ^ mtd_crc32(0, xvalue, value_len)) % XATTRENTRY_HASHSIZE;
++ index = (crc32(0, xname, name_len) ^ crc32(0, xvalue, value_len)) % XATTRENTRY_HASHSIZE;
+ for (xe = xentry_hash[index]; xe; xe = xe->next) {
+ if (xe->xprefix == xprefix
+ && xe->value_len == value_len
+@@ -1218,11 +1221,11 @@ static void write_xattr_entry(struct fil
+ ref.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
+ ref.nodetype = cpu_to_je16(JFFS2_NODETYPE_XREF);
+ ref.totlen = cpu_to_je32(sizeof(ref));
+- ref.hdr_crc = cpu_to_je32(mtd_crc32(0, &ref, sizeof(struct jffs2_unknown_node) - 4));
++ ref.hdr_crc = cpu_to_je32(crc32(0, &ref, sizeof(struct jffs2_unknown_node) - 4));
+ ref.ino = cpu_to_je32(e->ino);
+ ref.xid = cpu_to_je32(xe->xid);
+ ref.xseqno = cpu_to_je32(highest_xseqno += 2);
+- ref.node_crc = cpu_to_je32(mtd_crc32(0, &ref, sizeof(ref) - 4));
++ ref.node_crc = cpu_to_je32(crc32(0, &ref, sizeof(ref) - 4));
+
+ pad_block_if_less_than(sizeof(ref));
+ full_write(out_fd, &ref, sizeof(ref));
+@@ -1350,7 +1353,7 @@ static void create_target_filesystem(str
+ cleanmarker.magic = cpu_to_je16(JFFS2_MAGIC_BITMASK);
+ cleanmarker.nodetype = cpu_to_je16(JFFS2_NODETYPE_CLEANMARKER);
+ cleanmarker.totlen = cpu_to_je32(cleanmarker_size);
+- cleanmarker.hdr_crc = cpu_to_je32(mtd_crc32(0, &cleanmarker, sizeof(struct jffs2_unknown_node)-4));
++ cleanmarker.hdr_crc = cpu_to_je32(crc32(0, &cleanmarker, sizeof(struct jffs2_unknown_node)-4));
+
+ if (ino == 0)
+ ino = 1;
+diff -Nrup a/mkfs.ubifs/compr.c b/mkfs.ubifs/compr.c
+--- a/mkfs.ubifs/compr.c
++++ b/mkfs.ubifs/compr.c
+@@ -31,7 +31,6 @@
+
+ #define crc32 __zlib_crc32
+ #include <zlib.h>
+-#undef crc32
+
+ #include "compr.h"
+ #include "ubifs-media.h"
diff --git a/tools/mtd-utils/patches/133-error-fix.patch b/tools/mtd-utils/patches/133-error-fix.patch
new file mode 100644
index 0000000000..ada1ea8e44
--- /dev/null
+++ b/tools/mtd-utils/patches/133-error-fix.patch
@@ -0,0 +1,20 @@
+--- a/mkfs.jffs2.c
++++ b/mkfs.jffs2.c
+@@ -471,7 +471,7 @@ static int interpret_table_entry(struct
+ if (entry) {
+ /* Check the type */
+ if ((mode & S_IFMT) != (entry->sb.st_mode & S_IFMT)) {
+- error_msg ("skipping device_table entry '%s': type mismatch!", name);
++ sys_errmsg ("skipping device_table entry '%s': type mismatch!", name);
+ free(name);
+ free(hostpath);
+ return 1;
+@@ -487,7 +487,7 @@ static int interpret_table_entry(struct
+ }
+ } else {
+ if (type == 'f' || type == 'l') {
+- error_msg ("skipping device_table entry '%s': file does not exist!", name);
++ sys_errmsg ("skipping device_table entry '%s': file does not exist!", name);
+ free(name);
+ free(hostpath);
+ return 1;
diff --git a/tools/mtd-utils/patches/134-freebsd_loff_t.patch b/tools/mtd-utils/patches/134-freebsd_loff_t.patch
new file mode 100644
index 0000000000..805e5ff027
--- /dev/null
+++ b/tools/mtd-utils/patches/134-freebsd_loff_t.patch
@@ -0,0 +1,13 @@
+--- a/include/mtd/mtd-abi.h
++++ b/include/mtd/mtd-abi.h
+@@ -98,8 +98,8 @@
+ #define MEMGETREGIONINFO _IOWR('M', 8, struct region_info_user)
+ #define MEMSETOOBSEL _IOW('M', 9, struct nand_oobinfo)
+ #define MEMGETOOBSEL _IOR('M', 10, struct nand_oobinfo)
+-#define MEMGETBADBLOCK _IOW('M', 11, __kernel_loff_t)
+-#define MEMSETBADBLOCK _IOW('M', 12, __kernel_loff_t)
++#define MEMGETBADBLOCK _IOW('M', 11, loff_t)
++#define MEMSETBADBLOCK _IOW('M', 12, loff_t)
+ #define OTPSELECT _IOR('M', 13, int)
+ #define OTPGETREGIONCOUNT _IOW('M', 14, int)
+ #define OTPGETREGIONINFO _IOW('M', 15, struct otp_info)