Root/tools/mtd-utils/patches/101-ubifs-optional_lzo.patch

1--- a/mkfs.ubifs/Makefile
2+++ b/mkfs.ubifs/Makefile
3@@ -6,7 +6,7 @@ ALL_SOURCES=*.[ch] hashtable/*.[ch]
4 
5 TARGETS = mkfs.ubifs
6 
7-LDLIBS_mkfs.ubifs = -lz -llzo2 -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
8+LDLIBS_mkfs.ubifs = -lz $(if,$(NO_LZO),,-llzo2) -lm -luuid -L$(BUILDDIR)/../ubi-utils/ -lubi
9 LDLIBS_mkfs.ubifs += -L$(BUILDDIR)/../lib -lmtd -lcrc32
10 LDLIBS_mkfs.ubifs += $(ZLIBLDFLAGS) $(LZOLDFLAGS)
11 
12--- a/mkfs.ubifs/compr.c
13+++ b/mkfs.ubifs/compr.c
14@@ -24,7 +24,9 @@
15 #include <stdio.h>
16 #include <stdint.h>
17 #include <string.h>
18+#if CONFIG_UBIFS_LZO
19 #include <lzo/lzo1x.h>
20+#endif
21 #include <linux/types.h>
22 
23 #define crc32 __zlib_crc32
24@@ -86,6 +88,16 @@ static int zlib_deflate(void *in_buf, si
25     return 0;
26 }
27 
28+static int no_compress(void *in_buf, size_t in_len, void *out_buf,
29+ size_t *out_len)
30+{
31+ memcpy(out_buf, in_buf, in_len);
32+ *out_len = in_len;
33+ return 0;
34+}
35+
36+#if CONFIG_UBIFS_LZO
37+
38 static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
39             size_t *out_len)
40 {
41@@ -104,14 +116,16 @@ static int lzo_compress(void *in_buf, si
42     return 0;
43 }
44 
45-static int no_compress(void *in_buf, size_t in_len, void *out_buf,
46- size_t *out_len)
47+#else
48+
49+static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
50+ size_t *out_len)
51 {
52- memcpy(out_buf, in_buf, in_len);
53- *out_len = in_len;
54- return 0;
55+ return 1;
56 }
57 
58+#endif
59+
60 static char *zlib_buf;
61 
62 static int favor_lzo_compress(void *in_buf, size_t in_len, void *out_buf,
63@@ -198,9 +212,11 @@ int compress_data(void *in_buf, size_t i
64 
65 int init_compression(void)
66 {
67+#ifdef CONFIG_UBIFS_LZO
68     lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
69     if (!lzo_mem)
70         return -1;
71+#endif
72 
73     zlib_buf = malloc(UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR);
74     if (!zlib_buf) {
75@@ -214,7 +230,9 @@ int init_compression(void)
76 void destroy_compression(void)
77 {
78     free(zlib_buf);
79+#ifdef CONFIG_UBIFS_LZO
80     free(lzo_mem);
81+#endif
82     if (errcnt)
83         fprintf(stderr, "%llu compression errors occurred\n", errcnt);
84 }
85

Archive Download this file



interactive