1 --- a/mkfs.ubifs/compr.c
2 +++ b/mkfs.ubifs/compr.c
7 -#include <lzo/lzo1x.h>
8 #include <linux/types.h>
10 #define crc32 __zlib_crc32
12 #include "ubifs-media.h"
13 #include "mkfs.ubifs.h"
15 -static void *lzo_mem;
16 static unsigned long long errcnt = 0;
17 static struct ubifs_info *c = &info_;
19 @@ -86,6 +84,25 @@ static int zlib_deflate(void *in_buf, si
24 +#include <lzo/lzo1x.h>
26 +static void *lzo_mem;
28 +static int lzo_init(void)
30 + lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
37 +static void lzo_fini(void)
42 static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
45 @@ -103,6 +120,12 @@ static int lzo_compress(void *in_buf, si
50 +static inline int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
51 + size_t *out_len) { return -1; }
52 +static inline int lzo_init(void) { return 0; }
53 +static inline void lzo_fini(void) { }
56 static int no_compress(void *in_buf, size_t in_len, void *out_buf,
58 @@ -123,7 +146,6 @@ static int favor_lzo_compress(void *in_b
59 lzo_len = zlib_len = *out_len;
60 lzo_ret = lzo_compress(in_buf, in_len, out_buf, &lzo_len);
61 zlib_ret = zlib_deflate(in_buf, in_len, zlib_buf, &zlib_len);
63 if (lzo_ret && zlib_ret)
64 /* Both compressors failed */
66 @@ -198,23 +220,28 @@ int compress_data(void *in_buf, size_t i
68 int init_compression(void)
70 - lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
79 zlib_buf = malloc(UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR);
95 void destroy_compression(void)
101 fprintf(stderr, "%llu compression errors occurred\n", errcnt);
103 --- a/mkfs.ubifs/Makefile
104 +++ b/mkfs.ubifs/Makefile
105 @@ -6,7 +6,13 @@ ALL_SOURCES=*.[ch] hashtable/*.[ch]
109 -LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
110 +ifeq ($(WITHOUT_LZO), 1)
111 + CPPFLAGS += -DWITHOUT_LZO
116 +LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
117 LDLIBS_mkfs.ubifs += -L$(BUILDDIR)/../lib -lmtd
118 LDLIBS_mkfs.ubifs += $(ZLIBLDFLAGS) $(LZOLDFLAGS)