wok-6.x annotate linux/stuff/linux-squashfs-lzma-2.6.34.u @ rev 8825

Fix tazchroot receipt
author Christophe Lincoln <pankso@slitaz.org>
date Thu Feb 24 03:37:30 2011 +0100 (2011-02-24)
parents 0c80e5eb512d
children
rev   line source
pascal@5691 1 --- linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h
pascal@5691 2 +++ linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h
pascal@5691 3 @@ -0,0 +1,13 @@
pascal@5691 4 +#ifndef BUNZIP2_MM_H
pascal@5691 5 +#define BUNZIP2_MM_H
pascal@5691 6 +
pascal@5691 7 +#ifdef STATIC
pascal@5691 8 +/* Code active when included from pre-boot environment: */
pascal@5691 9 +#define INIT
pascal@5691 10 +#else
pascal@5691 11 +/* Compile for initramfs/initrd code only */
pascal@5691 12 +#define INIT __init
pascal@5691 13 +static void(*error)(char *m);
pascal@5691 14 +#endif
pascal@5691 15 +
pascal@5691 16 +#endif
pascal@5691 17
pascal@5691 18 --- linux-2.6.30.6/include/linux/decompress/inflate_mm.h
pascal@5691 19 +++ linux-2.6.30.6/include/linux/decompress/inflate_mm.h
pascal@5691 20 @@ -0,0 +1,13 @@
pascal@5691 21 +#ifndef INFLATE_MM_H
pascal@5691 22 +#define INFLATE_MM_H
pascal@5691 23 +
pascal@5691 24 +#ifdef STATIC
pascal@5691 25 +/* Code active when included from pre-boot environment: */
pascal@5691 26 +#define INIT
pascal@5691 27 +#else
pascal@5691 28 +/* Compile for initramfs/initrd code only */
pascal@5691 29 +#define INIT __init
pascal@5691 30 +static void(*error)(char *m);
pascal@5691 31 +#endif
pascal@5691 32 +
pascal@5691 33 +#endif
pascal@5691 34
pascal@5691 35 #--- linux-2.6.30.6/include/linux/decompress/mm.h
pascal@5691 36 #+++ linux-2.6.30.6/include/linux/decompress/mm.h
pascal@5691 37 @@ -63,8 +63,6 @@
pascal@5691 38
pascal@5691 39 #define set_error_fn(x)
pascal@5691 40
pascal@5691 41 -#define INIT
pascal@5691 42 -
pascal@5691 43 #else /* STATIC */
pascal@5691 44
pascal@5691 45 /* Code active when compiled standalone for use when loading ramdisk: */
pascal@5691 46 @@ -84,10 +82,8 @@
pascal@5691 47 #define large_malloc(a) vmalloc(a)
pascal@5691 48 #define large_free(a) vfree(a)
pascal@5691 49
pascal@5691 50 -static void(*error)(char *m);
pascal@5691 51 #define set_error_fn(x) error = x;
pascal@5691 52
pascal@5691 53 -#define INIT __init
pascal@5691 54 #define STATIC
pascal@5691 55
pascal@5691 56 #include <linux/init.h>
pascal@5691 57
pascal@5691 58 --- linux-2.6.30.6/include/linux/decompress/unlzma_mm.h
pascal@5691 59 +++ linux-2.6.30.6/include/linux/decompress/unlzma_mm.h
pascal@5691 60 @@ -0,0 +1,20 @@
pascal@5691 61 +#ifndef UNLZMA_MM_H
pascal@5691 62 +#define UNLZMA_MM_H
pascal@5691 63 +
pascal@5691 64 +#ifdef STATIC
pascal@5691 65 +
pascal@5691 66 +/* Code active when included from pre-boot environment: */
pascal@5691 67 +#define INIT
pascal@5691 68 +
pascal@5691 69 +#elif defined(CONFIG_DECOMPRESS_LZMA_NEEDED)
pascal@5691 70 +
pascal@5691 71 +/* Make it available to non initramfs/initrd code */
pascal@5691 72 +#define INIT
pascal@5691 73 +#include <linux/module.h>
pascal@5691 74 +#else
pascal@5691 75 +
pascal@5691 76 +/* Compile for initramfs/initrd code only */
pascal@5691 77 +#define INIT __init
pascal@5691 78 +#endif
pascal@5691 79 +
pascal@5691 80 +#endif
pascal@5691 81
pascal@5691 82 --- linux-2.6.30.6/lib/Kconfig
pascal@5691 83 +++ linux-2.6.30.6/lib/Kconfig
pascal@5691 84 @@ -117,6 +117,9 @@
pascal@5691 85 config DECOMPRESS_LZMA
pascal@5691 86 tristate
pascal@5691 87
pascal@5691 88 +config DECOMPRESS_LZMA_NEEDED
pascal@5691 89 + boolean
pascal@5691 90 +
pascal@5691 91 config DECOMPRESS_LZO
pascal@5691 92 select LZO_DECOMPRESS
pascal@5691 93 tristate
pascal@5691 94
pascal@5691 95 --- linux-2.6.30.6/lib/decompress_bunzip2.c
pascal@5691 96 +++ linux-2.6.30.6/lib/decompress_bunzip2.c
pascal@5691 97 @@ -52,6 +52,7 @@
pascal@5691 98 #include <linux/slab.h>
pascal@5691 99 #endif /* STATIC */
pascal@5691 100
pascal@5691 101 +#include <linux/decompress/bunzip2_mm.h>
pascal@5691 102 #include <linux/decompress/mm.h>
pascal@5691 103
pascal@5691 104 #ifndef INT_MAX
pascal@5691 105
pascal@5691 106 --- linux-2.6.30.6/lib/decompress_inflate.c
pascal@5691 107 +++ linux-2.6.30.6/lib/decompress_inflate.c
pascal@5691 108 @@ -23,6 +23,7 @@
pascal@5691 109
pascal@5691 110 #endif /* STATIC */
pascal@5691 111
pascal@5691 112 +#include <linux/decompress/inflate_mm.h>
pascal@5691 113 #include <linux/decompress/mm.h>
pascal@5691 114
pascal@5691 115 #define GZIP_IOBUF_SIZE (16*1024)
pascal@5691 116
pascal@5691 117 --- linux-2.6.30.6/lib/decompress_unlzma.c
pascal@5691 118 +++ linux-2.6.30.6/lib/decompress_unlzma.c
pascal@5691 119 @@ -36,6 +36,7 @@
pascal@5691 120 #include <linux/slab.h>
pascal@5691 121 #endif /* STATIC */
pascal@5691 122
pascal@5691 123 +#include <linux/decompress/unlzma_mm.h>
pascal@5691 124 #include <linux/decompress/mm.h>
pascal@5691 125
pascal@5691 126 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
pascal@5691 127 @@ -88,7 +89,7 @@
pascal@5691 128 }
pascal@5691 129
pascal@5691 130 /* Called twice: once at startup and once in rc_normalize() */
pascal@5691 131 -static void INIT rc_read(struct rc *rc)
pascal@5691 132 +static void INIT rc_read(struct rc *rc, void(*error)(char *x))
pascal@5691 133 {
pascal@5691 134 rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE);
pascal@5691 135 if (rc->buffer_size <= 0)
pascal@5691 136 @@ -115,13 +116,13 @@
pascal@5691 137 rc->range = 0xFFFFFFFF;
pascal@5691 138 }
pascal@5691 139
pascal@5691 140 -static inline void INIT rc_init_code(struct rc *rc)
pascal@5691 141 +static inline void INIT rc_init_code(struct rc *rc, void(*error)(char *x))
pascal@5691 142 {
pascal@5691 143 int i;
pascal@5691 144
pascal@5691 145 for (i = 0; i < 5; i++) {
pascal@5691 146 if (rc->ptr >= rc->buffer_end)
pascal@5691 147 - rc_read(rc);
pascal@5691 148 + rc_read(rc, error);
pascal@5691 149 rc->code = (rc->code << 8) | *rc->ptr++;
pascal@5691 150 }
pascal@5691 151 }
pascal@5691 152 @@ -134,32 +135,33 @@
pascal@5691 153 }
pascal@5691 154
pascal@5691 155 /* Called twice, but one callsite is in inline'd rc_is_bit_0_helper() */
pascal@5691 156 -static void INIT rc_do_normalize(struct rc *rc)
pascal@5691 157 +static void INIT rc_do_normalize(struct rc *rc, void(*error)(char *x))
pascal@5691 158 {
pascal@5691 159 if (rc->ptr >= rc->buffer_end)
pascal@5691 160 - rc_read(rc);
pascal@5691 161 + rc_read(rc, error);
pascal@5691 162 rc->range <<= 8;
pascal@5691 163 rc->code = (rc->code << 8) | *rc->ptr++;
pascal@5691 164 }
pascal@5691 165 -static inline void INIT rc_normalize(struct rc *rc)
pascal@5691 166 +static inline void INIT rc_normalize(struct rc *rc, void(*error)(char *x))
pascal@5691 167 {
pascal@5691 168 if (rc->range < (1 << RC_TOP_BITS))
pascal@5691 169 - rc_do_normalize(rc);
pascal@5691 170 + rc_do_normalize(rc, error);
pascal@5691 171 }
pascal@5691 172
pascal@5691 173 /* Called 9 times */
pascal@5691 174 /* Why rc_is_bit_0_helper exists?
pascal@5691 175 *Because we want to always expose (rc->code < rc->bound) to optimizer
pascal@5691 176 */
pascal@5691 177 -static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p)
pascal@5691 178 +static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p,
pascal@5691 179 + void (*error)(char *x))
pascal@5691 180 {
pascal@5691 181 - rc_normalize(rc);
pascal@5691 182 + rc_normalize(rc, error);
pascal@5691 183 rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
pascal@5691 184 return rc->bound;
pascal@5691 185 }
pascal@5691 186 -static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p)
pascal@5691 187 +static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p, void(*error)(char *x))
pascal@5691 188 {
pascal@5691 189 - uint32_t t = rc_is_bit_0_helper(rc, p);
pascal@5691 190 + uint32_t t = rc_is_bit_0_helper(rc, p, error);
pascal@5691 191 return rc->code < t;
pascal@5691 192 }
pascal@5691 193
pascal@5691 194 @@ -177,9 +179,9 @@
pascal@5691 195 }
pascal@5691 196
pascal@5691 197 /* Called 4 times in unlzma loop */
pascal@5691 198 -static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol)
pascal@5691 199 +static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol, void(*error)(char *x))
pascal@5691 200 {
pascal@5691 201 - if (rc_is_bit_0(rc, p)) {
pascal@5691 202 + if (rc_is_bit_0(rc, p, error)) {
pascal@5691 203 rc_update_bit_0(rc, p);
pascal@5691 204 *symbol *= 2;
pascal@5691 205 return 0;
pascal@5691 206 @@ -191,9 +193,9 @@
pascal@5691 207 }
pascal@5691 208
pascal@5691 209 /* Called once */
pascal@5691 210 -static inline int INIT rc_direct_bit(struct rc *rc)
pascal@5691 211 +static inline int INIT rc_direct_bit(struct rc *rc , void(*error)(char *x))
pascal@5691 212 {
pascal@5691 213 - rc_normalize(rc);
pascal@5691 214 + rc_normalize(rc, error);
pascal@5691 215 rc->range >>= 1;
pascal@5691 216 if (rc->code >= rc->range) {
pascal@5691 217 rc->code -= rc->range;
pascal@5691 218 @@ -204,13 +206,14 @@
pascal@5691 219
pascal@5691 220 /* Called twice */
pascal@5691 221 static inline void INIT
pascal@5691 222 -rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol)
pascal@5691 223 +rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol,
pascal@5691 224 + void(*error)(char *x))
pascal@5691 225 {
pascal@5691 226 int i = num_levels;
pascal@5691 227
pascal@5691 228 *symbol = 1;
pascal@5691 229 while (i--)
pascal@5691 230 - rc_get_bit(rc, p + *symbol, symbol);
pascal@5691 231 + rc_get_bit(rc, p + *symbol, symbol, error);
pascal@5691 232 *symbol -= 1 << num_levels;
pascal@5691 233 }
pascal@5691 234
pascal@5691 235 @@ -406,7 +409,8 @@
pascal@5691 236 static inline void INIT process_bit0(struct writer *wr, struct rc *rc,
pascal@5691 237 struct cstate *cst, uint16_t *p,
pascal@5691 238 int pos_state, uint16_t *prob,
pascal@5691 239 - int lc, uint32_t literal_pos_mask) {
pascal@5691 240 + int lc, uint32_t literal_pos_mask,
pascal@5691 241 + void(*error)(char *x)) {
pascal@5691 242 int mi = 1;
pascal@5691 243 static const int state[LZMA_NUM_STATES] =
pascal@5691 244 { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
pascal@5691 245 @@ -427,7 +431,7 @@
pascal@5691 246 match_byte <<= 1;
pascal@5691 247 bit = match_byte & 0x100;
pascal@5691 248 prob_lit = prob + 0x100 + bit + mi;
pascal@5691 249 - if (rc_get_bit(rc, prob_lit, &mi)) {
pascal@5691 250 + if (rc_get_bit(rc, prob_lit, &mi, error)) {
pascal@5691 251 if (!bit)
pascal@5691 252 break;
pascal@5691 253 } else {
pascal@5691 254 @@ -438,7 +442,7 @@
pascal@5691 255 }
pascal@5691 256 while (mi < 0x100) {
pascal@5691 257 uint16_t *prob_lit = prob + mi;
pascal@5691 258 - rc_get_bit(rc, prob_lit, &mi);
pascal@5691 259 + rc_get_bit(rc, prob_lit, &mi, error);
pascal@5691 260 }
pascal@5691 261 write_byte(wr, mi);
pascal@5691 262 cst->state = state[cst->state];
pascal@5691 263 @@ -446,7 +453,8 @@
pascal@5691 264
pascal@5691 265 static inline void INIT process_bit1(struct writer *wr, struct rc *rc,
pascal@5691 266 struct cstate *cst, uint16_t *p,
pascal@5691 267 - int pos_state, uint16_t *prob) {
pascal@5691 268 + int pos_state, uint16_t *prob,
pascal@5691 269 + void(*error)(char *x)) {
pascal@5691 270 int offset;
pascal@5691 271 uint16_t *prob_len;
pascal@5691 272 int num_bits;
pascal@5691 273 @@ -454,7 +459,7 @@
pascal@5691 274
pascal@5691 275 rc_update_bit_1(rc, prob);
pascal@5691 276 prob = p + LZMA_IS_REP + cst->state;
pascal@5691 277 - if (rc_is_bit_0(rc, prob)) {
pascal@5691 278 + if (rc_is_bit_0(rc, prob, error)) {
pascal@5691 279 rc_update_bit_0(rc, prob);
pascal@5691 280 cst->rep3 = cst->rep2;
pascal@5691 281 cst->rep2 = cst->rep1;
pascal@5691 282 @@ -464,13 +469,13 @@
pascal@5691 283 } else {
pascal@5691 284 rc_update_bit_1(rc, prob);
pascal@5691 285 prob += LZMA_IS_REP_G0 - LZMA_IS_REP;
pascal@5691 286 - if (rc_is_bit_0(rc, prob)) {
pascal@5691 287 + if (rc_is_bit_0(rc, prob, error)) {
pascal@5691 288 rc_update_bit_0(rc, prob);
pascal@5691 289 prob = (p + LZMA_IS_REP_0_LONG
pascal@5691 290 + (cst->state <<
pascal@5691 291 LZMA_NUM_POS_BITS_MAX) +
pascal@5691 292 pos_state);
pascal@5691 293 - if (rc_is_bit_0(rc, prob)) {
pascal@5691 294 + if (rc_is_bit_0(rc, prob, error)) {
pascal@5691 295 rc_update_bit_0(rc, prob);
pascal@5691 296
pascal@5691 297 cst->state = cst->state < LZMA_NUM_LIT_STATES ?
pascal@5691 298 @@ -485,13 +490,13 @@
pascal@5691 299
pascal@5691 300 rc_update_bit_1(rc, prob);
pascal@5691 301 prob += LZMA_IS_REP_G1 - LZMA_IS_REP_G0;
pascal@5691 302 - if (rc_is_bit_0(rc, prob)) {
pascal@5691 303 + if (rc_is_bit_0(rc, prob, error)) {
pascal@5691 304 rc_update_bit_0(rc, prob);
pascal@5691 305 distance = cst->rep1;
pascal@5691 306 } else {
pascal@5691 307 rc_update_bit_1(rc, prob);
pascal@5691 308 prob += LZMA_IS_REP_G2 - LZMA_IS_REP_G1;
pascal@5691 309 - if (rc_is_bit_0(rc, prob)) {
pascal@5691 310 + if (rc_is_bit_0(rc, prob, error)) {
pascal@5691 311 rc_update_bit_0(rc, prob);
pascal@5691 312 distance = cst->rep2;
pascal@5691 313 } else {
pascal@5691 314 @@ -509,7 +514,7 @@
pascal@5691 315 }
pascal@5691 316
pascal@5691 317 prob_len = prob + LZMA_LEN_CHOICE;
pascal@5691 318 - if (rc_is_bit_0(rc, prob_len)) {
pascal@5691 319 + if (rc_is_bit_0(rc, prob_len, error)) {
pascal@5691 320 rc_update_bit_0(rc, prob_len);
pascal@5691 321 prob_len += LZMA_LEN_LOW - LZMA_LEN_CHOICE
pascal@5691 322 + (pos_state <<
pascal@5691 323 @@ -519,7 +524,7 @@
pascal@5691 324 } else {
pascal@5691 325 rc_update_bit_1(rc, prob_len);
pascal@5691 326 prob_len += LZMA_LEN_CHOICE_2 - LZMA_LEN_CHOICE;
pascal@5691 327 - if (rc_is_bit_0(rc, prob_len)) {
pascal@5691 328 + if (rc_is_bit_0(rc, prob_len, error)) {
pascal@5691 329 rc_update_bit_0(rc, prob_len);
pascal@5691 330 prob_len += LZMA_LEN_MID - LZMA_LEN_CHOICE_2
pascal@5691 331 + (pos_state <<
pascal@5691 332 @@ -535,7 +540,7 @@
pascal@5691 333 }
pascal@5691 334 }
pascal@5691 335
pascal@5691 336 - rc_bit_tree_decode(rc, prob_len, num_bits, &len);
pascal@5691 337 + rc_bit_tree_decode(rc, prob_len, num_bits, &len, error);
pascal@5691 338 len += offset;
pascal@5691 339
pascal@5691 340 if (cst->state < 4) {
pascal@5691 341 @@ -550,7 +555,7 @@
pascal@5691 342 << LZMA_NUM_POS_SLOT_BITS);
pascal@5691 343 rc_bit_tree_decode(rc, prob,
pascal@5691 344 LZMA_NUM_POS_SLOT_BITS,
pascal@5691 345 - &pos_slot);
pascal@5691 346 + &pos_slot, error);
pascal@5691 347 if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
pascal@5691 348 int i, mi;
pascal@5691 349 num_bits = (pos_slot >> 1) - 1;
pascal@5691 350 @@ -563,7 +568,7 @@
pascal@5691 351 num_bits -= LZMA_NUM_ALIGN_BITS;
pascal@5691 352 while (num_bits--)
pascal@5691 353 cst->rep0 = (cst->rep0 << 1) |
pascal@5691 354 - rc_direct_bit(rc);
pascal@5691 355 + rc_direct_bit(rc, error);
pascal@5691 356 prob = p + LZMA_ALIGN;
pascal@5691 357 cst->rep0 <<= LZMA_NUM_ALIGN_BITS;
pascal@5691 358 num_bits = LZMA_NUM_ALIGN_BITS;
pascal@5691 359 @@ -571,7 +576,7 @@
pascal@5691 360 i = 1;
pascal@5691 361 mi = 1;
pascal@5691 362 while (num_bits--) {
pascal@5691 363 - if (rc_get_bit(rc, prob + mi, &mi))
pascal@5691 364 + if (rc_get_bit(rc, prob + mi, &mi, error))
pascal@5691 365 cst->rep0 |= i;
pascal@5691 366 i <<= 1;
pascal@5691 367 }
pascal@5691 368 @@ -588,12 +593,12 @@
pascal@5691 369
pascal@5691 370
pascal@5691 371
pascal@5691 372 -STATIC inline int INIT unlzma(unsigned char *buf, int in_len,
pascal@5691 373 +STATIC int INIT unlzma(unsigned char *buf, int in_len,
pascal@5691 374 int(*fill)(void*, unsigned int),
pascal@5691 375 int(*flush)(void*, unsigned int),
pascal@5691 376 unsigned char *output,
pascal@5691 377 int *posp,
pascal@5691 378 - void(*error_fn)(char *x)
pascal@5691 379 + void(*error)(char *x)
pascal@5691 380 )
pascal@5691 381 {
pascal@5691 382 extern int cpio_flush_buffer(void*, unsigned int);
pascal@5691 383 @@ -610,7 +615,6 @@
pascal@5691 384 unsigned char *inbuf;
pascal@5691 385 int ret = -1;
pascal@5691 386
pascal@5691 387 - set_error_fn(error_fn);
pascal@5691 388
pascal@5691 389 if (buf)
pascal@5691 390 inbuf = buf;
pascal@5691 391 @@ -638,7 +642,7 @@
pascal@5691 392
pascal@5691 393 for (i = 0; i < sizeof(header); i++) {
pascal@5691 394 if (rc.ptr >= rc.buffer_end)
pascal@5691 395 - rc_read(&rc);
pascal@5691 396 + rc_read(&rc, error);
pascal@5691 397 ((unsigned char *)&header)[i] = *rc.ptr++;
pascal@5691 398 }
pascal@5691 399
pascal@5691 400 @@ -683,17 +687,17 @@
pascal@5691 401 for (i = 0; i < num_probs; i++)
pascal@5691 402 p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
pascal@5691 403 wr.max_index = wr.next_index = 0;
pascal@5691 404 - rc_init_code(&rc);
pascal@5691 405 + rc_init_code(&rc, error);
pascal@5691 406
pascal@5691 407 while (get_pos(&wr) < header.dst_size) {
pascal@5691 408 int pos_state = get_pos(&wr) & pos_state_mask;
pascal@5691 409 uint16_t *prob = p + LZMA_IS_MATCH +
pascal@5691 410 (cst.state << LZMA_NUM_POS_BITS_MAX) + pos_state;
pascal@5691 411 - if (rc_is_bit_0(&rc, prob))
pascal@5691 412 + if (rc_is_bit_0(&rc, prob, error))
pascal@5691 413 process_bit0(&wr, &rc, &cst, p, pos_state, prob,
pascal@5691 414 - lc, literal_pos_mask);
pascal@5691 415 + lc, literal_pos_mask, error);
pascal@5691 416 else {
pascal@5691 417 - process_bit1(&wr, &rc, &cst, p, pos_state, prob);
pascal@5691 418 + process_bit1(&wr, &rc, &cst, p, pos_state, prob, error);
pascal@5691 419 if (cst.rep0 == 0)
pascal@5691 420 break;
pascal@5691 421 }
pascal@5691 422 @@ -727,6 +731,9 @@
pascal@5691 423 exit_0:
pascal@5691 424 return ret;
pascal@5691 425 }
pascal@5691 426 +#if defined(CONFIG_DECOMPRESS_LZMA_NEEDED) && !defined(PREBOOT)
pascal@5691 427 +EXPORT_SYMBOL(unlzma);
pascal@5691 428 +#endif
pascal@5691 429
pascal@5691 430 #ifdef PREBOOT
pascal@5691 431 STATIC int INIT decompress(unsigned char *buf, int in_len,
pascal@5691 432
pascal@5691 433 --- linux-2.6.34/fs/squashfs/Kconfig
pascal@5691 434 +++ linux-2.6.34/fs/squashfs/Kconfig
pankso@5640 435 @@ -26,6 +26,12 @@
pankso@5640 436
pankso@5640 437 If unsure, say N.
pankso@5640 438
pankso@5640 439 +config SQUASHFS_LZMA
pankso@5640 440 + bool "Include support for LZMA compressed file systems"
pankso@5640 441 + depends on SQUASHFS
pankso@5640 442 + select DECOMPRESS_LZMA
pankso@5640 443 + select DECOMPRESS_LZMA_NEEDED
pankso@5640 444 +
pankso@5640 445 config SQUASHFS_EMBEDDED
pankso@5640 446
pankso@5640 447 bool "Additional option for memory-constrained systems"
pankso@5640 448
pascal@5691 449 --- linux-2.6.34/fs/squashfs/Makefile
pascal@5691 450 +++ linux-2.6.34/fs/squashfs/Makefile
pascal@5691 451 @@ -5,3 +5,4 @@
pankso@5640 452 obj-$(CONFIG_SQUASHFS) += squashfs.o
pankso@5640 453 squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
pascal@5691 454 squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o
pankso@5640 455 +squashfs-$(CONFIG_SQUASHFS_LZMA) += lzma_wrapper.o
pankso@5640 456
pascal@5691 457 --- linux-2.6.34/fs/squashfs/decompressor.c
pascal@5691 458 +++ linux-2.6.34/fs/squashfs/decompressor.c
pascal@5691 459 @@ -50,7 +50,11 @@
pankso@5640 460
pascal@5691 461 static const struct squashfs_decompressor *decompressor[] = {
pascal@5691 462 &squashfs_zlib_comp_ops,
pankso@5640 463 +#ifdef CONFIG_SQUASHFS_LZMA
pankso@5640 464 + &squashfs_lzma_comp_ops,
pankso@5640 465 +#else
pascal@5691 466 &squashfs_lzma_unsupported_comp_ops,
pankso@5640 467 +#endif
pascal@5691 468 &squashfs_lzo_unsupported_comp_ops,
pascal@5691 469 &squashfs_unknown_comp_ops
pascal@5691 470 };
pankso@5640 471
pascal@5691 472 --- linux-2.6.34/fs/squashfs/lzma_wrapper.c
pascal@5691 473 +++ linux-2.6.34/fs/squashfs/lzma_wrapper.c
pascal@5691 474 @@ -0,0 +1,152 @@
pankso@5640 475 +/*
pankso@5640 476 + * Squashfs - a compressed read only filesystem for Linux
pankso@5640 477 + *
pankso@5640 478 + * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
pankso@5640 479 + * Phillip Lougher <phillip@lougher.demon.co.uk>
pankso@5640 480 + *
pankso@5640 481 + * This program is free software; you can redistribute it and/or
pankso@5640 482 + * modify it under the terms of the GNU General Public License
pankso@5640 483 + * as published by the Free Software Foundation; either version 2,
pankso@5640 484 + * or (at your option) any later version.
pankso@5640 485 + *
pankso@5640 486 + * This program is distributed in the hope that it will be useful,
pankso@5640 487 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
pankso@5640 488 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
pankso@5640 489 + * GNU General Public License for more details.
pankso@5640 490 + *
pankso@5640 491 + * You should have received a copy of the GNU General Public License
pankso@5640 492 + * along with this program; if not, write to the Free Software
pankso@5640 493 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
pankso@5640 494 + *
pankso@5640 495 + * lzma_wrapper.c
pankso@5640 496 + */
pankso@5640 497 +
pankso@5640 498 +#include <asm/unaligned.h>
pascal@5691 499 +#include <linux/slab.h>
pankso@5640 500 +#include <linux/buffer_head.h>
pankso@5640 501 +#include <linux/mutex.h>
pankso@5640 502 +#include <linux/vmalloc.h>
pankso@5640 503 +#include <linux/decompress/unlzma.h>
pankso@5640 504 +
pankso@5640 505 +#include "squashfs_fs.h"
pankso@5640 506 +#include "squashfs_fs_sb.h"
pankso@5640 507 +#include "squashfs_fs_i.h"
pankso@5640 508 +#include "squashfs.h"
pankso@5640 509 +#include "decompressor.h"
pankso@5640 510 +
pankso@5640 511 +struct squashfs_lzma {
pankso@5640 512 + void *input;
pankso@5640 513 + void *output;
pankso@5640 514 +};
pankso@5640 515 +
pankso@5640 516 +/* decompress_unlzma.c is currently non re-entrant... */
pankso@5640 517 +DEFINE_MUTEX(lzma_mutex);
pankso@5640 518 +
pankso@5640 519 +/* decompress_unlzma.c doesn't provide any context in its callbacks... */
pankso@5640 520 +static int lzma_error;
pankso@5640 521 +
pankso@5640 522 +static void error(char *m)
pankso@5640 523 +{
pankso@5640 524 + ERROR("unlzma error: %s\n", m);
pankso@5640 525 + lzma_error = 1;
pankso@5640 526 +}
pankso@5640 527 +
pankso@5640 528 +
pankso@5640 529 +static void *lzma_init(struct squashfs_sb_info *msblk)
pankso@5640 530 +{
pankso@5640 531 + struct squashfs_lzma *stream = kzalloc(sizeof(*stream), GFP_KERNEL);
pankso@5640 532 + if (stream == NULL)
pankso@5640 533 + goto failed;
pankso@5640 534 + stream->input = vmalloc(msblk->block_size);
pankso@5640 535 + if (stream->input == NULL)
pankso@5640 536 + goto failed;
pankso@5640 537 + stream->output = vmalloc(msblk->block_size);
pankso@5640 538 + if (stream->output == NULL)
pankso@5640 539 + goto failed2;
pankso@5640 540 +
pankso@5640 541 + return stream;
pankso@5640 542 +
pankso@5640 543 +failed2:
pankso@5640 544 + vfree(stream->input);
pankso@5640 545 +failed:
pankso@5640 546 + ERROR("failed to allocate lzma workspace\n");
pankso@5640 547 + kfree(stream);
pankso@5640 548 + return NULL;
pankso@5640 549 +}
pankso@5640 550 +
pankso@5640 551 +
pankso@5640 552 +static void lzma_free(void *strm)
pankso@5640 553 +{
pankso@5640 554 + struct squashfs_lzma *stream = strm;
pankso@5640 555 +
pankso@5640 556 + if (stream) {
pankso@5640 557 + vfree(stream->input);
pankso@5640 558 + vfree(stream->output);
pankso@5640 559 + }
pankso@5640 560 + kfree(stream);
pankso@5640 561 +}
pankso@5640 562 +
pankso@5640 563 +
pankso@5640 564 +static int lzma_uncompress(struct squashfs_sb_info *msblk, void **buffer,
pankso@5640 565 + struct buffer_head **bh, int b, int offset, int length, int srclength,
pankso@5640 566 + int pages)
pankso@5640 567 +{
pankso@5640 568 + struct squashfs_lzma *stream = msblk->stream;
pankso@5640 569 + void *buff = stream->input;
pankso@5640 570 + int avail, i, bytes = length, res;
pankso@5640 571 +
pankso@5640 572 + mutex_lock(&lzma_mutex);
pankso@5640 573 +
pankso@5640 574 + for (i = 0; i < b; i++) {
pankso@5640 575 + wait_on_buffer(bh[i]);
pankso@5640 576 + if (!buffer_uptodate(bh[i]))
pankso@5640 577 + goto block_release;
pankso@5640 578 +
pankso@5640 579 + avail = min(bytes, msblk->devblksize - offset);
pankso@5640 580 + memcpy(buff, bh[i]->b_data + offset, avail);
pankso@5640 581 + buff += avail;
pankso@5640 582 + bytes -= avail;
pankso@5640 583 + offset = 0;
pankso@5640 584 + put_bh(bh[i]);
pankso@5640 585 + }
pankso@5640 586 +
pankso@5640 587 + lzma_error = 0;
pankso@5640 588 + res = unlzma(stream->input, length, NULL, NULL, stream->output, NULL,
pankso@5640 589 + error);
pankso@5640 590 + if (res || lzma_error)
pankso@5640 591 + goto failed;
pankso@5640 592 +
pankso@5640 593 + /* uncompressed size is stored in the LZMA header (5 byte offset) */
pankso@5640 594 + res = bytes = get_unaligned_le32(stream->input + 5);
pankso@5640 595 + for (i = 0, buff = stream->output; bytes && i < pages; i++) {
pankso@5640 596 + avail = min_t(int, bytes, PAGE_CACHE_SIZE);
pankso@5640 597 + memcpy(buffer[i], buff, avail);
pankso@5640 598 + buff += avail;
pankso@5640 599 + bytes -= avail;
pankso@5640 600 + }
pankso@5640 601 + if (bytes)
pankso@5640 602 + goto failed;
pankso@5640 603 +
pankso@5640 604 + mutex_unlock(&lzma_mutex);
pankso@5640 605 + return res;
pankso@5640 606 +
pankso@5640 607 +block_release:
pankso@5640 608 + for (; i < b; i++)
pankso@5640 609 + put_bh(bh[i]);
pankso@5640 610 +
pankso@5640 611 +failed:
pankso@5640 612 + mutex_unlock(&lzma_mutex);
pankso@5640 613 +
pankso@5640 614 + ERROR("lzma decompression failed, data probably corrupt\n");
pankso@5640 615 + return -EIO;
pankso@5640 616 +}
pankso@5640 617 +
pankso@5640 618 +const struct squashfs_decompressor squashfs_lzma_comp_ops = {
pankso@5640 619 + .init = lzma_init,
pankso@5640 620 + .free = lzma_free,
pankso@5640 621 + .decompress = lzma_uncompress,
pankso@5640 622 + .id = LZMA_COMPRESSION,
pankso@5640 623 + .name = "lzma",
pankso@5640 624 + .supported = 1
pankso@5640 625 +};
pankso@5640 626 +
pankso@5640 627
pascal@5691 628 --- linux-2.6.34/fs/squashfs/squashfs.h
pascal@5691 629 +++ linux-2.6.34/fs/squashfs/squashfs.h
pascal@5691 630 @@ -94,3 +94,6 @@
pankso@5640 631
pascal@5691 632 /* zlib_wrapper.c */
pascal@5691 633 extern const struct squashfs_decompressor squashfs_zlib_comp_ops;
pankso@5640 634 +
pankso@5640 635 +/* lzma wrapper.c */
pankso@5640 636 +extern const struct squashfs_decompressor squashfs_lzma_comp_ops;
pankso@5640 637
slaxemulator@6488 638 --- linux-2.6.34/lib/Makefile
slaxemulator@6488 639 +++ linux-2.6.34/lib/Makefile
slaxemulator@6488 640 @@ -69,7 +69,7 @@ obj-$(CONFIG_LZO_DECOMPRESS) += lzo/
slaxemulator@6488 641
slaxemulator@6488 642 lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
slaxemulator@6488 643 lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
slaxemulator@6488 644 -lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
slaxemulator@6488 645 +obj-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
slaxemulator@6488 646 lib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o
slaxemulator@6488 647
slaxemulator@6488 648 obj-$(CONFIG_TEXTSEARCH) += textsearch.o
slaxemulator@6488 649