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;
}
- memcpy(out_buf, in_buf, in_len);
- *out_len = in_len;
- return 0;
-+ return -1;
++ return 1;
}
+#endif
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)
{
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);
--- /dev/null
+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"