rev |
line source |
slaxemulator@7649
|
1 diff -r 2ab2996036dd squashfs-tools/Makefile
|
slaxemulator@7649
|
2 --- a/squashfs-tools/Makefile Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
3 +++ b/squashfs-tools/Makefile Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
4 @@ -20,20 +20,33 @@
|
slaxemulator@7649
|
5
|
slaxemulator@7649
|
6 ########### Building LZMA support #############
|
slaxemulator@7649
|
7 #
|
slaxemulator@7649
|
8 -# Both XZ Utils liblzma (http://tukaani.org/xz/) and LZMA SDK
|
slaxemulator@7649
|
9 +# LZMA1 compression.
|
slaxemulator@7649
|
10 +#
|
slaxemulator@7649
|
11 +# Both XZ Utils liblzma (http://tukaani.org/xz/) and LZMA SDK
|
slaxemulator@7649
|
12 # (http://www.7-zip.org/sdk.html) are supported
|
slaxemulator@7649
|
13 #
|
slaxemulator@7649
|
14 # To build using XZ Utils liblzma - install the library and uncomment
|
slaxemulator@7649
|
15 -# the XZ_SUPPORT line below.
|
slaxemulator@7649
|
16 +# the LZMA_XZ_SUPPORT line below.
|
slaxemulator@7649
|
17 #
|
slaxemulator@7649
|
18 # To build using the LZMA SDK (4.65 used in development, other versions may
|
slaxemulator@7649
|
19 # work) - download and unpack it, uncomment and set LZMA_DIR to unpacked source,
|
slaxemulator@7649
|
20 # and uncomment the LZMA_SUPPORT line below.
|
slaxemulator@7649
|
21 #
|
slaxemulator@7649
|
22 -#XZ_SUPPORT = 1
|
slaxemulator@7649
|
23 +LZMA_XZ_SUPPORT = 1
|
slaxemulator@7649
|
24 #LZMA_SUPPORT = 1
|
slaxemulator@7649
|
25 #LZMA_DIR = ../../../LZMA/lzma465
|
slaxemulator@7649
|
26
|
slaxemulator@7649
|
27 +########### Building XZ support #############
|
slaxemulator@7649
|
28 +#
|
slaxemulator@7649
|
29 +# LZMA2 compression.
|
slaxemulator@7649
|
30 +#
|
slaxemulator@7649
|
31 +# XZ Utils liblzma (http://tukaani.org/xz/) is supported
|
slaxemulator@7649
|
32 +#
|
slaxemulator@7649
|
33 +# To build using XZ Utils liblzma - install the library and uncomment
|
slaxemulator@7649
|
34 +# the XZ_SUPPORT line below.
|
slaxemulator@7649
|
35 +#
|
slaxemulator@7649
|
36 +XZ_SUPPORT = 1
|
slaxemulator@7649
|
37 +
|
slaxemulator@7649
|
38
|
slaxemulator@7649
|
39 ############ Building LZO support ##############
|
slaxemulator@7649
|
40 #
|
slaxemulator@7649
|
41 @@ -109,12 +122,20 @@
|
slaxemulator@7649
|
42 COMPRESSORS += lzma
|
slaxemulator@7649
|
43 endif
|
slaxemulator@7649
|
44
|
slaxemulator@7649
|
45 +ifdef LZMA_XZ_SUPPORT
|
slaxemulator@7649
|
46 +CFLAGS += -DLZMA_SUPPORT
|
slaxemulator@7649
|
47 +MKSQUASHFS_OBJS += lzma_xz_wrapper.o
|
slaxemulator@7649
|
48 +UNSQUASHFS_OBJS += lzma_xz_wrapper.o
|
slaxemulator@7649
|
49 +LIBS += -llzma
|
slaxemulator@7649
|
50 +COMPRESSORS += lzma
|
slaxemulator@7649
|
51 +endif
|
slaxemulator@7649
|
52 +
|
slaxemulator@7649
|
53 ifdef XZ_SUPPORT
|
slaxemulator@7649
|
54 -CFLAGS += -DLZMA_SUPPORT
|
slaxemulator@7649
|
55 +CFLAGS += -DXZ_SUPPORT
|
slaxemulator@7649
|
56 MKSQUASHFS_OBJS += xz_wrapper.o
|
slaxemulator@7649
|
57 UNSQUASHFS_OBJS += xz_wrapper.o
|
slaxemulator@7649
|
58 LIBS += -llzma
|
slaxemulator@7649
|
59 -COMPRESSORS += lzma
|
slaxemulator@7649
|
60 +COMPRESSORS += xz
|
slaxemulator@7649
|
61 endif
|
slaxemulator@7649
|
62
|
slaxemulator@7649
|
63 ifdef LZO_SUPPORT
|
slaxemulator@7649
|
64 @@ -149,11 +170,11 @@
|
slaxemulator@7649
|
65 endif
|
slaxemulator@7649
|
66
|
slaxemulator@7649
|
67 #
|
slaxemulator@7649
|
68 -# Both XZ_SUPPORT and LZMA_SUPPORT cannot be specified
|
slaxemulator@7649
|
69 +# Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified
|
slaxemulator@7649
|
70 #
|
slaxemulator@7649
|
71 -ifdef XZ_SUPPORT
|
slaxemulator@7649
|
72 +ifdef LZMA_XZ_SUPPORT
|
slaxemulator@7649
|
73 ifdef LZMA_SUPPORT
|
slaxemulator@7649
|
74 -$(error "Both XZ_SUPPORT and LZMA_SUPPORT cannot be specified")
|
slaxemulator@7649
|
75 +$(error "Both LZMA_XZ_SUPPORT and LZMA_SUPPORT cannot be specified")
|
slaxemulator@7649
|
76 endif
|
slaxemulator@7649
|
77 endif
|
slaxemulator@7649
|
78
|
slaxemulator@7649
|
79 @@ -161,7 +182,7 @@
|
slaxemulator@7649
|
80 # At least one compressor must have been selected
|
slaxemulator@7649
|
81 #
|
slaxemulator@7649
|
82 ifndef COMPRESSORS
|
slaxemulator@7649
|
83 -$(error "No compressor selected! Select one or more of GZIP, LZMA, or LZO!")
|
slaxemulator@7649
|
84 +$(error "No compressor selected! Select one or more of GZIP, LZMA, XZ or LZO!")
|
slaxemulator@7649
|
85 endif
|
slaxemulator@7649
|
86
|
slaxemulator@7649
|
87 #
|
slaxemulator@7649
|
88 diff -r 2ab2996036dd squashfs-tools/compressor.c
|
slaxemulator@7649
|
89 --- a/squashfs-tools/compressor.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
90 +++ b/squashfs-tools/compressor.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
91 @@ -25,31 +25,50 @@
|
slaxemulator@7649
|
92 #include "compressor.h"
|
slaxemulator@7649
|
93 #include "squashfs_fs.h"
|
slaxemulator@7649
|
94
|
slaxemulator@7649
|
95 -extern int gzip_compress(void **, char *, char *, int, int, int *);
|
slaxemulator@7649
|
96 -extern int gzip_uncompress(char *, char *, int, int, int *);
|
slaxemulator@7649
|
97 -extern int lzma_compress(void **, char *, char *, int, int, int *);
|
slaxemulator@7649
|
98 -extern int lzma_uncompress(char *, char *, int, int, int *);
|
slaxemulator@7649
|
99 -extern int lzo_compress(void **, char *, char *, int, int, int *);
|
slaxemulator@7649
|
100 -extern int lzo_uncompress(char *, char *, int, int, int *);
|
slaxemulator@7649
|
101 -
|
slaxemulator@7649
|
102 -struct compressor compressor[] = {
|
slaxemulator@7649
|
103 -#ifdef GZIP_SUPPORT
|
slaxemulator@7649
|
104 - { gzip_compress, gzip_uncompress, ZLIB_COMPRESSION, "gzip", 1 },
|
slaxemulator@7649
|
105 +#ifndef GZIP_SUPPORT
|
slaxemulator@7649
|
106 +static struct compressor gzip_comp_ops = {
|
slaxemulator@7649
|
107 + NULL, NULL, NULL, NULL, NULL, ZLIB_COMPRESSION, "gzip", 0
|
slaxemulator@7649
|
108 +};
|
slaxemulator@7649
|
109 #else
|
slaxemulator@7649
|
110 - { NULL, NULL, ZLIB_COMPRESSION, "gzip", 0 },
|
slaxemulator@7649
|
111 -#endif
|
slaxemulator@7649
|
112 -#ifdef LZMA_SUPPORT
|
slaxemulator@7649
|
113 - { lzma_compress, lzma_uncompress, LZMA_COMPRESSION, "lzma", 1 },
|
slaxemulator@7649
|
114 -#else
|
slaxemulator@7649
|
115 - { NULL, NULL, LZMA_COMPRESSION, "lzma", 0 },
|
slaxemulator@7649
|
116 -#endif
|
slaxemulator@7649
|
117 -#ifdef LZO_SUPPORT
|
slaxemulator@7649
|
118 - { lzo_compress, lzo_uncompress, LZO_COMPRESSION, "lzo", 1 },
|
slaxemulator@7649
|
119 -#else
|
slaxemulator@7649
|
120 - { NULL, NULL, LZO_COMPRESSION, "lzo", 0 },
|
slaxemulator@7649
|
121 +extern struct compressor gzip_comp_ops;
|
slaxemulator@7649
|
122 #endif
|
slaxemulator@7649
|
123
|
slaxemulator@7649
|
124 - { NULL, NULL , 0, "unknown", 0}
|
slaxemulator@7649
|
125 +#ifndef LZMA_SUPPORT
|
slaxemulator@7649
|
126 +static struct compressor lzma_comp_ops = {
|
slaxemulator@7649
|
127 + NULL, NULL, NULL, NULL, NULL, LZMA_COMPRESSION, "lzma", 0
|
slaxemulator@7649
|
128 +};
|
slaxemulator@7649
|
129 +#else
|
slaxemulator@7649
|
130 +extern struct compressor lzma_comp_ops;
|
slaxemulator@7649
|
131 +#endif
|
slaxemulator@7649
|
132 +
|
slaxemulator@7649
|
133 +#ifndef LZO_SUPPORT
|
slaxemulator@7649
|
134 +static struct compressor lzo_comp_ops = {
|
slaxemulator@7649
|
135 + NULL, NULL, NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0
|
slaxemulator@7649
|
136 +};
|
slaxemulator@7649
|
137 +#else
|
slaxemulator@7649
|
138 +extern struct compressor lzo_comp_ops;
|
slaxemulator@7649
|
139 +#endif
|
slaxemulator@7649
|
140 +
|
slaxemulator@7649
|
141 +#ifndef XZ_SUPPORT
|
slaxemulator@7649
|
142 +static struct compressor xz_comp_ops = {
|
slaxemulator@7649
|
143 + NULL, NULL, NULL, NULL, NULL, XZ_COMPRESSION, "xz", 0
|
slaxemulator@7649
|
144 +};
|
slaxemulator@7649
|
145 +#else
|
slaxemulator@7649
|
146 +extern struct compressor xz_comp_ops;
|
slaxemulator@7649
|
147 +#endif
|
slaxemulator@7649
|
148 +
|
slaxemulator@7649
|
149 +
|
slaxemulator@7649
|
150 +static struct compressor unknown_comp_ops = {
|
slaxemulator@7649
|
151 + NULL, NULL, NULL , NULL, NULL, 0, "unknown", 0
|
slaxemulator@7649
|
152 +};
|
slaxemulator@7649
|
153 +
|
slaxemulator@7649
|
154 +
|
slaxemulator@7649
|
155 +struct compressor *compressor[] = {
|
slaxemulator@7649
|
156 + &gzip_comp_ops,
|
slaxemulator@7649
|
157 + &lzma_comp_ops,
|
slaxemulator@7649
|
158 + &lzo_comp_ops,
|
slaxemulator@7649
|
159 + &xz_comp_ops,
|
slaxemulator@7649
|
160 + &unknown_comp_ops
|
slaxemulator@7649
|
161 };
|
slaxemulator@7649
|
162
|
slaxemulator@7649
|
163
|
slaxemulator@7649
|
164 @@ -57,11 +76,11 @@
|
slaxemulator@7649
|
165 {
|
slaxemulator@7649
|
166 int i;
|
slaxemulator@7649
|
167
|
slaxemulator@7649
|
168 - for(i = 0; compressor[i].id; i++)
|
slaxemulator@7649
|
169 - if(strcmp(compressor[i].name, name) == 0)
|
slaxemulator@7649
|
170 + for(i = 0; compressor[i]->id; i++)
|
slaxemulator@7649
|
171 + if(strcmp(compressor[i]->name, name) == 0)
|
slaxemulator@7649
|
172 break;
|
slaxemulator@7649
|
173
|
slaxemulator@7649
|
174 - return &compressor[i];
|
slaxemulator@7649
|
175 + return compressor[i];
|
slaxemulator@7649
|
176 }
|
slaxemulator@7649
|
177
|
slaxemulator@7649
|
178
|
slaxemulator@7649
|
179 @@ -69,11 +88,11 @@
|
slaxemulator@7649
|
180 {
|
slaxemulator@7649
|
181 int i;
|
slaxemulator@7649
|
182
|
slaxemulator@7649
|
183 - for(i = 0; compressor[i].id; i++)
|
slaxemulator@7649
|
184 - if(id == compressor[i].id)
|
slaxemulator@7649
|
185 + for(i = 0; compressor[i]->id; i++)
|
slaxemulator@7649
|
186 + if(id == compressor[i]->id)
|
slaxemulator@7649
|
187 break;
|
slaxemulator@7649
|
188
|
slaxemulator@7649
|
189 - return &compressor[i];
|
slaxemulator@7649
|
190 + return compressor[i];
|
slaxemulator@7649
|
191 }
|
slaxemulator@7649
|
192
|
slaxemulator@7649
|
193
|
slaxemulator@7649
|
194 @@ -81,10 +100,29 @@
|
slaxemulator@7649
|
195 {
|
slaxemulator@7649
|
196 int i;
|
slaxemulator@7649
|
197
|
slaxemulator@7649
|
198 - for(i = 0; compressor[i].id; i++)
|
slaxemulator@7649
|
199 - if(compressor[i].supported)
|
slaxemulator@7649
|
200 + for(i = 0; compressor[i]->id; i++)
|
slaxemulator@7649
|
201 + if(compressor[i]->supported)
|
slaxemulator@7649
|
202 fprintf(stderr, "%s\t%s%s\n", indent,
|
slaxemulator@7649
|
203 - compressor[i].name,
|
slaxemulator@7649
|
204 - strcmp(compressor[i].name, def_comp) == 0 ?
|
slaxemulator@7649
|
205 + compressor[i]->name,
|
slaxemulator@7649
|
206 + strcmp(compressor[i]->name, def_comp) == 0 ?
|
slaxemulator@7649
|
207 " (default)" : "");
|
slaxemulator@7649
|
208 }
|
slaxemulator@7649
|
209 +
|
slaxemulator@7649
|
210 +
|
slaxemulator@7649
|
211 +void display_compressor_usage(char *def_comp)
|
slaxemulator@7649
|
212 +{
|
slaxemulator@7649
|
213 + int i;
|
slaxemulator@7649
|
214 +
|
slaxemulator@7649
|
215 + for(i = 0; compressor[i]->id; i++)
|
slaxemulator@7649
|
216 + if(compressor[i]->supported) {
|
slaxemulator@7649
|
217 + char *str = strcmp(compressor[i]->name, def_comp) == 0 ?
|
slaxemulator@7649
|
218 + " (default)" : "";
|
slaxemulator@7649
|
219 + if(compressor[i]->usage) {
|
slaxemulator@7649
|
220 + fprintf(stderr, "\t%s%s\n",
|
slaxemulator@7649
|
221 + compressor[i]->name, str);
|
slaxemulator@7649
|
222 + compressor[i]->usage();
|
slaxemulator@7649
|
223 + } else
|
slaxemulator@7649
|
224 + fprintf(stderr, "\t%s (no options)%s\n",
|
slaxemulator@7649
|
225 + compressor[i]->name, str);
|
slaxemulator@7649
|
226 + }
|
slaxemulator@7649
|
227 +}
|
slaxemulator@7649
|
228 diff -r 2ab2996036dd squashfs-tools/compressor.h
|
slaxemulator@7649
|
229 --- a/squashfs-tools/compressor.h Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
230 +++ b/squashfs-tools/compressor.h Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
231 @@ -21,8 +21,11 @@
|
slaxemulator@7649
|
232 */
|
slaxemulator@7649
|
233
|
slaxemulator@7649
|
234 struct compressor {
|
slaxemulator@7649
|
235 - int (*compress)(void **, char *, char *, int, int, int *);
|
slaxemulator@7649
|
236 - int (*uncompress)(char *, char *, int, int, int *);
|
slaxemulator@7649
|
237 + int (*init)(void **, int, int);
|
slaxemulator@7649
|
238 + int (*compress)(void *, void *, void *, int, int, int *);
|
slaxemulator@7649
|
239 + int (*uncompress)(void *, void *, int, int, int *);
|
slaxemulator@7649
|
240 + int (*options)(char **, int);
|
slaxemulator@7649
|
241 + void (*usage)();
|
slaxemulator@7649
|
242 int id;
|
slaxemulator@7649
|
243 char *name;
|
slaxemulator@7649
|
244 int supported;
|
slaxemulator@7649
|
245 @@ -31,3 +34,25 @@
|
slaxemulator@7649
|
246 extern struct compressor *lookup_compressor(char *);
|
slaxemulator@7649
|
247 extern struct compressor *lookup_compressor_id(int);
|
slaxemulator@7649
|
248 extern void display_compressors(char *, char *);
|
slaxemulator@7649
|
249 +extern void display_compressor_usage(char *);
|
slaxemulator@7649
|
250 +
|
slaxemulator@7649
|
251 +static inline int compressor_options(struct compressor *comp, char *argv[],
|
slaxemulator@7649
|
252 + int argc)
|
slaxemulator@7649
|
253 +{
|
slaxemulator@7649
|
254 + if(comp->options == NULL)
|
slaxemulator@7649
|
255 + return -1;
|
slaxemulator@7649
|
256 +
|
slaxemulator@7649
|
257 + return comp->options(argv, argc);
|
slaxemulator@7649
|
258 +}
|
slaxemulator@7649
|
259 +
|
slaxemulator@7649
|
260 +
|
slaxemulator@7649
|
261 +static inline int compressor_init(struct compressor *comp, void **stream,
|
slaxemulator@7649
|
262 + int block_size, int flags)
|
slaxemulator@7649
|
263 +{
|
slaxemulator@7649
|
264 + if(comp->init == NULL)
|
slaxemulator@7649
|
265 + return 0;
|
slaxemulator@7649
|
266 + return comp->init(stream, block_size, flags);
|
slaxemulator@7649
|
267 +}
|
slaxemulator@7649
|
268 +
|
slaxemulator@7649
|
269 +
|
slaxemulator@7649
|
270 +
|
slaxemulator@7649
|
271 diff -r 2ab2996036dd squashfs-tools/gzip_wrapper.c
|
slaxemulator@7649
|
272 --- a/squashfs-tools/gzip_wrapper.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
273 +++ b/squashfs-tools/gzip_wrapper.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
274 @@ -22,28 +22,48 @@
|
slaxemulator@7649
|
275 #include <stdlib.h>
|
slaxemulator@7649
|
276 #include <zlib.h>
|
slaxemulator@7649
|
277
|
slaxemulator@7649
|
278 -int gzip_compress(void **strm, char *d, char *s, int size, int block_size,
|
slaxemulator@7649
|
279 +#include "squashfs_fs.h"
|
slaxemulator@7649
|
280 +#include "compressor.h"
|
slaxemulator@7649
|
281 +
|
slaxemulator@7649
|
282 +static int gzip_init(void **strm, int block_size, int flags)
|
slaxemulator@7649
|
283 +{
|
slaxemulator@7649
|
284 + int res;
|
slaxemulator@7649
|
285 + z_stream *stream;
|
slaxemulator@7649
|
286 +
|
slaxemulator@7649
|
287 + stream = *strm = malloc(sizeof(z_stream));
|
slaxemulator@7649
|
288 + if(stream == NULL)
|
slaxemulator@7649
|
289 + goto failed;
|
slaxemulator@7649
|
290 +
|
slaxemulator@7649
|
291 + stream->zalloc = Z_NULL;
|
slaxemulator@7649
|
292 + stream->zfree = Z_NULL;
|
slaxemulator@7649
|
293 + stream->opaque = 0;
|
slaxemulator@7649
|
294 +
|
slaxemulator@7649
|
295 + res = deflateInit(stream, 9);
|
slaxemulator@7649
|
296 + if(res != Z_OK)
|
slaxemulator@7649
|
297 + goto failed2;
|
slaxemulator@7649
|
298 +
|
slaxemulator@7649
|
299 + return 0;
|
slaxemulator@7649
|
300 +
|
slaxemulator@7649
|
301 +failed2:
|
slaxemulator@7649
|
302 + free(stream);
|
slaxemulator@7649
|
303 +failed:
|
slaxemulator@7649
|
304 + return -1;
|
slaxemulator@7649
|
305 +}
|
slaxemulator@7649
|
306 +
|
slaxemulator@7649
|
307 +
|
slaxemulator@7649
|
308 +static int gzip_compress(void *strm, void *d, void *s, int size, int block_size,
|
slaxemulator@7649
|
309 int *error)
|
slaxemulator@7649
|
310 {
|
slaxemulator@7649
|
311 - int res = 0;
|
slaxemulator@7649
|
312 - z_stream *stream = *strm;
|
slaxemulator@7649
|
313 + int res;
|
slaxemulator@7649
|
314 + z_stream *stream = strm;
|
slaxemulator@7649
|
315
|
slaxemulator@7649
|
316 - if(stream == NULL) {
|
slaxemulator@7649
|
317 - if((stream = *strm = malloc(sizeof(z_stream))) == NULL)
|
slaxemulator@7649
|
318 - goto failed;
|
slaxemulator@7649
|
319 -
|
slaxemulator@7649
|
320 - stream->zalloc = Z_NULL;
|
slaxemulator@7649
|
321 - stream->zfree = Z_NULL;
|
slaxemulator@7649
|
322 - stream->opaque = 0;
|
slaxemulator@7649
|
323 -
|
slaxemulator@7649
|
324 - if((res = deflateInit(stream, 9)) != Z_OK)
|
slaxemulator@7649
|
325 - goto failed;
|
slaxemulator@7649
|
326 - } else if((res = deflateReset(stream)) != Z_OK)
|
slaxemulator@7649
|
327 + res = deflateReset(stream);
|
slaxemulator@7649
|
328 + if(res != Z_OK)
|
slaxemulator@7649
|
329 goto failed;
|
slaxemulator@7649
|
330
|
slaxemulator@7649
|
331 - stream->next_in = (unsigned char *) s;
|
slaxemulator@7649
|
332 + stream->next_in = s;
|
slaxemulator@7649
|
333 stream->avail_in = size;
|
slaxemulator@7649
|
334 - stream->next_out = (unsigned char *) d;
|
slaxemulator@7649
|
335 + stream->next_out = d;
|
slaxemulator@7649
|
336 stream->avail_out = block_size;
|
slaxemulator@7649
|
337
|
slaxemulator@7649
|
338 res = deflate(stream, Z_FINISH);
|
slaxemulator@7649
|
339 @@ -67,14 +87,26 @@
|
slaxemulator@7649
|
340 }
|
slaxemulator@7649
|
341
|
slaxemulator@7649
|
342
|
slaxemulator@7649
|
343 -int gzip_uncompress(char *d, char *s, int size, int block_size, int *error)
|
slaxemulator@7649
|
344 +static int gzip_uncompress(void *d, void *s, int size, int block_size, int *error)
|
slaxemulator@7649
|
345 {
|
slaxemulator@7649
|
346 int res;
|
slaxemulator@7649
|
347 unsigned long bytes = block_size;
|
slaxemulator@7649
|
348
|
slaxemulator@7649
|
349 - res = uncompress((unsigned char *) d, &bytes,
|
slaxemulator@7649
|
350 - (const unsigned char *) s, size);
|
slaxemulator@7649
|
351 + res = uncompress(d, &bytes, s, size);
|
slaxemulator@7649
|
352
|
slaxemulator@7649
|
353 *error = res;
|
slaxemulator@7649
|
354 return res == Z_OK ? (int) bytes : -1;
|
slaxemulator@7649
|
355 }
|
slaxemulator@7649
|
356 +
|
slaxemulator@7649
|
357 +
|
slaxemulator@7649
|
358 +struct compressor gzip_comp_ops = {
|
slaxemulator@7649
|
359 + .init = gzip_init,
|
slaxemulator@7649
|
360 + .compress = gzip_compress,
|
slaxemulator@7649
|
361 + .uncompress = gzip_uncompress,
|
slaxemulator@7649
|
362 + .options = NULL,
|
slaxemulator@7649
|
363 + .usage = NULL,
|
slaxemulator@7649
|
364 + .id = ZLIB_COMPRESSION,
|
slaxemulator@7649
|
365 + .name = "gzip",
|
slaxemulator@7649
|
366 + .supported = 1
|
slaxemulator@7649
|
367 +};
|
slaxemulator@7649
|
368 +
|
slaxemulator@7649
|
369 diff -r 2ab2996036dd squashfs-tools/lzma_wrapper.c
|
slaxemulator@7649
|
370 --- a/squashfs-tools/lzma_wrapper.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
371 +++ b/squashfs-tools/lzma_wrapper.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
372 @@ -17,21 +17,27 @@
|
slaxemulator@7649
|
373 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
slaxemulator@7649
|
374 *
|
slaxemulator@7649
|
375 * lzma_wrapper.c
|
slaxemulator@7649
|
376 + *
|
slaxemulator@7649
|
377 + * Support for LZMA1 compression using LZMA SDK (4.65 used in
|
slaxemulator@7649
|
378 + * development, other versions may work) http://www.7-zip.org/sdk.html
|
slaxemulator@7649
|
379 */
|
slaxemulator@7649
|
380
|
slaxemulator@7649
|
381 #include <LzmaLib.h>
|
slaxemulator@7649
|
382
|
slaxemulator@7649
|
383 +#include "squashfs_fs.h"
|
slaxemulator@7649
|
384 +#include "compressor.h"
|
slaxemulator@7649
|
385 +
|
slaxemulator@7649
|
386 #define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + 8)
|
slaxemulator@7649
|
387
|
slaxemulator@7649
|
388 -int lzma_compress(void **strm, char *dest, char *src, int size, int block_size,
|
slaxemulator@7649
|
389 +static int lzma_compress(void *strm, void *dest, void *src, int size, int block_size,
|
slaxemulator@7649
|
390 int *error)
|
slaxemulator@7649
|
391 {
|
slaxemulator@7649
|
392 - unsigned char *d = (unsigned char *) dest, *s = (unsigned char *) src;
|
slaxemulator@7649
|
393 + unsigned char *d = dest;
|
slaxemulator@7649
|
394 size_t props_size = LZMA_PROPS_SIZE,
|
slaxemulator@7649
|
395 outlen = block_size - LZMA_HEADER_SIZE;
|
slaxemulator@7649
|
396 int res;
|
slaxemulator@7649
|
397
|
slaxemulator@7649
|
398 - res = LzmaCompress(d + LZMA_HEADER_SIZE, &outlen, s, size, d,
|
slaxemulator@7649
|
399 + res = LzmaCompress(dest + LZMA_HEADER_SIZE, &outlen, src, size, dest,
|
slaxemulator@7649
|
400 &props_size, 5, block_size, 3, 0, 2, 32, 1);
|
slaxemulator@7649
|
401
|
slaxemulator@7649
|
402 if(res == SZ_ERROR_OUTPUT_EOF) {
|
slaxemulator@7649
|
403 @@ -73,10 +79,10 @@
|
slaxemulator@7649
|
404 }
|
slaxemulator@7649
|
405
|
slaxemulator@7649
|
406
|
slaxemulator@7649
|
407 -int lzma_uncompress(char *dest, char *src, int size, int block_size,
|
slaxemulator@7649
|
408 +static int lzma_uncompress(void *dest, void *src, int size, int block_size,
|
slaxemulator@7649
|
409 int *error)
|
slaxemulator@7649
|
410 {
|
slaxemulator@7649
|
411 - unsigned char *d = (unsigned char *) dest, *s = (unsigned char *) src;
|
slaxemulator@7649
|
412 + unsigned char *s = src;
|
slaxemulator@7649
|
413 size_t outlen, inlen = size - LZMA_HEADER_SIZE;
|
slaxemulator@7649
|
414 int res;
|
slaxemulator@7649
|
415
|
slaxemulator@7649
|
416 @@ -85,9 +91,22 @@
|
slaxemulator@7649
|
417 (s[LZMA_PROPS_SIZE + 2] << 16) |
|
slaxemulator@7649
|
418 (s[LZMA_PROPS_SIZE + 3] << 24);
|
slaxemulator@7649
|
419
|
slaxemulator@7649
|
420 - res = LzmaUncompress(d, &outlen, s + LZMA_HEADER_SIZE, &inlen,
|
slaxemulator@7649
|
421 - s, LZMA_PROPS_SIZE);
|
slaxemulator@7649
|
422 + res = LzmaUncompress(dest, &outlen, src + LZMA_HEADER_SIZE, &inlen, src,
|
slaxemulator@7649
|
423 + LZMA_PROPS_SIZE);
|
slaxemulator@7649
|
424
|
slaxemulator@7649
|
425 *error = res;
|
slaxemulator@7649
|
426 return res == SZ_OK ? outlen : -1;
|
slaxemulator@7649
|
427 }
|
slaxemulator@7649
|
428 +
|
slaxemulator@7649
|
429 +
|
slaxemulator@7649
|
430 +struct compressor lzma_comp_ops = {
|
slaxemulator@7649
|
431 + .init = NULL,
|
slaxemulator@7649
|
432 + .compress = lzma_compress,
|
slaxemulator@7649
|
433 + .uncompress = lzma_uncompress,
|
slaxemulator@7649
|
434 + .options = NULL,
|
slaxemulator@7649
|
435 + .usage = NULL,
|
slaxemulator@7649
|
436 + .id = LZMA_COMPRESSION,
|
slaxemulator@7649
|
437 + .name = "lzma",
|
slaxemulator@7649
|
438 + .supported = 1
|
slaxemulator@7649
|
439 +};
|
slaxemulator@7649
|
440 +
|
slaxemulator@7649
|
441 diff -r 2ab2996036dd squashfs-tools/lzma_xz_wrapper.c
|
slaxemulator@7649
|
442 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
|
slaxemulator@7649
|
443 +++ b/squashfs-tools/lzma_xz_wrapper.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
444 @@ -0,0 +1,156 @@
|
slaxemulator@7649
|
445 +/*
|
slaxemulator@7649
|
446 + * Copyright (c) 2010
|
slaxemulator@7649
|
447 + * Phillip Lougher <phillip@lougher.demon.co.uk>
|
slaxemulator@7649
|
448 + *
|
slaxemulator@7649
|
449 + * This program is free software; you can redistribute it and/or
|
slaxemulator@7649
|
450 + * modify it under the terms of the GNU General Public License
|
slaxemulator@7649
|
451 + * as published by the Free Software Foundation; either version 2,
|
slaxemulator@7649
|
452 + * or (at your option) any later version.
|
slaxemulator@7649
|
453 + *
|
slaxemulator@7649
|
454 + * This program is distributed in the hope that it will be useful,
|
slaxemulator@7649
|
455 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
slaxemulator@7649
|
456 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
slaxemulator@7649
|
457 + * GNU General Public License for more details.
|
slaxemulator@7649
|
458 + *
|
slaxemulator@7649
|
459 + * You should have received a copy of the GNU General Public License
|
slaxemulator@7649
|
460 + * along with this program; if not, write to the Free Software
|
slaxemulator@7649
|
461 + * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
slaxemulator@7649
|
462 + *
|
slaxemulator@7649
|
463 + * lzma_xz_wrapper.c
|
slaxemulator@7649
|
464 + *
|
slaxemulator@7649
|
465 + * Support for LZMA1 compression using XZ Utils liblzma http://tukaani.org/xz/
|
slaxemulator@7649
|
466 + */
|
slaxemulator@7649
|
467 +
|
slaxemulator@7649
|
468 +#include <stdio.h>
|
slaxemulator@7649
|
469 +#include <string.h>
|
slaxemulator@7649
|
470 +#include <lzma.h>
|
slaxemulator@7649
|
471 +
|
slaxemulator@7649
|
472 +#include "squashfs_fs.h"
|
slaxemulator@7649
|
473 +#include "compressor.h"
|
slaxemulator@7649
|
474 +
|
slaxemulator@7649
|
475 +#define LZMA_PROPS_SIZE 5
|
slaxemulator@7649
|
476 +#define LZMA_UNCOMP_SIZE 8
|
slaxemulator@7649
|
477 +#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + LZMA_UNCOMP_SIZE)
|
slaxemulator@7649
|
478 +
|
slaxemulator@7649
|
479 +#define LZMA_OPTIONS 5
|
slaxemulator@7649
|
480 +#define MEMLIMIT (32 * 1024 * 1024)
|
slaxemulator@7649
|
481 +
|
slaxemulator@7649
|
482 +static int lzma_compress(void *dummy, void *dest, void *src, int size,
|
slaxemulator@7649
|
483 + int block_size, int *error)
|
slaxemulator@7649
|
484 +{
|
slaxemulator@7649
|
485 + unsigned char *d = (unsigned char *) dest;
|
slaxemulator@7649
|
486 + lzma_options_lzma opt;
|
slaxemulator@7649
|
487 + lzma_stream strm = LZMA_STREAM_INIT;
|
slaxemulator@7649
|
488 + int res;
|
slaxemulator@7649
|
489 +
|
slaxemulator@7649
|
490 + lzma_lzma_preset(&opt, LZMA_OPTIONS);
|
slaxemulator@7649
|
491 + opt.dict_size = block_size;
|
slaxemulator@7649
|
492 + res = lzma_alone_encoder(&strm, &opt);
|
slaxemulator@7649
|
493 + if(res != LZMA_OK) {
|
slaxemulator@7649
|
494 + lzma_end(&strm);
|
slaxemulator@7649
|
495 + goto failed;
|
slaxemulator@7649
|
496 + }
|
slaxemulator@7649
|
497 +
|
slaxemulator@7649
|
498 + strm.next_out = dest;
|
slaxemulator@7649
|
499 + strm.avail_out = block_size;
|
slaxemulator@7649
|
500 + strm.next_in = src;
|
slaxemulator@7649
|
501 + strm.avail_in = size;
|
slaxemulator@7649
|
502 +
|
slaxemulator@7649
|
503 + res = lzma_code(&strm, LZMA_FINISH);
|
slaxemulator@7649
|
504 + lzma_end(&strm);
|
slaxemulator@7649
|
505 +
|
slaxemulator@7649
|
506 + if(res == LZMA_STREAM_END) {
|
slaxemulator@7649
|
507 + /*
|
slaxemulator@7649
|
508 + * Fill in the 8 byte little endian uncompressed size field in
|
slaxemulator@7649
|
509 + * the LZMA header. 8 bytes is excessively large for squashfs
|
slaxemulator@7649
|
510 + * but this is the standard LZMA header and which is expected by
|
slaxemulator@7649
|
511 + * the kernel code
|
slaxemulator@7649
|
512 + */
|
slaxemulator@7649
|
513 +
|
slaxemulator@7649
|
514 + d[LZMA_PROPS_SIZE] = size & 255;
|
slaxemulator@7649
|
515 + d[LZMA_PROPS_SIZE + 1] = (size >> 8) & 255;
|
slaxemulator@7649
|
516 + d[LZMA_PROPS_SIZE + 2] = (size >> 16) & 255;
|
slaxemulator@7649
|
517 + d[LZMA_PROPS_SIZE + 3] = (size >> 24) & 255;
|
slaxemulator@7649
|
518 + d[LZMA_PROPS_SIZE + 4] = 0;
|
slaxemulator@7649
|
519 + d[LZMA_PROPS_SIZE + 5] = 0;
|
slaxemulator@7649
|
520 + d[LZMA_PROPS_SIZE + 6] = 0;
|
slaxemulator@7649
|
521 + d[LZMA_PROPS_SIZE + 7] = 0;
|
slaxemulator@7649
|
522 +
|
slaxemulator@7649
|
523 + return (int) strm.total_out;
|
slaxemulator@7649
|
524 + }
|
slaxemulator@7649
|
525 +
|
slaxemulator@7649
|
526 + if(res == LZMA_OK)
|
slaxemulator@7649
|
527 + /*
|
slaxemulator@7649
|
528 + * Output buffer overflow. Return out of buffer space
|
slaxemulator@7649
|
529 + */
|
slaxemulator@7649
|
530 + return 0;
|
slaxemulator@7649
|
531 +
|
slaxemulator@7649
|
532 +failed:
|
slaxemulator@7649
|
533 + /*
|
slaxemulator@7649
|
534 + * All other errors return failure, with the compressor
|
slaxemulator@7649
|
535 + * specific error code in *error
|
slaxemulator@7649
|
536 + */
|
slaxemulator@7649
|
537 + *error = res;
|
slaxemulator@7649
|
538 + return -1;
|
slaxemulator@7649
|
539 +}
|
slaxemulator@7649
|
540 +
|
slaxemulator@7649
|
541 +
|
slaxemulator@7649
|
542 +static int lzma_uncompress(void *dest, void *src, int size, int block_size,
|
slaxemulator@7649
|
543 + int *error)
|
slaxemulator@7649
|
544 +{
|
slaxemulator@7649
|
545 + lzma_stream strm = LZMA_STREAM_INIT;
|
slaxemulator@7649
|
546 + int uncompressed_size = 0, res;
|
slaxemulator@7649
|
547 + unsigned char lzma_header[LZMA_HEADER_SIZE];
|
slaxemulator@7649
|
548 +
|
slaxemulator@7649
|
549 + res = lzma_alone_decoder(&strm, MEMLIMIT);
|
slaxemulator@7649
|
550 + if(res != LZMA_OK) {
|
slaxemulator@7649
|
551 + lzma_end(&strm);
|
slaxemulator@7649
|
552 + goto failed;
|
slaxemulator@7649
|
553 + }
|
slaxemulator@7649
|
554 +
|
slaxemulator@7649
|
555 + memcpy(lzma_header, src, LZMA_HEADER_SIZE);
|
slaxemulator@7649
|
556 + uncompressed_size = lzma_header[LZMA_PROPS_SIZE] |
|
slaxemulator@7649
|
557 + (lzma_header[LZMA_PROPS_SIZE + 1] << 8) |
|
slaxemulator@7649
|
558 + (lzma_header[LZMA_PROPS_SIZE + 2] << 16) |
|
slaxemulator@7649
|
559 + (lzma_header[LZMA_PROPS_SIZE + 3] << 24);
|
slaxemulator@7649
|
560 + memset(lzma_header + LZMA_PROPS_SIZE, 255, LZMA_UNCOMP_SIZE);
|
slaxemulator@7649
|
561 +
|
slaxemulator@7649
|
562 + strm.next_out = dest;
|
slaxemulator@7649
|
563 + strm.avail_out = block_size;
|
slaxemulator@7649
|
564 + strm.next_in = lzma_header;
|
slaxemulator@7649
|
565 + strm.avail_in = LZMA_HEADER_SIZE;
|
slaxemulator@7649
|
566 +
|
slaxemulator@7649
|
567 + res = lzma_code(&strm, LZMA_RUN);
|
slaxemulator@7649
|
568 +
|
slaxemulator@7649
|
569 + if(res != LZMA_OK || strm.avail_in != 0) {
|
slaxemulator@7649
|
570 + lzma_end(&strm);
|
slaxemulator@7649
|
571 + goto failed;
|
slaxemulator@7649
|
572 + }
|
slaxemulator@7649
|
573 +
|
slaxemulator@7649
|
574 + strm.next_in = src + LZMA_HEADER_SIZE;
|
slaxemulator@7649
|
575 + strm.avail_in = size - LZMA_HEADER_SIZE;
|
slaxemulator@7649
|
576 +
|
slaxemulator@7649
|
577 + res = lzma_code(&strm, LZMA_FINISH);
|
slaxemulator@7649
|
578 + lzma_end(&strm);
|
slaxemulator@7649
|
579 +
|
slaxemulator@7649
|
580 + if(res == LZMA_STREAM_END || (res == LZMA_OK &&
|
slaxemulator@7649
|
581 + strm.total_out >= uncompressed_size && strm.avail_in == 0))
|
slaxemulator@7649
|
582 + return uncompressed_size;
|
slaxemulator@7649
|
583 +
|
slaxemulator@7649
|
584 +failed:
|
slaxemulator@7649
|
585 + *error = res;
|
slaxemulator@7649
|
586 + return -1;
|
slaxemulator@7649
|
587 +}
|
slaxemulator@7649
|
588 +
|
slaxemulator@7649
|
589 +
|
slaxemulator@7649
|
590 +struct compressor lzma_comp_ops = {
|
slaxemulator@7649
|
591 + .init = NULL,
|
slaxemulator@7649
|
592 + .compress = lzma_compress,
|
slaxemulator@7649
|
593 + .uncompress = lzma_uncompress,
|
slaxemulator@7649
|
594 + .options = NULL,
|
slaxemulator@7649
|
595 + .usage = NULL,
|
slaxemulator@7649
|
596 + .id = LZMA_COMPRESSION,
|
slaxemulator@7649
|
597 + .name = "lzma",
|
slaxemulator@7649
|
598 + .supported = 1
|
slaxemulator@7649
|
599 +};
|
slaxemulator@7649
|
600 +
|
slaxemulator@7649
|
601 diff -r 2ab2996036dd squashfs-tools/lzo_wrapper.c
|
slaxemulator@7649
|
602 --- a/squashfs-tools/lzo_wrapper.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
603 +++ b/squashfs-tools/lzo_wrapper.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
604 @@ -2,6 +2,9 @@
|
slaxemulator@7649
|
605 * Copyright (c) 2010 LG Electronics
|
slaxemulator@7649
|
606 * Chan Jeong <chan.jeong@lge.com>
|
slaxemulator@7649
|
607 *
|
slaxemulator@7649
|
608 + * All modifications Copyright (c) 2010
|
slaxemulator@7649
|
609 + * Phillip Lougher <phillip@lougher.demon.co.uk>
|
slaxemulator@7649
|
610 + *
|
slaxemulator@7649
|
611 * This program is free software; you can redistribute it and/or
|
slaxemulator@7649
|
612 * modify it under the terms of the GNU General Public License
|
slaxemulator@7649
|
613 * as published by the Free Software Foundation; either version 2,
|
slaxemulator@7649
|
614 @@ -25,6 +28,9 @@
|
slaxemulator@7649
|
615 #include <lzo/lzoconf.h>
|
slaxemulator@7649
|
616 #include <lzo/lzo1x.h>
|
slaxemulator@7649
|
617
|
slaxemulator@7649
|
618 +#include "squashfs_fs.h"
|
slaxemulator@7649
|
619 +#include "compressor.h"
|
slaxemulator@7649
|
620 +
|
slaxemulator@7649
|
621 /* worst-case expansion calculation during compression,
|
slaxemulator@7649
|
622 see LZO FAQ for more information */
|
slaxemulator@7649
|
623 #define LZO_OUTPUT_BUFFER_SIZE(size) (size + (size/16) + 64 + 3)
|
slaxemulator@7649
|
624 @@ -34,25 +40,39 @@
|
slaxemulator@7649
|
625 lzo_bytep out;
|
slaxemulator@7649
|
626 };
|
slaxemulator@7649
|
627
|
slaxemulator@7649
|
628 -int lzo_compress(void **strm, char *d, char *s, int size, int block_size,
|
slaxemulator@7649
|
629 +
|
slaxemulator@7649
|
630 +static int squashfs_lzo_init(void **strm, int block_size, int flags)
|
slaxemulator@7649
|
631 +{
|
slaxemulator@7649
|
632 + struct lzo_stream *stream;
|
slaxemulator@7649
|
633 +
|
slaxemulator@7649
|
634 + if((stream = *strm = malloc(sizeof(struct lzo_stream))) == NULL)
|
slaxemulator@7649
|
635 + goto failed;
|
slaxemulator@7649
|
636 + /* work memory for compression */
|
slaxemulator@7649
|
637 + if((stream->wrkmem = malloc(LZO1X_999_MEM_COMPRESS)) == NULL)
|
slaxemulator@7649
|
638 + goto failed2;
|
slaxemulator@7649
|
639 + /* temporal output buffer */
|
slaxemulator@7649
|
640 + if((stream->out = malloc(LZO_OUTPUT_BUFFER_SIZE(block_size))) == NULL)
|
slaxemulator@7649
|
641 + goto failed3;
|
slaxemulator@7649
|
642 +
|
slaxemulator@7649
|
643 + return 0;
|
slaxemulator@7649
|
644 +
|
slaxemulator@7649
|
645 +failed3:
|
slaxemulator@7649
|
646 + free(stream->wrkmem);
|
slaxemulator@7649
|
647 +failed2:
|
slaxemulator@7649
|
648 + free(stream);
|
slaxemulator@7649
|
649 +failed:
|
slaxemulator@7649
|
650 + return -1;
|
slaxemulator@7649
|
651 +}
|
slaxemulator@7649
|
652 +
|
slaxemulator@7649
|
653 +
|
slaxemulator@7649
|
654 +static int lzo_compress(void *strm, void *d, void *s, int size, int block_size,
|
slaxemulator@7649
|
655 int *error)
|
slaxemulator@7649
|
656 {
|
slaxemulator@7649
|
657 - int res = 0;
|
slaxemulator@7649
|
658 + int res;
|
slaxemulator@7649
|
659 lzo_uint outlen;
|
slaxemulator@7649
|
660 - struct lzo_stream *stream = *strm;
|
slaxemulator@7649
|
661 + struct lzo_stream *stream = strm;
|
slaxemulator@7649
|
662
|
slaxemulator@7649
|
663 - if(stream == NULL) {
|
slaxemulator@7649
|
664 - if((stream = *strm = malloc(sizeof(struct lzo_stream))) == NULL)
|
slaxemulator@7649
|
665 - goto failed;
|
slaxemulator@7649
|
666 - /* work memory for compression */
|
slaxemulator@7649
|
667 - if((stream->wrkmem = malloc(LZO1X_999_MEM_COMPRESS)) == NULL)
|
slaxemulator@7649
|
668 - goto failed;
|
slaxemulator@7649
|
669 - /* temporal output buffer */
|
slaxemulator@7649
|
670 - if((stream->out = malloc(LZO_OUTPUT_BUFFER_SIZE(block_size))) == NULL)
|
slaxemulator@7649
|
671 - goto failed;
|
slaxemulator@7649
|
672 - }
|
slaxemulator@7649
|
673 -
|
slaxemulator@7649
|
674 - res = lzo1x_999_compress((lzo_bytep)s, size, stream->out, &outlen, stream->wrkmem);
|
slaxemulator@7649
|
675 + res = lzo1x_999_compress(s, size, stream->out, &outlen, stream->wrkmem);
|
slaxemulator@7649
|
676 if(res != LZO_E_OK)
|
slaxemulator@7649
|
677 goto failed;
|
slaxemulator@7649
|
678 if(outlen >= size)
|
slaxemulator@7649
|
679 @@ -77,13 +97,26 @@
|
slaxemulator@7649
|
680 }
|
slaxemulator@7649
|
681
|
slaxemulator@7649
|
682
|
slaxemulator@7649
|
683 -int lzo_uncompress(char *d, char *s, int size, int block_size, int *error)
|
slaxemulator@7649
|
684 +static int lzo_uncompress(void *d, void *s, int size, int block_size, int *error)
|
slaxemulator@7649
|
685 {
|
slaxemulator@7649
|
686 int res;
|
slaxemulator@7649
|
687 lzo_uint bytes = block_size;
|
slaxemulator@7649
|
688
|
slaxemulator@7649
|
689 - res = lzo1x_decompress_safe((lzo_bytep)s, size, (lzo_bytep)d, &bytes, NULL);
|
slaxemulator@7649
|
690 + res = lzo1x_decompress_safe(s, size, d, &bytes, NULL);
|
slaxemulator@7649
|
691
|
slaxemulator@7649
|
692 *error = res;
|
slaxemulator@7649
|
693 return res == LZO_E_OK ? bytes : -1;
|
slaxemulator@7649
|
694 }
|
slaxemulator@7649
|
695 +
|
slaxemulator@7649
|
696 +
|
slaxemulator@7649
|
697 +struct compressor lzo_comp_ops = {
|
slaxemulator@7649
|
698 + .init = squashfs_lzo_init,
|
slaxemulator@7649
|
699 + .compress = lzo_compress,
|
slaxemulator@7649
|
700 + .uncompress = lzo_uncompress,
|
slaxemulator@7649
|
701 + .options = NULL,
|
slaxemulator@7649
|
702 + .usage = NULL,
|
slaxemulator@7649
|
703 + .id = LZO_COMPRESSION,
|
slaxemulator@7649
|
704 + .name = "lzo",
|
slaxemulator@7649
|
705 + .supported = 1
|
slaxemulator@7649
|
706 +};
|
slaxemulator@7649
|
707 +
|
slaxemulator@7649
|
708 diff -r 2ab2996036dd squashfs-tools/mksquashfs.c
|
slaxemulator@7649
|
709 --- a/squashfs-tools/mksquashfs.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
710 +++ b/squashfs-tools/mksquashfs.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
711 @@ -384,9 +384,10 @@
|
slaxemulator@7649
|
712 #define FRAGMENT_BUFFER_DEFAULT 64
|
slaxemulator@7649
|
713 int writer_buffer_size;
|
slaxemulator@7649
|
714
|
slaxemulator@7649
|
715 -/* compression operations structure */
|
slaxemulator@7649
|
716 +/* compression operations */
|
slaxemulator@7649
|
717 static struct compressor *comp;
|
slaxemulator@7649
|
718 -char *comp_name = COMP_DEFAULT;
|
slaxemulator@7649
|
719 +int compressor_opts_parsed = 0;
|
slaxemulator@7649
|
720 +void *stream = NULL;
|
slaxemulator@7649
|
721
|
slaxemulator@7649
|
722 /* xattr stats */
|
slaxemulator@7649
|
723 unsigned int xattr_bytes = 0, total_xattr_bytes = 0;
|
slaxemulator@7649
|
724 @@ -859,7 +860,7 @@
|
slaxemulator@7649
|
725 }
|
slaxemulator@7649
|
726
|
slaxemulator@7649
|
727
|
slaxemulator@7649
|
728 -int mangle2(void **strm, char *d, char *s, int size,
|
slaxemulator@7649
|
729 +int mangle2(void *strm, char *d, char *s, int size,
|
slaxemulator@7649
|
730 int block_size, int uncompressed, int data_block)
|
slaxemulator@7649
|
731 {
|
slaxemulator@7649
|
732 int error, c_byte = 0;
|
slaxemulator@7649
|
733 @@ -884,9 +885,7 @@
|
slaxemulator@7649
|
734 int mangle(char *d, char *s, int size, int block_size,
|
slaxemulator@7649
|
735 int uncompressed, int data_block)
|
slaxemulator@7649
|
736 {
|
slaxemulator@7649
|
737 - static void *stream = NULL;
|
slaxemulator@7649
|
738 -
|
slaxemulator@7649
|
739 - return mangle2(&stream, d, s, size, block_size, uncompressed,
|
slaxemulator@7649
|
740 + return mangle2(stream, d, s, size, block_size, uncompressed,
|
slaxemulator@7649
|
741 data_block);
|
slaxemulator@7649
|
742 }
|
slaxemulator@7649
|
743
|
slaxemulator@7649
|
744 @@ -2556,11 +2555,15 @@
|
slaxemulator@7649
|
745 void *deflator(void *arg)
|
slaxemulator@7649
|
746 {
|
slaxemulator@7649
|
747 void *stream = NULL;
|
slaxemulator@7649
|
748 - int oldstate;
|
slaxemulator@7649
|
749 + int res, oldstate;
|
slaxemulator@7649
|
750
|
slaxemulator@7649
|
751 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
|
slaxemulator@7649
|
752 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
|
slaxemulator@7649
|
753
|
slaxemulator@7649
|
754 + res = compressor_init(comp, &stream, block_size, 1);
|
slaxemulator@7649
|
755 + if(res)
|
slaxemulator@7649
|
756 + BAD_ERROR("deflator:: compressor_init failed\n");
|
slaxemulator@7649
|
757 +
|
slaxemulator@7649
|
758 while(1) {
|
slaxemulator@7649
|
759 struct file_buffer *file_buffer = queue_get(from_reader);
|
slaxemulator@7649
|
760 struct file_buffer *write_buffer;
|
slaxemulator@7649
|
761 @@ -2573,7 +2576,7 @@
|
slaxemulator@7649
|
762 queue_put(from_deflate, file_buffer);
|
slaxemulator@7649
|
763 } else {
|
slaxemulator@7649
|
764 write_buffer = cache_get(writer_buffer, 0, 0);
|
slaxemulator@7649
|
765 - write_buffer->c_byte = mangle2(&stream,
|
slaxemulator@7649
|
766 + write_buffer->c_byte = mangle2(stream,
|
slaxemulator@7649
|
767 write_buffer->data, file_buffer->data,
|
slaxemulator@7649
|
768 file_buffer->size, block_size, noD, 1);
|
slaxemulator@7649
|
769 write_buffer->sequence = file_buffer->sequence;
|
slaxemulator@7649
|
770 @@ -2593,11 +2596,15 @@
|
slaxemulator@7649
|
771 void *frag_deflator(void *arg)
|
slaxemulator@7649
|
772 {
|
slaxemulator@7649
|
773 void *stream = NULL;
|
slaxemulator@7649
|
774 - int oldstate;
|
slaxemulator@7649
|
775 + int res, oldstate;
|
slaxemulator@7649
|
776
|
slaxemulator@7649
|
777 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &oldstate);
|
slaxemulator@7649
|
778 pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, &oldstate);
|
slaxemulator@7649
|
779
|
slaxemulator@7649
|
780 + res = compressor_init(comp, &stream, block_size, 1);
|
slaxemulator@7649
|
781 + if(res)
|
slaxemulator@7649
|
782 + BAD_ERROR("frag_deflator:: compressor_init failed\n");
|
slaxemulator@7649
|
783 +
|
slaxemulator@7649
|
784 while(1) {
|
slaxemulator@7649
|
785 int c_byte, compressed_size;
|
slaxemulator@7649
|
786 struct file_buffer *file_buffer = queue_get(to_frag);
|
slaxemulator@7649
|
787 @@ -2605,7 +2612,7 @@
|
slaxemulator@7649
|
788 cache_get(writer_buffer, file_buffer->block +
|
slaxemulator@7649
|
789 FRAG_INDEX, 1);
|
slaxemulator@7649
|
790
|
slaxemulator@7649
|
791 - c_byte = mangle2(&stream, write_buffer->data, file_buffer->data,
|
slaxemulator@7649
|
792 + c_byte = mangle2(stream, write_buffer->data, file_buffer->data,
|
slaxemulator@7649
|
793 file_buffer->size, block_size, noF, 1);
|
slaxemulator@7649
|
794 compressed_size = SQUASHFS_COMPRESSED_SIZE_BLOCK(c_byte);
|
slaxemulator@7649
|
795 write_buffer->size = compressed_size;
|
slaxemulator@7649
|
796 @@ -4501,7 +4508,7 @@
|
slaxemulator@7649
|
797
|
slaxemulator@7649
|
798
|
slaxemulator@7649
|
799 #define VERSION() \
|
slaxemulator@7649
|
800 - printf("mksquashfs version 4.1 (2010/09/19)\n");\
|
slaxemulator@7649
|
801 + printf("mksquashfs version 4.1-CVS (2010/12/07)\n");\
|
slaxemulator@7649
|
802 printf("copyright (C) 2010 Phillip Lougher "\
|
slaxemulator@7649
|
803 "<phillip@lougher.demon.co.uk>\n\n"); \
|
slaxemulator@7649
|
804 printf("This program is free software; you can redistribute it and/or"\
|
slaxemulator@7649
|
805 @@ -4521,7 +4528,7 @@
|
slaxemulator@7649
|
806 int main(int argc, char *argv[])
|
slaxemulator@7649
|
807 {
|
slaxemulator@7649
|
808 struct stat buf, source_buf;
|
slaxemulator@7649
|
809 - int i;
|
slaxemulator@7649
|
810 + int res, i;
|
slaxemulator@7649
|
811 squashfs_super_block sBlk;
|
slaxemulator@7649
|
812 char *b, *root_name = NULL;
|
slaxemulator@7649
|
813 int nopad = FALSE, keep_as_directory = FALSE;
|
slaxemulator@7649
|
814 @@ -4542,14 +4549,50 @@
|
slaxemulator@7649
|
815 goto printOptions;
|
slaxemulator@7649
|
816 source_path = argv + 1;
|
slaxemulator@7649
|
817 source = i - 2;
|
slaxemulator@7649
|
818 + /*
|
slaxemulator@7649
|
819 + * lookup default compressor. Note the Makefile ensures the default
|
slaxemulator@7649
|
820 + * compressor has been built, and so we don't need to to check
|
slaxemulator@7649
|
821 + * for failure here
|
slaxemulator@7649
|
822 + */
|
slaxemulator@7649
|
823 + comp = lookup_compressor(COMP_DEFAULT);
|
slaxemulator@7649
|
824 for(; i < argc; i++) {
|
slaxemulator@7649
|
825 if(strcmp(argv[i], "-comp") == 0) {
|
slaxemulator@7649
|
826 + if(compressor_opts_parsed) {
|
slaxemulator@7649
|
827 + ERROR("%s: -comp must appear before -X options"
|
slaxemulator@7649
|
828 + "\n", argv[0]);
|
slaxemulator@7649
|
829 + exit(1);
|
slaxemulator@7649
|
830 + }
|
slaxemulator@7649
|
831 if(++i == argc) {
|
slaxemulator@7649
|
832 ERROR("%s: -comp missing compression type\n",
|
slaxemulator@7649
|
833 argv[0]);
|
slaxemulator@7649
|
834 exit(1);
|
slaxemulator@7649
|
835 }
|
slaxemulator@7649
|
836 - comp_name = argv[i];
|
slaxemulator@7649
|
837 + comp = lookup_compressor(argv[i]);
|
slaxemulator@7649
|
838 + if(!comp->supported) {
|
slaxemulator@7649
|
839 + ERROR("%s: Compressor \"%s\" is not supported!"
|
slaxemulator@7649
|
840 + "\n", argv[0], argv[i]);
|
slaxemulator@7649
|
841 + ERROR("%s: Compressors available:\n", argv[0]);
|
slaxemulator@7649
|
842 + display_compressors("", COMP_DEFAULT);
|
slaxemulator@7649
|
843 + exit(1);
|
slaxemulator@7649
|
844 + }
|
slaxemulator@7649
|
845 +
|
slaxemulator@7649
|
846 + } else if(strncmp(argv[i], "-X", 2) == 0) {
|
slaxemulator@7649
|
847 + int args = compressor_options(comp, argv + i, argc - i);
|
slaxemulator@7649
|
848 + if(args < 0) {
|
slaxemulator@7649
|
849 + if(args == -1) {
|
slaxemulator@7649
|
850 + ERROR("%s: Unrecognised compressor"
|
slaxemulator@7649
|
851 + " option %s\n", argv[0],
|
slaxemulator@7649
|
852 + argv[i]);
|
slaxemulator@7649
|
853 + ERROR("%s: Did you forget to specify"
|
slaxemulator@7649
|
854 + " -comp, or specify it after"
|
slaxemulator@7649
|
855 + " the compressor specific"
|
slaxemulator@7649
|
856 + " option?\n", argv[0]);
|
slaxemulator@7649
|
857 + }
|
slaxemulator@7649
|
858 + exit(1);
|
slaxemulator@7649
|
859 + }
|
slaxemulator@7649
|
860 + i += args;
|
slaxemulator@7649
|
861 + compressor_opts_parsed = 1;
|
slaxemulator@7649
|
862 +
|
slaxemulator@7649
|
863 } else if(strcmp(argv[i], "-pf") == 0) {
|
slaxemulator@7649
|
864 if(++i == argc) {
|
slaxemulator@7649
|
865 ERROR("%s: -pf missing filename\n", argv[0]);
|
slaxemulator@7649
|
866 @@ -4857,7 +4900,7 @@
|
slaxemulator@7649
|
867 ERROR("-write-queue <size>\tSet output queue to <size> "
|
slaxemulator@7649
|
868 "Mbytes. Default %d Mbytes\n",
|
slaxemulator@7649
|
869 WRITER_BUFFER_DEFAULT);
|
slaxemulator@7649
|
870 - ERROR("-fragment-queue <size>\tSet fagment queue to "
|
slaxemulator@7649
|
871 + ERROR("-fragment-queue <size>\tSet fragment queue to "
|
slaxemulator@7649
|
872 "<size> Mbytes. Default %d Mbytes\n",
|
slaxemulator@7649
|
873 FRAGMENT_BUFFER_DEFAULT);
|
slaxemulator@7649
|
874 ERROR("\nMiscellaneous options:\n");
|
slaxemulator@7649
|
875 @@ -4871,8 +4914,9 @@
|
slaxemulator@7649
|
876 "-noF\n");
|
slaxemulator@7649
|
877 ERROR("-noXattrCompression\talternative name for "
|
slaxemulator@7649
|
878 "-noX\n");
|
slaxemulator@7649
|
879 - ERROR("\nCompressors available:\n");
|
slaxemulator@7649
|
880 - display_compressors("", COMP_DEFAULT);
|
slaxemulator@7649
|
881 + ERROR("\nCompressors available and compressor specific "
|
slaxemulator@7649
|
882 + "options:\n");
|
slaxemulator@7649
|
883 + display_compressor_usage(COMP_DEFAULT);
|
slaxemulator@7649
|
884 exit(1);
|
slaxemulator@7649
|
885 }
|
slaxemulator@7649
|
886 }
|
slaxemulator@7649
|
887 @@ -5005,19 +5049,14 @@
|
slaxemulator@7649
|
888 always_use_fragments = SQUASHFS_ALWAYS_FRAGMENTS(sBlk.flags);
|
slaxemulator@7649
|
889 duplicate_checking = SQUASHFS_DUPLICATES(sBlk.flags);
|
slaxemulator@7649
|
890 exportable = SQUASHFS_EXPORTABLE(sBlk.flags);
|
slaxemulator@7649
|
891 - } else {
|
slaxemulator@7649
|
892 - comp = lookup_compressor(comp_name);
|
slaxemulator@7649
|
893 - if(!comp->supported) {
|
slaxemulator@7649
|
894 - ERROR("FATAL_ERROR: Compressor \"%s\" is not "
|
slaxemulator@7649
|
895 - "supported!\n", comp_name);
|
slaxemulator@7649
|
896 - ERROR("Compressors available:\n");
|
slaxemulator@7649
|
897 - display_compressors("", COMP_DEFAULT);
|
slaxemulator@7649
|
898 - EXIT_MKSQUASHFS();
|
slaxemulator@7649
|
899 - }
|
slaxemulator@7649
|
900 }
|
slaxemulator@7649
|
901
|
slaxemulator@7649
|
902 initialise_threads(readb_mbytes, writeb_mbytes, fragmentb_mbytes);
|
slaxemulator@7649
|
903
|
slaxemulator@7649
|
904 + res = compressor_init(comp, &stream, SQUASHFS_METADATA_SIZE, 0);
|
slaxemulator@7649
|
905 + if(res)
|
slaxemulator@7649
|
906 + BAD_ERROR("compressor_init failed\n");
|
slaxemulator@7649
|
907 +
|
slaxemulator@7649
|
908 if(delete) {
|
slaxemulator@7649
|
909 printf("Creating %d.%d filesystem on %s, block size %d.\n",
|
slaxemulator@7649
|
910 SQUASHFS_MAJOR, s_minor, argv[source + 1], block_size);
|
slaxemulator@7649
|
911 diff -r 2ab2996036dd squashfs-tools/read_fs.c
|
slaxemulator@7649
|
912 --- a/squashfs-tools/read_fs.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
913 +++ b/squashfs-tools/read_fs.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
914 @@ -363,7 +363,8 @@
|
slaxemulator@7649
|
915 }
|
slaxemulator@7649
|
916 }
|
slaxemulator@7649
|
917
|
slaxemulator@7649
|
918 - return files;
|
slaxemulator@7649
|
919 + printf("Read existing filesystem, %d inodes scanned\n", files);
|
slaxemulator@7649
|
920 + return TRUE;
|
slaxemulator@7649
|
921
|
slaxemulator@7649
|
922
|
slaxemulator@7649
|
923 failed:
|
slaxemulator@7649
|
924 @@ -414,6 +415,7 @@
|
slaxemulator@7649
|
925 if(!comp->supported) {
|
slaxemulator@7649
|
926 ERROR("Filesystem on %s uses %s compression, this is"
|
slaxemulator@7649
|
927 "unsupported by this version\n", source, comp->name);
|
slaxemulator@7649
|
928 + ERROR("Compressors available:\n");
|
slaxemulator@7649
|
929 display_compressors("", "");
|
slaxemulator@7649
|
930 goto failed_mount;
|
slaxemulator@7649
|
931 }
|
slaxemulator@7649
|
932 @@ -691,7 +693,7 @@
|
slaxemulator@7649
|
933 SQUASHFS_INODE_BLK(sBlk->root_inode);
|
slaxemulator@7649
|
934 unsigned int root_inode_offset =
|
slaxemulator@7649
|
935 SQUASHFS_INODE_OFFSET(sBlk->root_inode);
|
slaxemulator@7649
|
936 - unsigned int root_inode_block, files;
|
slaxemulator@7649
|
937 + unsigned int root_inode_block;
|
slaxemulator@7649
|
938 squashfs_inode_header inode;
|
slaxemulator@7649
|
939 unsigned int *id_table;
|
slaxemulator@7649
|
940 int res;
|
slaxemulator@7649
|
941 @@ -711,20 +713,18 @@
|
slaxemulator@7649
|
942 if(id_table == NULL)
|
slaxemulator@7649
|
943 goto error;
|
slaxemulator@7649
|
944
|
slaxemulator@7649
|
945 - if((files = scan_inode_table(fd, start, end, root_inode_start,
|
slaxemulator@7649
|
946 - root_inode_offset, sBlk, &inode, &inode_table,
|
slaxemulator@7649
|
947 - &root_inode_block, root_inode_size, uncompressed_file,
|
slaxemulator@7649
|
948 - uncompressed_directory, file_count, sym_count,
|
slaxemulator@7649
|
949 - dev_count, dir_count, fifo_count, sock_count, id_table))
|
slaxemulator@7649
|
950 - == 0) {
|
slaxemulator@7649
|
951 + res = scan_inode_table(fd, start, end, root_inode_start,
|
slaxemulator@7649
|
952 + root_inode_offset, sBlk, &inode, &inode_table,
|
slaxemulator@7649
|
953 + &root_inode_block, root_inode_size, uncompressed_file,
|
slaxemulator@7649
|
954 + uncompressed_directory, file_count, sym_count, dev_count,
|
slaxemulator@7649
|
955 + dir_count, fifo_count, sock_count, id_table);
|
slaxemulator@7649
|
956 + if(res == 0) {
|
slaxemulator@7649
|
957 ERROR("read_filesystem: inode table read failed\n");
|
slaxemulator@7649
|
958 goto error;
|
slaxemulator@7649
|
959 }
|
slaxemulator@7649
|
960
|
slaxemulator@7649
|
961 *uncompressed_inode = root_inode_block;
|
slaxemulator@7649
|
962
|
slaxemulator@7649
|
963 - printf("Read existing filesystem, %d inodes scanned\n", files);
|
slaxemulator@7649
|
964 -
|
slaxemulator@7649
|
965 if(inode.base.inode_type == SQUASHFS_DIR_TYPE ||
|
slaxemulator@7649
|
966 inode.base.inode_type == SQUASHFS_LDIR_TYPE) {
|
slaxemulator@7649
|
967 if(inode.base.inode_type == SQUASHFS_DIR_TYPE) {
|
slaxemulator@7649
|
968 diff -r 2ab2996036dd squashfs-tools/squashfs_fs.h
|
slaxemulator@7649
|
969 --- a/squashfs-tools/squashfs_fs.h Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
970 +++ b/squashfs-tools/squashfs_fs.h Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
971 @@ -259,6 +259,7 @@
|
slaxemulator@7649
|
972 #define ZLIB_COMPRESSION 1
|
slaxemulator@7649
|
973 #define LZMA_COMPRESSION 2
|
slaxemulator@7649
|
974 #define LZO_COMPRESSION 3
|
slaxemulator@7649
|
975 +#define XZ_COMPRESSION 4
|
slaxemulator@7649
|
976
|
slaxemulator@7649
|
977 struct squashfs_super_block {
|
slaxemulator@7649
|
978 unsigned int s_magic;
|
slaxemulator@7649
|
979 diff -r 2ab2996036dd squashfs-tools/unsquash-1.c
|
slaxemulator@7649
|
980 --- a/squashfs-tools/unsquash-1.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
981 +++ b/squashfs-tools/unsquash-1.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
982 @@ -138,7 +138,7 @@
|
slaxemulator@7649
|
983
|
slaxemulator@7649
|
984 i.data = inode->file_size;
|
slaxemulator@7649
|
985 i.time = inode->mtime;
|
slaxemulator@7649
|
986 - i.blocks = (inode->file_size + sBlk.s.block_size - 1) >>
|
slaxemulator@7649
|
987 + i.blocks = (i.data + sBlk.s.block_size - 1) >>
|
slaxemulator@7649
|
988 sBlk.s.block_log;
|
slaxemulator@7649
|
989 i.start = inode->start_block;
|
slaxemulator@7649
|
990 i.block_ptr = block_ptr + sizeof(*inode);
|
slaxemulator@7649
|
991 diff -r 2ab2996036dd squashfs-tools/unsquash-2.c
|
slaxemulator@7649
|
992 --- a/squashfs-tools/unsquash-2.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
993 +++ b/squashfs-tools/unsquash-2.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
994 @@ -205,8 +205,8 @@
|
slaxemulator@7649
|
995 i.fragment = inode->fragment;
|
slaxemulator@7649
|
996 i.offset = inode->offset;
|
slaxemulator@7649
|
997 i.blocks = inode->fragment == SQUASHFS_INVALID_FRAG ?
|
slaxemulator@7649
|
998 - (inode->file_size + sBlk.s.block_size - 1) >>
|
slaxemulator@7649
|
999 - sBlk.s.block_log : inode->file_size >>
|
slaxemulator@7649
|
1000 + (i.data + sBlk.s.block_size - 1) >>
|
slaxemulator@7649
|
1001 + sBlk.s.block_log : i.data >>
|
slaxemulator@7649
|
1002 sBlk.s.block_log;
|
slaxemulator@7649
|
1003 i.start = inode->start_block;
|
slaxemulator@7649
|
1004 i.sparse = 0;
|
slaxemulator@7649
|
1005 diff -r 2ab2996036dd squashfs-tools/unsquash-3.c
|
slaxemulator@7649
|
1006 --- a/squashfs-tools/unsquash-3.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
1007 +++ b/squashfs-tools/unsquash-3.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
1008 @@ -188,9 +188,9 @@
|
slaxemulator@7649
|
1009 i.fragment = inode->fragment;
|
slaxemulator@7649
|
1010 i.offset = inode->offset;
|
slaxemulator@7649
|
1011 i.blocks = inode->fragment == SQUASHFS_INVALID_FRAG ?
|
slaxemulator@7649
|
1012 - (inode->file_size + sBlk.s.block_size - 1) >>
|
slaxemulator@7649
|
1013 + (i.data + sBlk.s.block_size - 1) >>
|
slaxemulator@7649
|
1014 sBlk.s.block_log :
|
slaxemulator@7649
|
1015 - inode->file_size >> sBlk.s.block_log;
|
slaxemulator@7649
|
1016 + i.data >> sBlk.s.block_log;
|
slaxemulator@7649
|
1017 i.start = inode->start_block;
|
slaxemulator@7649
|
1018 i.sparse = 1;
|
slaxemulator@7649
|
1019 i.block_ptr = block_ptr + sizeof(*inode);
|
slaxemulator@7649
|
1020 diff -r 2ab2996036dd squashfs-tools/unsquash-4.c
|
slaxemulator@7649
|
1021 --- a/squashfs-tools/unsquash-4.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
1022 +++ b/squashfs-tools/unsquash-4.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
1023 @@ -143,9 +143,9 @@
|
slaxemulator@7649
|
1024 i.fragment = inode->fragment;
|
slaxemulator@7649
|
1025 i.offset = inode->offset;
|
slaxemulator@7649
|
1026 i.blocks = inode->fragment == SQUASHFS_INVALID_FRAG ?
|
slaxemulator@7649
|
1027 - (inode->file_size + sBlk.s.block_size - 1) >>
|
slaxemulator@7649
|
1028 + (i.data + sBlk.s.block_size - 1) >>
|
slaxemulator@7649
|
1029 sBlk.s.block_log :
|
slaxemulator@7649
|
1030 - inode->file_size >> sBlk.s.block_log;
|
slaxemulator@7649
|
1031 + i.data >> sBlk.s.block_log;
|
slaxemulator@7649
|
1032 i.start = inode->start_block;
|
slaxemulator@7649
|
1033 i.sparse = 0;
|
slaxemulator@7649
|
1034 i.block_ptr = block_ptr + sizeof(*inode);
|
slaxemulator@7649
|
1035 diff -r 2ab2996036dd squashfs-tools/unsquashfs.c
|
slaxemulator@7649
|
1036 --- a/squashfs-tools/unsquashfs.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
1037 +++ b/squashfs-tools/unsquashfs.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
1038 @@ -737,7 +737,7 @@
|
slaxemulator@7649
|
1039 int lseek_broken = FALSE;
|
slaxemulator@7649
|
1040 char *zero_data = NULL;
|
slaxemulator@7649
|
1041
|
slaxemulator@7649
|
1042 -int write_block(int file_fd, char *buffer, int size, int hole, int sparse)
|
slaxemulator@7649
|
1043 +int write_block(int file_fd, char *buffer, int size, long long hole, int sparse)
|
slaxemulator@7649
|
1044 {
|
slaxemulator@7649
|
1045 off_t off = hole;
|
slaxemulator@7649
|
1046
|
slaxemulator@7649
|
1047 @@ -1299,9 +1299,12 @@
|
slaxemulator@7649
|
1048 print_filename(parent_name, i);
|
slaxemulator@7649
|
1049
|
slaxemulator@7649
|
1050 if(!lsonly && mkdir(parent_name, (mode_t) dir->mode) == -1 &&
|
slaxemulator@7649
|
1051 - (!force || errno != EEXIST))
|
slaxemulator@7649
|
1052 - ERROR("dir_scan: failed to open directory %s, because %s\n",
|
slaxemulator@7649
|
1053 + (!force || errno != EEXIST)) {
|
slaxemulator@7649
|
1054 + ERROR("dir_scan: failed to make directory %s, because %s\n",
|
slaxemulator@7649
|
1055 parent_name, strerror(errno));
|
slaxemulator@7649
|
1056 + squashfs_closedir(dir);
|
slaxemulator@7649
|
1057 + return;
|
slaxemulator@7649
|
1058 + }
|
slaxemulator@7649
|
1059
|
slaxemulator@7649
|
1060 while(squashfs_readdir(dir, &name, &start_block, &offset, &type)) {
|
slaxemulator@7649
|
1061 TRACE("dir_scan: name %s, start_block %d, offset %d, type %d\n",
|
slaxemulator@7649
|
1062 @@ -1604,7 +1607,7 @@
|
slaxemulator@7649
|
1063 while(1) {
|
slaxemulator@7649
|
1064 struct squashfs_file *file = queue_get(to_writer);
|
slaxemulator@7649
|
1065 int file_fd;
|
slaxemulator@7649
|
1066 - int hole = 0;
|
slaxemulator@7649
|
1067 + long long hole = 0;
|
slaxemulator@7649
|
1068 int failed = FALSE;
|
slaxemulator@7649
|
1069 int error;
|
slaxemulator@7649
|
1070
|
slaxemulator@7649
|
1071 @@ -1903,7 +1906,7 @@
|
slaxemulator@7649
|
1072
|
slaxemulator@7649
|
1073
|
slaxemulator@7649
|
1074 #define VERSION() \
|
slaxemulator@7649
|
1075 - printf("unsquashfs version 4.1 (2010/09/19)\n");\
|
slaxemulator@7649
|
1076 + printf("unsquashfs version 4.1-CVS (2010/10/23)\n");\
|
slaxemulator@7649
|
1077 printf("copyright (C) 2010 Phillip Lougher "\
|
slaxemulator@7649
|
1078 "<phillip@lougher.demon.co.uk>\n\n");\
|
slaxemulator@7649
|
1079 printf("This program is free software; you can redistribute it and/or"\
|
slaxemulator@7649
|
1080 @@ -2081,7 +2084,7 @@
|
slaxemulator@7649
|
1081 ERROR("\t-da[ta-queue] <size>\tSet data queue to "
|
slaxemulator@7649
|
1082 "<size> Mbytes. Default %d\n\t\t\t\tMbytes\n",
|
slaxemulator@7649
|
1083 DATA_BUFFER_DEFAULT);
|
slaxemulator@7649
|
1084 - ERROR("\t-fr[ag-queue] <size>\tSet fagment queue to "
|
slaxemulator@7649
|
1085 + ERROR("\t-fr[ag-queue] <size>\tSet fragment queue to "
|
slaxemulator@7649
|
1086 "<size> Mbytes. Default %d\n\t\t\t\t Mbytes\n",
|
slaxemulator@7649
|
1087 FRAGMENT_BUFFER_DEFAULT);
|
slaxemulator@7649
|
1088 ERROR("\t-r[egex]\t\ttreat extract names as POSIX "
|
slaxemulator@7649
|
1089 diff -r 2ab2996036dd squashfs-tools/unsquashfs_xattr.c
|
slaxemulator@7649
|
1090 --- a/squashfs-tools/unsquashfs_xattr.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
1091 +++ b/squashfs-tools/unsquashfs_xattr.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
1092 @@ -25,7 +25,7 @@
|
slaxemulator@7649
|
1093 #include "unsquashfs.h"
|
slaxemulator@7649
|
1094 #include "xattr.h"
|
slaxemulator@7649
|
1095
|
slaxemulator@7649
|
1096 -#include <attr/xattr.h>
|
slaxemulator@7649
|
1097 +#include <sys/xattr.h>
|
slaxemulator@7649
|
1098
|
slaxemulator@7649
|
1099 extern int root_process;
|
slaxemulator@7649
|
1100
|
slaxemulator@7649
|
1101 diff -r 2ab2996036dd squashfs-tools/xattr.c
|
slaxemulator@7649
|
1102 --- a/squashfs-tools/xattr.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
1103 +++ b/squashfs-tools/xattr.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
1104 @@ -34,7 +34,7 @@
|
slaxemulator@7649
|
1105 #include <dirent.h>
|
slaxemulator@7649
|
1106 #include <string.h>
|
slaxemulator@7649
|
1107 #include <stdlib.h>
|
slaxemulator@7649
|
1108 -#include <attr/xattr.h>
|
slaxemulator@7649
|
1109 +#include <sys/xattr.h>
|
slaxemulator@7649
|
1110
|
slaxemulator@7649
|
1111 #include "squashfs_fs.h"
|
slaxemulator@7649
|
1112 #include "global.h"
|
slaxemulator@7649
|
1113 @@ -219,6 +219,10 @@
|
slaxemulator@7649
|
1114 break;
|
slaxemulator@7649
|
1115 }
|
slaxemulator@7649
|
1116 xattr_list[i].vsize = vsize;
|
slaxemulator@7649
|
1117 +
|
slaxemulator@7649
|
1118 + TRACE("read_xattrs_from_system: filename %s, xattr name %s,"
|
slaxemulator@7649
|
1119 + " vsize %d\n", filename, xattr_list[i].full_name,
|
slaxemulator@7649
|
1120 + xattr_list[i].vsize);
|
slaxemulator@7649
|
1121 }
|
slaxemulator@7649
|
1122 free(xattr_names);
|
slaxemulator@7649
|
1123 *xattrs = xattr_list;
|
slaxemulator@7649
|
1124 diff -r 2ab2996036dd squashfs-tools/xz_wrapper.c
|
slaxemulator@7649
|
1125 --- a/squashfs-tools/xz_wrapper.c Tue Dec 14 12:19:33 2010 +0000
|
slaxemulator@7649
|
1126 +++ b/squashfs-tools/xz_wrapper.c Tue Dec 14 14:18:11 2010 +0000
|
slaxemulator@7649
|
1127 @@ -17,69 +17,192 @@
|
slaxemulator@7649
|
1128 * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
slaxemulator@7649
|
1129 *
|
slaxemulator@7649
|
1130 * xz_wrapper.c
|
slaxemulator@7649
|
1131 + *
|
slaxemulator@7649
|
1132 + * Support for XZ (LZMA2) compression using XZ Utils liblzma http://tukaani.org/xz/
|
slaxemulator@7649
|
1133 */
|
slaxemulator@7649
|
1134
|
slaxemulator@7649
|
1135 #include <stdio.h>
|
slaxemulator@7649
|
1136 #include <string.h>
|
slaxemulator@7649
|
1137 +#include <stdlib.h>
|
slaxemulator@7649
|
1138 #include <lzma.h>
|
slaxemulator@7649
|
1139
|
slaxemulator@7649
|
1140 -#define LZMA_PROPS_SIZE 5
|
slaxemulator@7649
|
1141 -#define LZMA_UNCOMP_SIZE 8
|
slaxemulator@7649
|
1142 -#define LZMA_HEADER_SIZE (LZMA_PROPS_SIZE + LZMA_UNCOMP_SIZE)
|
slaxemulator@7649
|
1143 +#include "squashfs_fs.h"
|
slaxemulator@7649
|
1144 +#include "compressor.h"
|
slaxemulator@7649
|
1145
|
slaxemulator@7649
|
1146 -#define LZMA_OPTIONS 5
|
slaxemulator@7649
|
1147 #define MEMLIMIT (32 * 1024 * 1024)
|
slaxemulator@7649
|
1148
|
slaxemulator@7649
|
1149 -int lzma_compress(void **dummy, void *dest, void *src, int size,
|
slaxemulator@7649
|
1150 +static struct bcj {
|
slaxemulator@7649
|
1151 + char *name;
|
slaxemulator@7649
|
1152 + lzma_vli id;
|
slaxemulator@7649
|
1153 + int selected;
|
slaxemulator@7649
|
1154 +} bcj[] = {
|
slaxemulator@7649
|
1155 + { "x86", LZMA_FILTER_X86, 0 },
|
slaxemulator@7649
|
1156 + { "powerpc", LZMA_FILTER_POWERPC, 0 },
|
slaxemulator@7649
|
1157 + { "ia64", LZMA_FILTER_IA64, 0 },
|
slaxemulator@7649
|
1158 + { "arm", LZMA_FILTER_ARM, 0 },
|
slaxemulator@7649
|
1159 + { "armthumb", LZMA_FILTER_ARMTHUMB, 0 },
|
slaxemulator@7649
|
1160 + { "sparc", LZMA_FILTER_SPARC, 0 },
|
slaxemulator@7649
|
1161 + { NULL, LZMA_VLI_UNKNOWN, 0 }
|
slaxemulator@7649
|
1162 +};
|
slaxemulator@7649
|
1163 +
|
slaxemulator@7649
|
1164 +struct filter {
|
slaxemulator@7649
|
1165 + void *buffer;
|
slaxemulator@7649
|
1166 + lzma_filter filter[3];
|
slaxemulator@7649
|
1167 + size_t length;
|
slaxemulator@7649
|
1168 +};
|
slaxemulator@7649
|
1169 +
|
slaxemulator@7649
|
1170 +struct xz_stream {
|
slaxemulator@7649
|
1171 + struct filter *filter;
|
slaxemulator@7649
|
1172 + int filters;
|
slaxemulator@7649
|
1173 + lzma_options_lzma opt;
|
slaxemulator@7649
|
1174 +};
|
slaxemulator@7649
|
1175 +
|
slaxemulator@7649
|
1176 +static int filter_count = 1;
|
slaxemulator@7649
|
1177 +
|
slaxemulator@7649
|
1178 +
|
slaxemulator@7649
|
1179 +static int xz_options(char *argv[], int argc)
|
slaxemulator@7649
|
1180 +{
|
slaxemulator@7649
|
1181 + int i;
|
slaxemulator@7649
|
1182 + char *name;
|
slaxemulator@7649
|
1183 +
|
slaxemulator@7649
|
1184 + if(strcmp(argv[0], "-Xbcj") == 0) {
|
slaxemulator@7649
|
1185 + if(argc < 2) {
|
slaxemulator@7649
|
1186 + fprintf(stderr, "xz: -Xbcj missing filter\n");
|
slaxemulator@7649
|
1187 + goto failed;
|
slaxemulator@7649
|
1188 + }
|
slaxemulator@7649
|
1189 +
|
slaxemulator@7649
|
1190 + name = argv[1];
|
slaxemulator@7649
|
1191 + while(name[0] != '\0') {
|
slaxemulator@7649
|
1192 + for(i = 0; bcj[i].name; i++) {
|
slaxemulator@7649
|
1193 + int n = strlen(bcj[i].name);
|
slaxemulator@7649
|
1194 + if((strncmp(name, bcj[i].name, n) == 0) &&
|
slaxemulator@7649
|
1195 + (name[n] == '\0' ||
|
slaxemulator@7649
|
1196 + name[n] == ',')) {
|
slaxemulator@7649
|
1197 + if(bcj[i].selected == 0) {
|
slaxemulator@7649
|
1198 + bcj[i].selected = 1;
|
slaxemulator@7649
|
1199 + filter_count++;
|
slaxemulator@7649
|
1200 + }
|
slaxemulator@7649
|
1201 + name += name[n] == ',' ? n + 1 : n;
|
slaxemulator@7649
|
1202 + break;
|
slaxemulator@7649
|
1203 + }
|
slaxemulator@7649
|
1204 + }
|
slaxemulator@7649
|
1205 + if(bcj[i].name == NULL) {
|
slaxemulator@7649
|
1206 + fprintf(stderr, "xz: -Xbcj unrecognised filter\n");
|
slaxemulator@7649
|
1207 + goto failed;
|
slaxemulator@7649
|
1208 + }
|
slaxemulator@7649
|
1209 + }
|
slaxemulator@7649
|
1210 +
|
slaxemulator@7649
|
1211 + return 1;
|
slaxemulator@7649
|
1212 + }
|
slaxemulator@7649
|
1213 +
|
slaxemulator@7649
|
1214 + return -1;
|
slaxemulator@7649
|
1215 +
|
slaxemulator@7649
|
1216 +failed:
|
slaxemulator@7649
|
1217 + return -2;
|
slaxemulator@7649
|
1218 +}
|
slaxemulator@7649
|
1219 +
|
slaxemulator@7649
|
1220 +
|
slaxemulator@7649
|
1221 +void xz_usage()
|
slaxemulator@7649
|
1222 +{
|
slaxemulator@7649
|
1223 + fprintf(stderr, "\t -Xbcj filter1,filter2,...,filterN\n");
|
slaxemulator@7649
|
1224 + fprintf(stderr, "\t\tCompress using filter1,filter2,...,filterN in");
|
slaxemulator@7649
|
1225 + fprintf(stderr, " turn\n\t\t(in addition to no filter), and choose");
|
slaxemulator@7649
|
1226 + fprintf(stderr, " the best compression.\n");
|
slaxemulator@7649
|
1227 + fprintf(stderr, "\t\tAvailable filters: x86, arm, armthumb,");
|
slaxemulator@7649
|
1228 + fprintf(stderr, " powerpc, sparc, ia64\n");
|
slaxemulator@7649
|
1229 +}
|
slaxemulator@7649
|
1230 +
|
slaxemulator@7649
|
1231 +
|
slaxemulator@7649
|
1232 +static int xz_init(void **strm, int block_size, int flags)
|
slaxemulator@7649
|
1233 +{
|
slaxemulator@7649
|
1234 + int i, j, filters = flags ? filter_count : 1;
|
slaxemulator@7649
|
1235 + struct filter *filter = malloc(filters * sizeof(struct filter));
|
slaxemulator@7649
|
1236 + struct xz_stream *stream;
|
slaxemulator@7649
|
1237 +
|
slaxemulator@7649
|
1238 + if(filter == NULL)
|
slaxemulator@7649
|
1239 + goto failed;
|
slaxemulator@7649
|
1240 +
|
slaxemulator@7649
|
1241 + stream = *strm = malloc(sizeof(struct xz_stream));
|
slaxemulator@7649
|
1242 + if(stream == NULL)
|
slaxemulator@7649
|
1243 + goto failed2;
|
slaxemulator@7649
|
1244 +
|
slaxemulator@7649
|
1245 + stream->filter = filter;
|
slaxemulator@7649
|
1246 + stream->filters = filters;
|
slaxemulator@7649
|
1247 +
|
slaxemulator@7649
|
1248 + memset(filter, 0, filters * sizeof(struct filter));
|
slaxemulator@7649
|
1249 +
|
slaxemulator@7649
|
1250 + filter[0].filter[0].id = LZMA_FILTER_LZMA2;
|
slaxemulator@7649
|
1251 + filter[0].filter[0].options = &stream->opt;
|
slaxemulator@7649
|
1252 + filter[0].filter[1].id = LZMA_VLI_UNKNOWN;
|
slaxemulator@7649
|
1253 +
|
slaxemulator@7649
|
1254 + for(i = 0, j = 1; flags && bcj[i].name; i++) {
|
slaxemulator@7649
|
1255 + if(bcj[i].selected) {
|
slaxemulator@7649
|
1256 + filter[j].buffer = malloc(block_size);
|
slaxemulator@7649
|
1257 + if(filter[j].buffer == NULL)
|
slaxemulator@7649
|
1258 + goto failed3;
|
slaxemulator@7649
|
1259 + filter[j].filter[0].id = bcj[i].id;
|
slaxemulator@7649
|
1260 + filter[j].filter[1].id = LZMA_FILTER_LZMA2;
|
slaxemulator@7649
|
1261 + filter[j].filter[1].options = &stream->opt;
|
slaxemulator@7649
|
1262 + filter[j].filter[2].id = LZMA_VLI_UNKNOWN;
|
slaxemulator@7649
|
1263 + j++;
|
slaxemulator@7649
|
1264 + }
|
slaxemulator@7649
|
1265 + }
|
slaxemulator@7649
|
1266 +
|
slaxemulator@7649
|
1267 + return 0;
|
slaxemulator@7649
|
1268 +
|
slaxemulator@7649
|
1269 +failed3:
|
slaxemulator@7649
|
1270 + for(i = 1; i < filters; i++)
|
slaxemulator@7649
|
1271 + free(filter[i].buffer);
|
slaxemulator@7649
|
1272 + free(stream);
|
slaxemulator@7649
|
1273 +
|
slaxemulator@7649
|
1274 +failed2:
|
slaxemulator@7649
|
1275 + free(filter);
|
slaxemulator@7649
|
1276 +
|
slaxemulator@7649
|
1277 +failed:
|
slaxemulator@7649
|
1278 + return -1;
|
slaxemulator@7649
|
1279 +}
|
slaxemulator@7649
|
1280 +
|
slaxemulator@7649
|
1281 +
|
slaxemulator@7649
|
1282 +static int xz_compress(void *strm, void *dest, void *src, int size,
|
slaxemulator@7649
|
1283 int block_size, int *error)
|
slaxemulator@7649
|
1284 {
|
slaxemulator@7649
|
1285 - unsigned char *d = (unsigned char *) dest;
|
slaxemulator@7649
|
1286 - lzma_options_lzma opt;
|
slaxemulator@7649
|
1287 - lzma_stream strm = LZMA_STREAM_INIT;
|
slaxemulator@7649
|
1288 - int res;
|
slaxemulator@7649
|
1289 + int i;
|
slaxemulator@7649
|
1290 + lzma_ret res = 0;
|
slaxemulator@7649
|
1291 + struct xz_stream *stream = strm;
|
slaxemulator@7649
|
1292 + struct filter *selected = NULL;
|
slaxemulator@7649
|
1293
|
slaxemulator@7649
|
1294 - lzma_lzma_preset(&opt, LZMA_OPTIONS);
|
slaxemulator@7649
|
1295 - opt.dict_size = block_size;
|
slaxemulator@7649
|
1296 - res = lzma_alone_encoder(&strm, &opt);
|
slaxemulator@7649
|
1297 - if(res != LZMA_OK) {
|
slaxemulator@7649
|
1298 - lzma_end(&strm);
|
slaxemulator@7649
|
1299 - goto failed;
|
slaxemulator@7649
|
1300 + stream->filter[0].buffer = dest;
|
slaxemulator@7649
|
1301 +
|
slaxemulator@7649
|
1302 + for(i = 0; i < stream->filters; i++) {
|
slaxemulator@7649
|
1303 + struct filter *filter = &stream->filter[i];
|
slaxemulator@7649
|
1304 +
|
slaxemulator@7649
|
1305 + if(lzma_lzma_preset(&stream->opt, LZMA_PRESET_DEFAULT))
|
slaxemulator@7649
|
1306 + goto failed;
|
slaxemulator@7649
|
1307 +
|
slaxemulator@7649
|
1308 + stream->opt.dict_size = block_size;
|
slaxemulator@7649
|
1309 + filter->length = 0;
|
slaxemulator@7649
|
1310 + res = lzma_stream_buffer_encode(filter->filter,
|
slaxemulator@7649
|
1311 + LZMA_CHECK_CRC32, NULL, src, size, filter->buffer,
|
slaxemulator@7649
|
1312 + &filter->length, block_size);
|
slaxemulator@7649
|
1313 +
|
slaxemulator@7649
|
1314 + if(res == LZMA_OK) {
|
slaxemulator@7649
|
1315 + if(!selected || selected->length > filter->length)
|
slaxemulator@7649
|
1316 + selected = filter;
|
slaxemulator@7649
|
1317 + } else if(res != LZMA_BUF_ERROR)
|
slaxemulator@7649
|
1318 + goto failed;
|
slaxemulator@7649
|
1319 }
|
slaxemulator@7649
|
1320
|
slaxemulator@7649
|
1321 - strm.next_out = dest;
|
slaxemulator@7649
|
1322 - strm.avail_out = block_size;
|
slaxemulator@7649
|
1323 - strm.next_in = src;
|
slaxemulator@7649
|
1324 - strm.avail_in = size;
|
slaxemulator@7649
|
1325 -
|
slaxemulator@7649
|
1326 - res = lzma_code(&strm, LZMA_FINISH);
|
slaxemulator@7649
|
1327 - lzma_end(&strm);
|
slaxemulator@7649
|
1328 -
|
slaxemulator@7649
|
1329 - if(res == LZMA_STREAM_END) {
|
slaxemulator@7649
|
1330 - /*
|
slaxemulator@7649
|
1331 - * Fill in the 8 byte little endian uncompressed size field in
|
slaxemulator@7649
|
1332 - * the LZMA header. 8 bytes is excessively large for squashfs
|
slaxemulator@7649
|
1333 - * but this is the standard LZMA header and which is expected by
|
slaxemulator@7649
|
1334 - * the kernel code
|
slaxemulator@7649
|
1335 - */
|
slaxemulator@7649
|
1336 -
|
slaxemulator@7649
|
1337 - d[LZMA_PROPS_SIZE] = size & 255;
|
slaxemulator@7649
|
1338 - d[LZMA_PROPS_SIZE + 1] = (size >> 8) & 255;
|
slaxemulator@7649
|
1339 - d[LZMA_PROPS_SIZE + 2] = (size >> 16) & 255;
|
slaxemulator@7649
|
1340 - d[LZMA_PROPS_SIZE + 3] = (size >> 24) & 255;
|
slaxemulator@7649
|
1341 - d[LZMA_PROPS_SIZE + 4] = 0;
|
slaxemulator@7649
|
1342 - d[LZMA_PROPS_SIZE + 5] = 0;
|
slaxemulator@7649
|
1343 - d[LZMA_PROPS_SIZE + 6] = 0;
|
slaxemulator@7649
|
1344 - d[LZMA_PROPS_SIZE + 7] = 0;
|
slaxemulator@7649
|
1345 -
|
slaxemulator@7649
|
1346 - return (int) strm.total_out;
|
slaxemulator@7649
|
1347 - }
|
slaxemulator@7649
|
1348 -
|
slaxemulator@7649
|
1349 - if(res == LZMA_OK)
|
slaxemulator@7649
|
1350 + if(!selected)
|
slaxemulator@7649
|
1351 /*
|
slaxemulator@7649
|
1352 * Output buffer overflow. Return out of buffer space
|
slaxemulator@7649
|
1353 */
|
slaxemulator@7649
|
1354 return 0;
|
slaxemulator@7649
|
1355
|
slaxemulator@7649
|
1356 + if(selected->buffer != dest)
|
slaxemulator@7649
|
1357 + memcpy(dest, selected->buffer, selected->length);
|
slaxemulator@7649
|
1358 +
|
slaxemulator@7649
|
1359 + return (int) selected->length;
|
slaxemulator@7649
|
1360 +
|
slaxemulator@7649
|
1361 failed:
|
slaxemulator@7649
|
1362 /*
|
slaxemulator@7649
|
1363 * All other errors return failure, with the compressor
|
slaxemulator@7649
|
1364 @@ -90,49 +213,29 @@
|
slaxemulator@7649
|
1365 }
|
slaxemulator@7649
|
1366
|
slaxemulator@7649
|
1367
|
slaxemulator@7649
|
1368 -int lzma_uncompress(void *dest, void *src, int size, int block_size,
|
slaxemulator@7649
|
1369 +static int xz_uncompress(void *dest, void *src, int size, int block_size,
|
slaxemulator@7649
|
1370 int *error)
|
slaxemulator@7649
|
1371 {
|
slaxemulator@7649
|
1372 - lzma_stream strm = LZMA_STREAM_INIT;
|
slaxemulator@7649
|
1373 - int uncompressed_size = 0, res;
|
slaxemulator@7649
|
1374 - unsigned char lzma_header[LZMA_HEADER_SIZE];
|
slaxemulator@7649
|
1375 + size_t src_pos = 0;
|
slaxemulator@7649
|
1376 + size_t dest_pos = 0;
|
slaxemulator@7649
|
1377 + uint64_t memlimit = MEMLIMIT;
|
slaxemulator@7649
|
1378
|
slaxemulator@7649
|
1379 - res = lzma_alone_decoder(&strm, MEMLIMIT);
|
slaxemulator@7649
|
1380 - if(res != LZMA_OK) {
|
slaxemulator@7649
|
1381 - lzma_end(&strm);
|
slaxemulator@7649
|
1382 - goto failed;
|
slaxemulator@7649
|
1383 - }
|
slaxemulator@7649
|
1384 + lzma_ret res = lzma_stream_buffer_decode(&memlimit, 0, NULL,
|
slaxemulator@7649
|
1385 + src, &src_pos, size, dest, &dest_pos, block_size);
|
slaxemulator@7649
|
1386
|
slaxemulator@7649
|
1387 - memcpy(lzma_header, src, LZMA_HEADER_SIZE);
|
slaxemulator@7649
|
1388 - uncompressed_size = lzma_header[LZMA_PROPS_SIZE] |
|
slaxemulator@7649
|
1389 - (lzma_header[LZMA_PROPS_SIZE + 1] << 8) |
|
slaxemulator@7649
|
1390 - (lzma_header[LZMA_PROPS_SIZE + 2] << 16) |
|
slaxemulator@7649
|
1391 - (lzma_header[LZMA_PROPS_SIZE + 3] << 24);
|
slaxemulator@7649
|
1392 - memset(lzma_header + LZMA_PROPS_SIZE, 255, LZMA_UNCOMP_SIZE);
|
slaxemulator@7649
|
1393 + *error = res;
|
slaxemulator@7649
|
1394 + return res == LZMA_OK && size == (int) src_pos ? (int) dest_pos : -1;
|
slaxemulator@7649
|
1395 +}
|
slaxemulator@7649
|
1396
|
slaxemulator@7649
|
1397 - strm.next_out = dest;
|
slaxemulator@7649
|
1398 - strm.avail_out = block_size;
|
slaxemulator@7649
|
1399 - strm.next_in = lzma_header;
|
slaxemulator@7649
|
1400 - strm.avail_in = LZMA_HEADER_SIZE;
|
slaxemulator@7649
|
1401
|
slaxemulator@7649
|
1402 - res = lzma_code(&strm, LZMA_RUN);
|
slaxemulator@7649
|
1403 +struct compressor xz_comp_ops = {
|
slaxemulator@7649
|
1404 + .init = xz_init,
|
slaxemulator@7649
|
1405 + .compress = xz_compress,
|
slaxemulator@7649
|
1406 + .uncompress = xz_uncompress,
|
slaxemulator@7649
|
1407 + .options = xz_options,
|
slaxemulator@7649
|
1408 + .usage = xz_usage,
|
slaxemulator@7649
|
1409 + .id = XZ_COMPRESSION,
|
slaxemulator@7649
|
1410 + .name = "xz",
|
slaxemulator@7649
|
1411 + .supported = 1
|
slaxemulator@7649
|
1412 +};
|
slaxemulator@7649
|
1413
|
slaxemulator@7649
|
1414 - if(res != LZMA_OK || strm.avail_in != 0) {
|
slaxemulator@7649
|
1415 - lzma_end(&strm);
|
slaxemulator@7649
|
1416 - goto failed;
|
slaxemulator@7649
|
1417 - }
|
slaxemulator@7649
|
1418 -
|
slaxemulator@7649
|
1419 - strm.next_in = src + LZMA_HEADER_SIZE;
|
slaxemulator@7649
|
1420 - strm.avail_in = size - LZMA_HEADER_SIZE;
|
slaxemulator@7649
|
1421 -
|
slaxemulator@7649
|
1422 - res = lzma_code(&strm, LZMA_FINISH);
|
slaxemulator@7649
|
1423 - lzma_end(&strm);
|
slaxemulator@7649
|
1424 -
|
slaxemulator@7649
|
1425 - if(res == LZMA_STREAM_END || (res == LZMA_OK &&
|
slaxemulator@7649
|
1426 - strm.total_out >= uncompressed_size && strm.avail_in == 0))
|
slaxemulator@7649
|
1427 - return uncompressed_size;
|
slaxemulator@7649
|
1428 -
|
slaxemulator@7649
|
1429 -failed:
|
slaxemulator@7649
|
1430 - *error = res;
|
slaxemulator@7649
|
1431 - return -1;
|
slaxemulator@7649
|
1432 -}
|