summaryrefslogtreecommitdiffstats
path: root/meta/packages/mtd/mtd-utils/favour_lzo.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/packages/mtd/mtd-utils/favour_lzo.patch')
-rw-r--r--meta/packages/mtd/mtd-utils/favour_lzo.patch140
1 files changed, 0 insertions, 140 deletions
diff --git a/meta/packages/mtd/mtd-utils/favour_lzo.patch b/meta/packages/mtd/mtd-utils/favour_lzo.patch
deleted file mode 100644
index 8b1581c467..0000000000
--- a/meta/packages/mtd/mtd-utils/favour_lzo.patch
+++ /dev/null
@@ -1,140 +0,0 @@
1Subject: [mtd-utils patch 2/2] Add favourlzo compression mode
2
3Add a favourlzo compression mode to mtd-utils
4
5This allows lzo compression to be used in the cases where the
6compression ratio isn't quite as good zlib. This can make sense in
7certain use cases because LZO decompression is much faster than zlib.
8
9Signed-off-by: Richard Purdie <rpurdie@openedhand.com>
10
11---
12 compr.c | 52 +++++++++++++++++++++++++++++++++++++++++++++++++---
13 compr.h | 1 +
14 2 files changed, 50 insertions(+), 3 deletions(-)
15
16Index: git/compr.c
17===================================================================
18--- git.orig/compr.c 2007-03-01 11:58:01.000000000 +0000
19+++ git/compr.c 2007-03-01 11:58:09.000000000 +0000
20@@ -16,6 +16,8 @@
21 #include <stdlib.h>
22 #include <linux/jffs2.h>
23
24+#define FAVOUR_LZO_PERCENT 80
25+
26 extern int page_size;
27
28 /* LIST IMPLEMENTATION (from linux/list.h) */
29@@ -166,6 +168,33 @@ static void jffs2_decompression_test(str
30 }
31 }
32
33+/*
34+ * Return 1 to use this compression
35+ */
36+static int jffs2_is_best_compression(struct jffs2_compressor *this,
37+ struct jffs2_compressor *best, uint32_t size, uint32_t bestsize)
38+{
39+ switch (jffs2_compression_mode) {
40+ case JFFS2_COMPR_MODE_SIZE:
41+ if (bestsize > size)
42+ return 1;
43+ return 0;
44+ case JFFS2_COMPR_MODE_FAVOURLZO:
45+ if ((this->compr == JFFS2_COMPR_LZO) && (bestsize > size))
46+ return 1;
47+ if ((best->compr != JFFS2_COMPR_LZO) && (bestsize > size))
48+ return 1;
49+ if ((this->compr == JFFS2_COMPR_LZO) && (bestsize > (size * FAVOUR_LZO_PERCENT / 100)))
50+ return 1;
51+ if ((bestsize * FAVOUR_LZO_PERCENT / 100) > size)
52+ return 1;
53+
54+ return 0;
55+ }
56+ /* Shouldn't happen */
57+ return 0;
58+}
59+
60 /* jffs2_compress:
61 * @data: Pointer to uncompressed data
62 * @cdata: Pointer to returned pointer to buffer for compressed data
63@@ -231,21 +260,29 @@ uint16_t jffs2_compress( unsigned char *
64 }
65 if (ret == JFFS2_COMPR_NONE) free(output_buf);
66 break;
67+ case JFFS2_COMPR_MODE_FAVOURLZO:
68 case JFFS2_COMPR_MODE_SIZE:
69 orig_slen = *datalen;
70 orig_dlen = *cdatalen;
71 list_for_each_entry(this, &jffs2_compressor_list, list) {
72+ uint32_t needed_buf_size;
73+
74+ if (jffs2_compression_mode == JFFS2_COMPR_MODE_FAVOURLZO)
75+ needed_buf_size = orig_slen + jffs2_compression_check;
76+ else
77+ needed_buf_size = orig_dlen + jffs2_compression_check;
78+
79 /* Skip decompress-only backwards-compatibility and disabled modules */
80 if ((!this->compress)||(this->disabled))
81 continue;
82 /* Allocating memory for output buffer if necessary */
83- if ((this->compr_buf_size<orig_dlen+jffs2_compression_check)&&(this->compr_buf)) {
84+ if ((this->compr_buf_size < needed_buf_size) && (this->compr_buf)) {
85 free(this->compr_buf);
86 this->compr_buf_size=0;
87 this->compr_buf=NULL;
88 }
89 if (!this->compr_buf) {
90- tmp_buf = malloc(orig_dlen+jffs2_compression_check);
91+ tmp_buf = malloc(needed_buf_size);
92 if (!tmp_buf) {
93 fprintf(stderr,"mkfs.jffs2: No memory for compressor allocation. (%d bytes)\n",orig_dlen);
94 continue;
95@@ -265,7 +302,8 @@ uint16_t jffs2_compress( unsigned char *
96 if (!compr_ret) {
97 if (jffs2_compression_check)
98 jffs2_decompression_test(this, data_in, this->compr_buf, *cdatalen, *datalen, this->compr_buf_size);
99- if ((!best_dlen)||(best_dlen>*cdatalen)) {
100+ if (((!best_dlen) || jffs2_is_best_compression(this, best, *cdatalen, best_dlen))
101+ && (*cdatalen < *datalen)) {
102 best_dlen = *cdatalen;
103 best_slen = *datalen;
104 best = this;
105@@ -377,6 +415,9 @@ char *jffs2_stats(void)
106 case JFFS2_COMPR_MODE_SIZE:
107 act_buf += sprintf(act_buf,"size");
108 break;
109+ case JFFS2_COMPR_MODE_FAVOURLZO:
110+ act_buf += sprintf(act_buf, "favourlzo");
111+ break;
112 default:
113 act_buf += sprintf(act_buf,"unkown");
114 break;
115@@ -413,6 +454,11 @@ int jffs2_set_compression_mode_name(cons
116 jffs2_compression_mode = JFFS2_COMPR_MODE_SIZE;
117 return 0;
118 }
119+ if (!strcmp("favourlzo", name)) {
120+ jffs2_compression_mode = JFFS2_COMPR_MODE_FAVOURLZO;
121+ return 0;
122+ }
123+
124 return 1;
125 }
126
127Index: git/compr.h
128===================================================================
129--- git.orig/compr.h 2007-03-01 11:58:01.000000000 +0000
130+++ git/compr.h 2007-03-01 11:58:09.000000000 +0000
131@@ -32,6 +32,7 @@
132 #define JFFS2_COMPR_MODE_NONE 0
133 #define JFFS2_COMPR_MODE_PRIORITY 1
134 #define JFFS2_COMPR_MODE_SIZE 2
135+#define JFFS2_COMPR_MODE_FAVOURLZO 3
136
137 #define kmalloc(a,b) malloc(a)
138 #define kfree(a) free(a)
139
140