2010-01-11 11:04:30 +00:00
|
|
|
diff --git a/mkfs.ubifs/Makefile b/mkfs.ubifs/Makefile
|
|
|
|
index a678b0a..919ce89 100644
|
|
|
|
--- a/mkfs.ubifs/Makefile
|
|
|
|
+++ b/mkfs.ubifs/Makefile
|
2010-10-01 16:39:08 +00:00
|
|
|
@@ -6,7 +6,7 @@ ALL_SOURCES=*.[ch] hashtable/*.[ch]
|
2010-01-11 11:04:30 +00:00
|
|
|
|
|
|
|
TARGETS = mkfs.ubifs
|
|
|
|
|
2010-10-01 16:39:08 +00:00
|
|
|
-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)
|
2010-01-11 11:04:30 +00:00
|
|
|
|
|
|
|
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
|
2010-10-01 16:39:08 +00:00
|
|
|
@@ -24,7 +24,9 @@
|
|
|
|
#include <stdio.h>
|
2010-01-11 16:15:52 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
#include <string.h>
|
|
|
|
+#if CONFIG_UBIFS_LZO
|
|
|
|
#include <lzo/lzo1x.h>
|
|
|
|
+#endif
|
|
|
|
#include <linux/types.h>
|
|
|
|
|
2010-10-01 16:39:08 +00:00
|
|
|
#define crc32 __zlib_crc32
|
|
|
|
@@ -85,6 +87,16 @@ static int zlib_deflate(void *in_buf, si
|
2010-01-11 11:04:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
+static int no_compress(void *in_buf, size_t in_len, void *out_buf,
|
2010-10-01 16:39:08 +00:00
|
|
|
+ size_t *out_len)
|
2010-01-11 11:04:30 +00:00
|
|
|
+{
|
|
|
|
+ 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)
|
|
|
|
{
|
2010-10-01 16:39:08 +00:00
|
|
|
@@ -103,14 +115,16 @@ static int lzo_compress(void *in_buf, si
|
2010-01-11 11:04:30 +00:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
-static int no_compress(void *in_buf, size_t in_len, void *out_buf,
|
|
|
|
- size_t *out_len)
|
|
|
|
+#else
|
|
|
|
+
|
|
|
|
+static int lzo_compress(void *in_buf, size_t in_len, void *out_buf,
|
|
|
|
+ size_t *out_len)
|
|
|
|
{
|
|
|
|
- memcpy(out_buf, in_buf, in_len);
|
|
|
|
- *out_len = in_len;
|
|
|
|
- return 0;
|
2010-10-01 16:39:08 +00:00
|
|
|
+ return 1;
|
2010-01-11 11:04:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
+#endif
|
|
|
|
+
|
|
|
|
static char *zlib_buf;
|
|
|
|
|
|
|
|
static int favor_lzo_compress(void *in_buf, size_t in_len, void *out_buf,
|
2010-10-01 16:39:08 +00:00
|
|
|
@@ -197,9 +211,11 @@ int compress_data(void *in_buf, size_t i
|
2010-01-11 11:04:30 +00:00
|
|
|
|
|
|
|
int init_compression(void)
|
|
|
|
{
|
|
|
|
+#ifdef CONFIG_UBIFS_LZO
|
|
|
|
lzo_mem = malloc(LZO1X_999_MEM_COMPRESS);
|
|
|
|
if (!lzo_mem)
|
|
|
|
return -1;
|
|
|
|
+#endif
|
|
|
|
|
|
|
|
zlib_buf = malloc(UBIFS_BLOCK_SIZE * WORST_COMPR_FACTOR);
|
|
|
|
if (!zlib_buf) {
|
2010-10-01 16:39:08 +00:00
|
|
|
@@ -213,7 +229,9 @@ int init_compression(void)
|
2010-01-11 11:04:30 +00:00
|
|
|
void destroy_compression(void)
|
|
|
|
{
|
|
|
|
free(zlib_buf);
|
|
|
|
+#ifdef CONFIG_UBIFS_LZO
|
|
|
|
free(lzo_mem);
|
|
|
|
+#endif
|
|
|
|
if (errcnt)
|
|
|
|
fprintf(stderr, "%llu compression errors occurred\n", errcnt);
|
|
|
|
}
|