wok-6.x diff linux-libre/stuff/linux-squashfs-lzma-2.6.34.u @ rev 13955

gtk+3: moved from wok-undigest
author Aleksej Bobylev <al.bobylev@gmail.com>
date Wed Jan 30 11:48:51 2013 +0000 (2013-01-30)
parents
children
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/linux-libre/stuff/linux-squashfs-lzma-2.6.34.u	Wed Jan 30 11:48:51 2013 +0000
     1.3 @@ -0,0 +1,649 @@
     1.4 +--- linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h
     1.5 ++++ linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h
     1.6 +@@ -0,0 +1,13 @@
     1.7 ++#ifndef BUNZIP2_MM_H
     1.8 ++#define BUNZIP2_MM_H
     1.9 ++
    1.10 ++#ifdef STATIC
    1.11 ++/* Code active when included from pre-boot environment: */
    1.12 ++#define INIT
    1.13 ++#else
    1.14 ++/* Compile for initramfs/initrd code only */
    1.15 ++#define INIT __init
    1.16 ++static void(*error)(char *m);
    1.17 ++#endif
    1.18 ++
    1.19 ++#endif
    1.20 +
    1.21 +--- linux-2.6.30.6/include/linux/decompress/inflate_mm.h
    1.22 ++++ linux-2.6.30.6/include/linux/decompress/inflate_mm.h
    1.23 +@@ -0,0 +1,13 @@
    1.24 ++#ifndef INFLATE_MM_H
    1.25 ++#define INFLATE_MM_H
    1.26 ++
    1.27 ++#ifdef STATIC
    1.28 ++/* Code active when included from pre-boot environment: */
    1.29 ++#define INIT
    1.30 ++#else
    1.31 ++/* Compile for initramfs/initrd code only */
    1.32 ++#define INIT __init
    1.33 ++static void(*error)(char *m);
    1.34 ++#endif
    1.35 ++
    1.36 ++#endif
    1.37 +
    1.38 +#--- linux-2.6.30.6/include/linux/decompress/mm.h
    1.39 +#+++ linux-2.6.30.6/include/linux/decompress/mm.h
    1.40 +@@ -63,8 +63,6 @@
    1.41 + 
    1.42 + #define set_error_fn(x)
    1.43 + 
    1.44 +-#define INIT
    1.45 +-
    1.46 + #else /* STATIC */
    1.47 + 
    1.48 + /* Code active when compiled standalone for use when loading ramdisk: */
    1.49 +@@ -84,10 +82,8 @@
    1.50 + #define large_malloc(a) vmalloc(a)
    1.51 + #define large_free(a) vfree(a)
    1.52 + 
    1.53 +-static void(*error)(char *m);
    1.54 + #define set_error_fn(x) error = x;
    1.55 + 
    1.56 +-#define INIT __init
    1.57 + #define STATIC
    1.58 + 
    1.59 + #include <linux/init.h>
    1.60 +
    1.61 +--- linux-2.6.30.6/include/linux/decompress/unlzma_mm.h
    1.62 ++++ linux-2.6.30.6/include/linux/decompress/unlzma_mm.h
    1.63 +@@ -0,0 +1,20 @@
    1.64 ++#ifndef UNLZMA_MM_H
    1.65 ++#define UNLZMA_MM_H
    1.66 ++
    1.67 ++#ifdef STATIC
    1.68 ++
    1.69 ++/* Code active when included from pre-boot environment: */
    1.70 ++#define INIT
    1.71 ++
    1.72 ++#elif defined(CONFIG_DECOMPRESS_LZMA_NEEDED)
    1.73 ++
    1.74 ++/* Make it available to non initramfs/initrd code */
    1.75 ++#define INIT
    1.76 ++#include <linux/module.h>
    1.77 ++#else
    1.78 ++
    1.79 ++/* Compile for initramfs/initrd code only */
    1.80 ++#define INIT __init
    1.81 ++#endif
    1.82 ++
    1.83 ++#endif
    1.84 +
    1.85 +--- linux-2.6.30.6/lib/Kconfig
    1.86 ++++ linux-2.6.30.6/lib/Kconfig
    1.87 +@@ -117,6 +117,9 @@
    1.88 + config DECOMPRESS_LZMA
    1.89 + 	tristate
    1.90 + 
    1.91 ++config DECOMPRESS_LZMA_NEEDED
    1.92 ++	 boolean
    1.93 ++
    1.94 + config DECOMPRESS_LZO
    1.95 + 	select LZO_DECOMPRESS
    1.96 + 	tristate
    1.97 +
    1.98 +--- linux-2.6.30.6/lib/decompress_bunzip2.c
    1.99 ++++ linux-2.6.30.6/lib/decompress_bunzip2.c
   1.100 +@@ -52,6 +52,7 @@
   1.101 + #include <linux/slab.h>
   1.102 + #endif /* STATIC */
   1.103 + 
   1.104 ++#include <linux/decompress/bunzip2_mm.h>
   1.105 + #include <linux/decompress/mm.h>
   1.106 + 
   1.107 + #ifndef INT_MAX
   1.108 +
   1.109 +--- linux-2.6.30.6/lib/decompress_inflate.c
   1.110 ++++ linux-2.6.30.6/lib/decompress_inflate.c
   1.111 +@@ -23,6 +23,7 @@
   1.112 + 
   1.113 + #endif /* STATIC */
   1.114 + 
   1.115 ++#include <linux/decompress/inflate_mm.h>
   1.116 + #include <linux/decompress/mm.h>
   1.117 + 
   1.118 + #define GZIP_IOBUF_SIZE (16*1024)
   1.119 +
   1.120 +--- linux-2.6.30.6/lib/decompress_unlzma.c
   1.121 ++++ linux-2.6.30.6/lib/decompress_unlzma.c
   1.122 +@@ -36,6 +36,7 @@
   1.123 + #include <linux/slab.h>
   1.124 + #endif /* STATIC */
   1.125 + 
   1.126 ++#include <linux/decompress/unlzma_mm.h>
   1.127 + #include <linux/decompress/mm.h>
   1.128 + 
   1.129 + #define	MIN(a, b) (((a) < (b)) ? (a) : (b))
   1.130 +@@ -88,7 +89,7 @@
   1.131 + }
   1.132 + 
   1.133 + /* Called twice: once at startup and once in rc_normalize() */
   1.134 +-static void INIT rc_read(struct rc *rc)
   1.135 ++static void INIT rc_read(struct rc *rc, void(*error)(char *x))
   1.136 + {
   1.137 + 	rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE);
   1.138 + 	if (rc->buffer_size <= 0)
   1.139 +@@ -115,13 +116,13 @@
   1.140 + 	rc->range = 0xFFFFFFFF;
   1.141 + }
   1.142 + 
   1.143 +-static inline void INIT rc_init_code(struct rc *rc)
   1.144 ++static inline void INIT rc_init_code(struct rc *rc, void(*error)(char *x))
   1.145 + {
   1.146 + 	int i;
   1.147 + 
   1.148 + 	for (i = 0; i < 5; i++) {
   1.149 + 		if (rc->ptr >= rc->buffer_end)
   1.150 +-			rc_read(rc);
   1.151 ++			rc_read(rc, error);
   1.152 + 		rc->code = (rc->code << 8) | *rc->ptr++;
   1.153 + 	}
   1.154 + }
   1.155 +@@ -134,32 +135,33 @@
   1.156 + }
   1.157 + 
   1.158 + /* Called twice, but one callsite is in inline'd rc_is_bit_0_helper() */
   1.159 +-static void INIT rc_do_normalize(struct rc *rc)
   1.160 ++static void INIT rc_do_normalize(struct rc *rc, void(*error)(char *x))
   1.161 + {
   1.162 + 	if (rc->ptr >= rc->buffer_end)
   1.163 +-		rc_read(rc);
   1.164 ++		rc_read(rc, error);
   1.165 + 	rc->range <<= 8;
   1.166 + 	rc->code = (rc->code << 8) | *rc->ptr++;
   1.167 + }
   1.168 +-static inline void INIT rc_normalize(struct rc *rc)
   1.169 ++static inline void INIT rc_normalize(struct rc *rc, void(*error)(char *x))
   1.170 + {
   1.171 + 	if (rc->range < (1 << RC_TOP_BITS))
   1.172 +-		rc_do_normalize(rc);
   1.173 ++		rc_do_normalize(rc, error);
   1.174 + }
   1.175 + 
   1.176 + /* Called 9 times */
   1.177 + /* Why rc_is_bit_0_helper exists?
   1.178 +  *Because we want to always expose (rc->code < rc->bound) to optimizer
   1.179 +  */
   1.180 +-static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p)
   1.181 ++static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p,
   1.182 ++					       void (*error)(char *x))
   1.183 + {
   1.184 +-	rc_normalize(rc);
   1.185 ++	rc_normalize(rc, error);
   1.186 + 	rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
   1.187 + 	return rc->bound;
   1.188 + }
   1.189 +-static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p)
   1.190 ++static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p, void(*error)(char *x))
   1.191 + {
   1.192 +-	uint32_t t = rc_is_bit_0_helper(rc, p);
   1.193 ++	uint32_t t = rc_is_bit_0_helper(rc, p, error);
   1.194 + 	return rc->code < t;
   1.195 + }
   1.196 + 
   1.197 +@@ -177,9 +179,9 @@
   1.198 + }
   1.199 + 
   1.200 + /* Called 4 times in unlzma loop */
   1.201 +-static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol)
   1.202 ++static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol, void(*error)(char *x))
   1.203 + {
   1.204 +-	if (rc_is_bit_0(rc, p)) {
   1.205 ++	if (rc_is_bit_0(rc, p, error)) {
   1.206 + 		rc_update_bit_0(rc, p);
   1.207 + 		*symbol *= 2;
   1.208 + 		return 0;
   1.209 +@@ -191,9 +193,9 @@
   1.210 + }
   1.211 + 
   1.212 + /* Called once */
   1.213 +-static inline int INIT rc_direct_bit(struct rc *rc)
   1.214 ++static inline int INIT rc_direct_bit(struct rc *rc , void(*error)(char *x))
   1.215 + {
   1.216 +-	rc_normalize(rc);
   1.217 ++	rc_normalize(rc, error);
   1.218 + 	rc->range >>= 1;
   1.219 + 	if (rc->code >= rc->range) {
   1.220 + 		rc->code -= rc->range;
   1.221 +@@ -204,13 +206,14 @@
   1.222 + 
   1.223 + /* Called twice */
   1.224 + static inline void INIT
   1.225 +-rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol)
   1.226 ++rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol,
   1.227 ++							void(*error)(char *x))
   1.228 + {
   1.229 + 	int i = num_levels;
   1.230 + 
   1.231 + 	*symbol = 1;
   1.232 + 	while (i--)
   1.233 +-		rc_get_bit(rc, p + *symbol, symbol);
   1.234 ++		rc_get_bit(rc, p + *symbol, symbol, error);
   1.235 + 	*symbol -= 1 << num_levels;
   1.236 + }
   1.237 + 
   1.238 +@@ -406,7 +409,8 @@
   1.239 + static inline void INIT process_bit0(struct writer *wr, struct rc *rc,
   1.240 + 				     struct cstate *cst, uint16_t *p,
   1.241 + 				     int pos_state, uint16_t *prob,
   1.242 +-				     int lc, uint32_t literal_pos_mask) {
   1.243 ++				     int lc, uint32_t literal_pos_mask,
   1.244 ++				     void(*error)(char *x)) {
   1.245 + 	int mi = 1;
   1.246 + 	static const int state[LZMA_NUM_STATES] = 
   1.247 + 		{ 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
   1.248 +@@ -427,7 +431,7 @@
   1.249 + 			match_byte <<= 1;
   1.250 + 			bit = match_byte & 0x100;
   1.251 + 			prob_lit = prob + 0x100 + bit + mi;
   1.252 +-			if (rc_get_bit(rc, prob_lit, &mi)) {
   1.253 ++			if (rc_get_bit(rc, prob_lit, &mi, error)) {
   1.254 + 				if (!bit)
   1.255 + 					break;
   1.256 + 			} else {
   1.257 +@@ -438,7 +442,7 @@
   1.258 + 	}
   1.259 + 	while (mi < 0x100) {
   1.260 + 		uint16_t *prob_lit = prob + mi;
   1.261 +-		rc_get_bit(rc, prob_lit, &mi);
   1.262 ++		rc_get_bit(rc, prob_lit, &mi, error);
   1.263 + 	}
   1.264 + 	write_byte(wr, mi);
   1.265 + 	cst->state = state[cst->state];
   1.266 +@@ -446,7 +453,8 @@
   1.267 + 
   1.268 + static inline void INIT process_bit1(struct writer *wr, struct rc *rc,
   1.269 + 					    struct cstate *cst, uint16_t *p,
   1.270 +-					    int pos_state, uint16_t *prob) {
   1.271 ++					    int pos_state, uint16_t *prob,
   1.272 ++					    void(*error)(char *x)) {
   1.273 + 	int offset;
   1.274 + 	uint16_t *prob_len;
   1.275 + 	int num_bits;
   1.276 +@@ -454,7 +459,7 @@
   1.277 + 
   1.278 + 	rc_update_bit_1(rc, prob);
   1.279 + 	prob = p + LZMA_IS_REP + cst->state;
   1.280 +-	if (rc_is_bit_0(rc, prob)) {
   1.281 ++	if (rc_is_bit_0(rc, prob, error)) {
   1.282 + 		rc_update_bit_0(rc, prob);
   1.283 + 		cst->rep3 = cst->rep2;
   1.284 + 		cst->rep2 = cst->rep1;
   1.285 +@@ -464,13 +469,13 @@
   1.286 + 	} else {
   1.287 + 		rc_update_bit_1(rc, prob);
   1.288 + 		prob += LZMA_IS_REP_G0 - LZMA_IS_REP;
   1.289 +-		if (rc_is_bit_0(rc, prob)) {
   1.290 ++		if (rc_is_bit_0(rc, prob, error)) {
   1.291 + 			rc_update_bit_0(rc, prob);
   1.292 + 			prob = (p + LZMA_IS_REP_0_LONG
   1.293 + 				+ (cst->state <<
   1.294 + 				   LZMA_NUM_POS_BITS_MAX) +
   1.295 + 				pos_state);
   1.296 +-			if (rc_is_bit_0(rc, prob)) {
   1.297 ++			if (rc_is_bit_0(rc, prob, error)) {
   1.298 + 				rc_update_bit_0(rc, prob);
   1.299 + 
   1.300 + 				cst->state = cst->state < LZMA_NUM_LIT_STATES ?
   1.301 +@@ -485,13 +490,13 @@
   1.302 + 
   1.303 + 			rc_update_bit_1(rc, prob);
   1.304 + 			prob += LZMA_IS_REP_G1 - LZMA_IS_REP_G0;
   1.305 +-			if (rc_is_bit_0(rc, prob)) {
   1.306 ++			if (rc_is_bit_0(rc, prob, error)) {
   1.307 + 				rc_update_bit_0(rc, prob);
   1.308 + 				distance = cst->rep1;
   1.309 + 			} else {
   1.310 + 				rc_update_bit_1(rc, prob);
   1.311 + 				prob += LZMA_IS_REP_G2 - LZMA_IS_REP_G1;
   1.312 +-				if (rc_is_bit_0(rc, prob)) {
   1.313 ++				if (rc_is_bit_0(rc, prob, error)) {
   1.314 + 					rc_update_bit_0(rc, prob);
   1.315 + 					distance = cst->rep2;
   1.316 + 				} else {
   1.317 +@@ -509,7 +514,7 @@
   1.318 + 	}
   1.319 + 
   1.320 + 	prob_len = prob + LZMA_LEN_CHOICE;
   1.321 +-	if (rc_is_bit_0(rc, prob_len)) {
   1.322 ++	if (rc_is_bit_0(rc, prob_len, error)) {
   1.323 + 		rc_update_bit_0(rc, prob_len);
   1.324 + 		prob_len += LZMA_LEN_LOW - LZMA_LEN_CHOICE
   1.325 + 			    + (pos_state <<
   1.326 +@@ -519,7 +524,7 @@
   1.327 + 	} else {
   1.328 + 		rc_update_bit_1(rc, prob_len);
   1.329 + 		prob_len += LZMA_LEN_CHOICE_2 - LZMA_LEN_CHOICE;
   1.330 +-		if (rc_is_bit_0(rc, prob_len)) {
   1.331 ++		if (rc_is_bit_0(rc, prob_len, error)) {
   1.332 + 			rc_update_bit_0(rc, prob_len);
   1.333 + 			prob_len += LZMA_LEN_MID - LZMA_LEN_CHOICE_2
   1.334 + 				    + (pos_state <<
   1.335 +@@ -535,7 +540,7 @@
   1.336 + 		}
   1.337 + 	}
   1.338 + 
   1.339 +-	rc_bit_tree_decode(rc, prob_len, num_bits, &len);
   1.340 ++	rc_bit_tree_decode(rc, prob_len, num_bits, &len, error);
   1.341 + 	len += offset;
   1.342 + 
   1.343 + 	if (cst->state < 4) {
   1.344 +@@ -550,7 +555,7 @@
   1.345 + 			 << LZMA_NUM_POS_SLOT_BITS);
   1.346 + 		rc_bit_tree_decode(rc, prob,
   1.347 + 				   LZMA_NUM_POS_SLOT_BITS,
   1.348 +-				   &pos_slot);
   1.349 ++				   &pos_slot, error);
   1.350 + 		if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
   1.351 + 			int i, mi;
   1.352 + 			num_bits = (pos_slot >> 1) - 1;
   1.353 +@@ -563,7 +568,7 @@
   1.354 + 				num_bits -= LZMA_NUM_ALIGN_BITS;
   1.355 + 				while (num_bits--)
   1.356 + 					cst->rep0 = (cst->rep0 << 1) |
   1.357 +-						rc_direct_bit(rc);
   1.358 ++						rc_direct_bit(rc, error);
   1.359 + 				prob = p + LZMA_ALIGN;
   1.360 + 				cst->rep0 <<= LZMA_NUM_ALIGN_BITS;
   1.361 + 				num_bits = LZMA_NUM_ALIGN_BITS;
   1.362 +@@ -571,7 +576,7 @@
   1.363 + 			i = 1;
   1.364 + 			mi = 1;
   1.365 + 			while (num_bits--) {
   1.366 +-				if (rc_get_bit(rc, prob + mi, &mi))
   1.367 ++				if (rc_get_bit(rc, prob + mi, &mi, error))
   1.368 + 					cst->rep0 |= i;
   1.369 + 				i <<= 1;
   1.370 + 			}
   1.371 +@@ -588,12 +593,12 @@
   1.372 + 
   1.373 + 
   1.374 + 
   1.375 +-STATIC inline int INIT unlzma(unsigned char *buf, int in_len,
   1.376 ++STATIC int INIT unlzma(unsigned char *buf, int in_len,
   1.377 + 			      int(*fill)(void*, unsigned int),
   1.378 + 			      int(*flush)(void*, unsigned int),
   1.379 + 			      unsigned char *output,
   1.380 + 			      int *posp,
   1.381 +-			      void(*error_fn)(char *x)
   1.382 ++			      void(*error)(char *x)
   1.383 + 	)
   1.384 + {
   1.385 + 	extern int cpio_flush_buffer(void*, unsigned int);
   1.386 +@@ -610,7 +615,6 @@
   1.387 + 	unsigned char *inbuf;
   1.388 + 	int ret = -1;
   1.389 + 
   1.390 +-	set_error_fn(error_fn);
   1.391 + 
   1.392 + 	if (buf)
   1.393 + 		inbuf = buf;
   1.394 +@@ -638,7 +642,7 @@
   1.395 + 
   1.396 + 	for (i = 0; i < sizeof(header); i++) {
   1.397 + 		if (rc.ptr >= rc.buffer_end)
   1.398 +-			rc_read(&rc);
   1.399 ++			rc_read(&rc, error);
   1.400 + 		((unsigned char *)&header)[i] = *rc.ptr++;
   1.401 + 	}
   1.402 + 
   1.403 +@@ -683,17 +687,17 @@
   1.404 + 	for (i = 0; i < num_probs; i++)
   1.405 + 		p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
   1.406 + 	wr.max_index = wr.next_index = 0;
   1.407 +-	rc_init_code(&rc);
   1.408 ++	rc_init_code(&rc, error);
   1.409 + 
   1.410 + 	while (get_pos(&wr) < header.dst_size) {
   1.411 + 		int pos_state =	get_pos(&wr) & pos_state_mask;
   1.412 + 		uint16_t *prob = p + LZMA_IS_MATCH +
   1.413 + 			(cst.state << LZMA_NUM_POS_BITS_MAX) + pos_state;
   1.414 +-		if (rc_is_bit_0(&rc, prob))
   1.415 ++		if (rc_is_bit_0(&rc, prob, error))
   1.416 + 			process_bit0(&wr, &rc, &cst, p, pos_state, prob,
   1.417 +-				     lc, literal_pos_mask);
   1.418 ++				     lc, literal_pos_mask, error);
   1.419 + 		else {
   1.420 +-			process_bit1(&wr, &rc, &cst, p, pos_state, prob);
   1.421 ++			process_bit1(&wr, &rc, &cst, p, pos_state, prob, error);
   1.422 + 			if (cst.rep0 == 0)
   1.423 + 				break;
   1.424 + 		}
   1.425 +@@ -727,6 +731,9 @@
   1.426 + exit_0:
   1.427 + 	return ret;
   1.428 + }
   1.429 ++#if defined(CONFIG_DECOMPRESS_LZMA_NEEDED) && !defined(PREBOOT)
   1.430 ++EXPORT_SYMBOL(unlzma);
   1.431 ++#endif
   1.432 + 
   1.433 + #ifdef PREBOOT
   1.434 + STATIC int INIT decompress(unsigned char *buf, int in_len,
   1.435 +
   1.436 +--- linux-2.6.34/fs/squashfs/Kconfig
   1.437 ++++ linux-2.6.34/fs/squashfs/Kconfig
   1.438 +@@ -26,6 +26,12 @@
   1.439 + 
   1.440 + 	  If unsure, say N.
   1.441 + 
   1.442 ++config SQUASHFS_LZMA
   1.443 ++	bool "Include support for LZMA compressed file systems"
   1.444 ++	depends on SQUASHFS
   1.445 ++	select DECOMPRESS_LZMA
   1.446 ++	select DECOMPRESS_LZMA_NEEDED
   1.447 ++
   1.448 + config SQUASHFS_EMBEDDED
   1.449 + 
   1.450 + 	bool "Additional option for memory-constrained systems" 
   1.451 +
   1.452 +--- linux-2.6.34/fs/squashfs/Makefile
   1.453 ++++ linux-2.6.34/fs/squashfs/Makefile
   1.454 +@@ -5,3 +5,4 @@
   1.455 + obj-$(CONFIG_SQUASHFS) += squashfs.o
   1.456 + squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
   1.457 + squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o
   1.458 ++squashfs-$(CONFIG_SQUASHFS_LZMA) += lzma_wrapper.o
   1.459 +
   1.460 +--- linux-2.6.34/fs/squashfs/decompressor.c
   1.461 ++++ linux-2.6.34/fs/squashfs/decompressor.c
   1.462 +@@ -50,7 +50,11 @@
   1.463 + 
   1.464 + static const struct squashfs_decompressor *decompressor[] = {
   1.465 + 	&squashfs_zlib_comp_ops,
   1.466 ++#ifdef CONFIG_SQUASHFS_LZMA
   1.467 ++	&squashfs_lzma_comp_ops,
   1.468 ++#else
   1.469 + 	&squashfs_lzma_unsupported_comp_ops,
   1.470 ++#endif
   1.471 + 	&squashfs_lzo_unsupported_comp_ops,
   1.472 + 	&squashfs_unknown_comp_ops
   1.473 + };
   1.474 +
   1.475 +--- linux-2.6.34/fs/squashfs/lzma_wrapper.c
   1.476 ++++ linux-2.6.34/fs/squashfs/lzma_wrapper.c
   1.477 +@@ -0,0 +1,152 @@
   1.478 ++/*
   1.479 ++ * Squashfs - a compressed read only filesystem for Linux
   1.480 ++ *
   1.481 ++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
   1.482 ++ * Phillip Lougher <phillip@lougher.demon.co.uk>
   1.483 ++ *
   1.484 ++ * This program is free software; you can redistribute it and/or
   1.485 ++ * modify it under the terms of the GNU General Public License
   1.486 ++ * as published by the Free Software Foundation; either version 2,
   1.487 ++ * or (at your option) any later version.
   1.488 ++ *
   1.489 ++ * This program is distributed in the hope that it will be useful,
   1.490 ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
   1.491 ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   1.492 ++ * GNU General Public License for more details.
   1.493 ++ *
   1.494 ++ * You should have received a copy of the GNU General Public License
   1.495 ++ * along with this program; if not, write to the Free Software
   1.496 ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
   1.497 ++ *
   1.498 ++ * lzma_wrapper.c
   1.499 ++ */
   1.500 ++
   1.501 ++#include <asm/unaligned.h>
   1.502 ++#include <linux/slab.h>
   1.503 ++#include <linux/buffer_head.h>
   1.504 ++#include <linux/mutex.h>
   1.505 ++#include <linux/vmalloc.h>
   1.506 ++#include <linux/decompress/unlzma.h>
   1.507 ++
   1.508 ++#include "squashfs_fs.h"
   1.509 ++#include "squashfs_fs_sb.h"
   1.510 ++#include "squashfs_fs_i.h"
   1.511 ++#include "squashfs.h"
   1.512 ++#include "decompressor.h"
   1.513 ++
   1.514 ++struct squashfs_lzma {
   1.515 ++	void	*input;
   1.516 ++	void	*output;
   1.517 ++};
   1.518 ++
   1.519 ++/* decompress_unlzma.c is currently non re-entrant... */
   1.520 ++DEFINE_MUTEX(lzma_mutex);
   1.521 ++
   1.522 ++/* decompress_unlzma.c doesn't provide any context in its callbacks... */
   1.523 ++static int lzma_error;
   1.524 ++
   1.525 ++static void error(char *m)
   1.526 ++{
   1.527 ++	ERROR("unlzma error: %s\n", m);
   1.528 ++	lzma_error = 1;
   1.529 ++}
   1.530 ++
   1.531 ++
   1.532 ++static void *lzma_init(struct squashfs_sb_info *msblk)
   1.533 ++{
   1.534 ++	struct squashfs_lzma *stream = kzalloc(sizeof(*stream), GFP_KERNEL);
   1.535 ++	if (stream == NULL)
   1.536 ++		goto failed;
   1.537 ++	stream->input = vmalloc(msblk->block_size);
   1.538 ++	if (stream->input == NULL)
   1.539 ++		goto failed;
   1.540 ++	stream->output = vmalloc(msblk->block_size);
   1.541 ++	if (stream->output == NULL)
   1.542 ++		goto failed2;
   1.543 ++
   1.544 ++	return stream;
   1.545 ++
   1.546 ++failed2:
   1.547 ++	vfree(stream->input);
   1.548 ++failed:
   1.549 ++	ERROR("failed to allocate lzma workspace\n");
   1.550 ++	kfree(stream);
   1.551 ++	return NULL;
   1.552 ++}
   1.553 ++
   1.554 ++
   1.555 ++static void lzma_free(void *strm)
   1.556 ++{
   1.557 ++	struct squashfs_lzma *stream = strm;
   1.558 ++
   1.559 ++	if (stream) {
   1.560 ++		vfree(stream->input);
   1.561 ++		vfree(stream->output);
   1.562 ++	}
   1.563 ++	kfree(stream);
   1.564 ++}
   1.565 ++
   1.566 ++
   1.567 ++static int lzma_uncompress(struct squashfs_sb_info *msblk, void **buffer,
   1.568 ++	struct buffer_head **bh, int b, int offset, int length, int srclength,
   1.569 ++	int pages)
   1.570 ++{
   1.571 ++	struct squashfs_lzma *stream = msblk->stream;
   1.572 ++	void *buff = stream->input;
   1.573 ++	int avail, i, bytes = length, res;
   1.574 ++
   1.575 ++	mutex_lock(&lzma_mutex);
   1.576 ++
   1.577 ++	for (i = 0; i < b; i++) {
   1.578 ++		wait_on_buffer(bh[i]);
   1.579 ++		if (!buffer_uptodate(bh[i]))
   1.580 ++			goto block_release;
   1.581 ++
   1.582 ++		avail = min(bytes, msblk->devblksize - offset);
   1.583 ++		memcpy(buff, bh[i]->b_data + offset, avail);
   1.584 ++		buff += avail;
   1.585 ++		bytes -= avail;
   1.586 ++		offset = 0;
   1.587 ++		put_bh(bh[i]);
   1.588 ++	}
   1.589 ++
   1.590 ++	lzma_error = 0;
   1.591 ++	res = unlzma(stream->input, length, NULL, NULL, stream->output, NULL,
   1.592 ++							error);
   1.593 ++	if (res || lzma_error)
   1.594 ++		goto failed;
   1.595 ++
   1.596 ++	/* uncompressed size is stored in the LZMA header (5 byte offset) */
   1.597 ++	res = bytes = get_unaligned_le32(stream->input + 5);
   1.598 ++	for (i = 0, buff = stream->output; bytes && i < pages; i++) {
   1.599 ++		avail = min_t(int, bytes, PAGE_CACHE_SIZE);
   1.600 ++		memcpy(buffer[i], buff, avail);
   1.601 ++		buff += avail;
   1.602 ++		bytes -= avail;
   1.603 ++	}
   1.604 ++	if (bytes)
   1.605 ++		goto failed;
   1.606 ++
   1.607 ++	mutex_unlock(&lzma_mutex);
   1.608 ++	return res;
   1.609 ++
   1.610 ++block_release:
   1.611 ++	for (; i < b; i++)
   1.612 ++		put_bh(bh[i]);
   1.613 ++
   1.614 ++failed:
   1.615 ++	mutex_unlock(&lzma_mutex);
   1.616 ++
   1.617 ++	ERROR("lzma decompression failed, data probably corrupt\n");
   1.618 ++	return -EIO;
   1.619 ++}
   1.620 ++
   1.621 ++const struct squashfs_decompressor squashfs_lzma_comp_ops = {
   1.622 ++	.init = lzma_init,
   1.623 ++	.free = lzma_free,
   1.624 ++	.decompress = lzma_uncompress,
   1.625 ++	.id = LZMA_COMPRESSION,
   1.626 ++	.name = "lzma",
   1.627 ++	.supported = 1
   1.628 ++};
   1.629 ++
   1.630 +
   1.631 +--- linux-2.6.34/fs/squashfs/squashfs.h
   1.632 ++++ linux-2.6.34/fs/squashfs/squashfs.h
   1.633 +@@ -94,3 +94,6 @@
   1.634 + 
   1.635 + /* zlib_wrapper.c */
   1.636 + extern const struct squashfs_decompressor squashfs_zlib_comp_ops;
   1.637 ++
   1.638 ++/* lzma wrapper.c */
   1.639 ++extern const struct squashfs_decompressor squashfs_lzma_comp_ops;
   1.640 +
   1.641 +--- linux-2.6.34/lib/Makefile
   1.642 ++++ linux-2.6.34/lib/Makefile
   1.643 +@@ -69,7 +69,7 @@ obj-$(CONFIG_LZO_DECOMPRESS) += lzo/
   1.644 + 
   1.645 + lib-$(CONFIG_DECOMPRESS_GZIP) += decompress_inflate.o
   1.646 + lib-$(CONFIG_DECOMPRESS_BZIP2) += decompress_bunzip2.o
   1.647 +-lib-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
   1.648 ++obj-$(CONFIG_DECOMPRESS_LZMA) += decompress_unlzma.o
   1.649 + lib-$(CONFIG_DECOMPRESS_LZO) += decompress_unlzo.o
   1.650 + 
   1.651 + obj-$(CONFIG_TEXTSEARCH) += textsearch.o
   1.652 +