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
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 @@ -85,6 +83,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 @@ -102,6 +119,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 @@ -122,7 +145,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 @@ -197,23 +219,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);
105 @@ -108,7 +108,13 @@ $(call _mkdep,lib/,libmtd.a)
106 obj-mkfs.ubifs = crc16.o lpt.o compr.o devtable.o \
107 hashtable/hashtable.o hashtable/hashtable_itr.o
108 LDFLAGS_mkfs.ubifs = $(ZLIBLDFLAGS) $(LZOLDFLAGS) $(UUIDLDFLAGS)
109 -LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid
110 +ifeq ($(WITHOUT_LZO), 1)
111 + CPPFLAGS += -DWITHOUT_LZO
116 +LDLIBS_mkfs.ubifs = -lz $(LZOLDLIBS) -lm -luuid
117 $(call mkdep,mkfs.ubifs/,mkfs.ubifs,,ubi-utils/libubi.a)