wok-6.x rev 5691

linux: add missing patches
author Pascal Bellard <pascal.bellard@slitaz.org>
date Sat Jun 05 13:07:53 2010 +0200 (2010-06-05)
parents 003ddfde863e
children 52dc580d9edb
files linux/receipt linux/stuff/linux-freeinitrd-2.6.34.u linux/stuff/linux-squashfs-lzma-2.6.34.u
line diff
     1.1 --- a/linux/receipt	Sat Jun 05 12:27:25 2010 +0200
     1.2 +++ b/linux/receipt	Sat Jun 05 13:07:53 2010 +0200
     1.3 @@ -43,8 +43,6 @@
     1.4  		echo "Apply $patch_file"
     1.5  		patch -p1 < slitaz/$patch_file || exit 1
     1.6  		touch done.$patch_file
     1.7 -		#$PACKAGE-freeinitrd-$VERSION.u
     1.8 -		#$PACKAGE-squashfs-lzma-$VERSION.u
     1.9  	done <<EOT
    1.10  $PACKAGE-diff-$VERSION.u
    1.11  $PACKAGE-unlzma-$VERSION.u
    1.12 @@ -52,6 +50,8 @@
    1.13  aufs2-base.patch
    1.14  aufs2-kbuild.patch
    1.15  aufs2-standalone.patch
    1.16 +$PACKAGE-freeinitrd-$VERSION.u
    1.17 +$PACKAGE-squashfs-lzma-$VERSION.u
    1.18  EOT
    1.19  	make mrproper
    1.20  	cd Documentation/lguest
     2.1 --- a/linux/stuff/linux-freeinitrd-2.6.34.u	Sat Jun 05 12:27:25 2010 +0200
     2.2 +++ b/linux/stuff/linux-freeinitrd-2.6.34.u	Sat Jun 05 13:07:53 2010 +0200
     2.3 @@ -1,6 +1,6 @@
     2.4  --- linux-2.6.30.4/arch/x86/mm/init.c
     2.5  +++ linux-2.6.30.4/arch/x86/mm/init.c
     2.6 -@@ -381,7 +381,7 @@
     2.7 +@@ -366,7 +366,7 @@
     2.8   	 */
     2.9   	set_memory_rw(begin, (end - begin) >> PAGE_SHIFT);
    2.10   
    2.11 @@ -90,25 +90,21 @@
    2.12   			continue;
    2.13   		}
    2.14   		if (!*buf) {
    2.15 -@@ -446,9 +497,15 @@
    2.16 - 		}
    2.17 +@@ -447,7 +497,12 @@
    2.18   		this_header = 0;
    2.19   		decompress = decompress_method(buf, len, &compress_name);
    2.20 --		if (decompress)
    2.21 --			decompress(buf, len, NULL, flush_buffer, NULL,
    2.22 -+		if (decompress) {
    2.23 + 		if (decompress) {
    2.24 +-			res = decompress(buf, len, NULL, flush_buffer, NULL,
    2.25  +			if (early_free_initrd) {
    2.26 -+				decompress(NULL, 0, fill_buffer, flush_buffer,
    2.27 -+					   NULL, &my_inptr, error);
    2.28 ++				res = decompress(NULL, 0, fill_buffer,
    2.29 ++					   flush_buffer, NULL, &my_inptr, error);
    2.30  +				my_inptr += fill.inptr;
    2.31  +			}
    2.32 -+			else decompress(buf, len, NULL, flush_buffer, NULL,
    2.33 ++			else res = decompress(buf, len, NULL, flush_buffer, NULL,
    2.34   				   &my_inptr, error);
    2.35 -+		}
    2.36 - 		else if (compress_name) {
    2.37 - 			if (!message) {
    2.38 - 				snprintf(msg_buf, sizeof msg_buf,
    2.39 -@@ -485,7 +543,8 @@
    2.40 + 			if (res)
    2.41 + 				error("decompressor failed");
    2.42 +@@ -488,7 +546,8 @@
    2.43   #include <linux/initrd.h>
    2.44   #include <linux/kexec.h>
    2.45   
    2.46 @@ -118,7 +114,7 @@
    2.47   {
    2.48   #ifdef CONFIG_KEXEC
    2.49   	unsigned long crashk_start = (unsigned long)__va(crashk_res.start);
    2.50 -@@ -513,6 +571,12 @@
    2.51 +@@ -516,6 +574,12 @@
    2.52   #endif
    2.53   		free_initrd_mem(initrd_start, initrd_end);
    2.54   skip:
     3.1 --- a/linux/stuff/linux-squashfs-lzma-2.6.34.u	Sat Jun 05 12:27:25 2010 +0200
     3.2 +++ b/linux/stuff/linux-squashfs-lzma-2.6.34.u	Sat Jun 05 13:07:53 2010 +0200
     3.3 @@ -1,5 +1,437 @@
     3.4 ---- linux-2.6.30.6/fs/squashfs/Kconfig
     3.5 -+++ linux-2.6.30.6/fs/squashfs/Kconfig
     3.6 +--- linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h
     3.7 ++++ linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h
     3.8 +@@ -0,0 +1,13 @@
     3.9 ++#ifndef BUNZIP2_MM_H
    3.10 ++#define BUNZIP2_MM_H
    3.11 ++
    3.12 ++#ifdef STATIC
    3.13 ++/* Code active when included from pre-boot environment: */
    3.14 ++#define INIT
    3.15 ++#else
    3.16 ++/* Compile for initramfs/initrd code only */
    3.17 ++#define INIT __init
    3.18 ++static void(*error)(char *m);
    3.19 ++#endif
    3.20 ++
    3.21 ++#endif
    3.22 +
    3.23 +--- linux-2.6.30.6/include/linux/decompress/inflate_mm.h
    3.24 ++++ linux-2.6.30.6/include/linux/decompress/inflate_mm.h
    3.25 +@@ -0,0 +1,13 @@
    3.26 ++#ifndef INFLATE_MM_H
    3.27 ++#define INFLATE_MM_H
    3.28 ++
    3.29 ++#ifdef STATIC
    3.30 ++/* Code active when included from pre-boot environment: */
    3.31 ++#define INIT
    3.32 ++#else
    3.33 ++/* Compile for initramfs/initrd code only */
    3.34 ++#define INIT __init
    3.35 ++static void(*error)(char *m);
    3.36 ++#endif
    3.37 ++
    3.38 ++#endif
    3.39 +
    3.40 +#--- linux-2.6.30.6/include/linux/decompress/mm.h
    3.41 +#+++ linux-2.6.30.6/include/linux/decompress/mm.h
    3.42 +@@ -63,8 +63,6 @@
    3.43 + 
    3.44 + #define set_error_fn(x)
    3.45 + 
    3.46 +-#define INIT
    3.47 +-
    3.48 + #else /* STATIC */
    3.49 + 
    3.50 + /* Code active when compiled standalone for use when loading ramdisk: */
    3.51 +@@ -84,10 +82,8 @@
    3.52 + #define large_malloc(a) vmalloc(a)
    3.53 + #define large_free(a) vfree(a)
    3.54 + 
    3.55 +-static void(*error)(char *m);
    3.56 + #define set_error_fn(x) error = x;
    3.57 + 
    3.58 +-#define INIT __init
    3.59 + #define STATIC
    3.60 + 
    3.61 + #include <linux/init.h>
    3.62 +
    3.63 +--- linux-2.6.30.6/include/linux/decompress/unlzma_mm.h
    3.64 ++++ linux-2.6.30.6/include/linux/decompress/unlzma_mm.h
    3.65 +@@ -0,0 +1,20 @@
    3.66 ++#ifndef UNLZMA_MM_H
    3.67 ++#define UNLZMA_MM_H
    3.68 ++
    3.69 ++#ifdef STATIC
    3.70 ++
    3.71 ++/* Code active when included from pre-boot environment: */
    3.72 ++#define INIT
    3.73 ++
    3.74 ++#elif defined(CONFIG_DECOMPRESS_LZMA_NEEDED)
    3.75 ++
    3.76 ++/* Make it available to non initramfs/initrd code */
    3.77 ++#define INIT
    3.78 ++#include <linux/module.h>
    3.79 ++#else
    3.80 ++
    3.81 ++/* Compile for initramfs/initrd code only */
    3.82 ++#define INIT __init
    3.83 ++#endif
    3.84 ++
    3.85 ++#endif
    3.86 +
    3.87 +--- linux-2.6.30.6/lib/Kconfig
    3.88 ++++ linux-2.6.30.6/lib/Kconfig
    3.89 +@@ -117,6 +117,9 @@
    3.90 + config DECOMPRESS_LZMA
    3.91 + 	tristate
    3.92 + 
    3.93 ++config DECOMPRESS_LZMA_NEEDED
    3.94 ++	 boolean
    3.95 ++
    3.96 + config DECOMPRESS_LZO
    3.97 + 	select LZO_DECOMPRESS
    3.98 + 	tristate
    3.99 +
   3.100 +--- linux-2.6.30.6/lib/decompress_bunzip2.c
   3.101 ++++ linux-2.6.30.6/lib/decompress_bunzip2.c
   3.102 +@@ -52,6 +52,7 @@
   3.103 + #include <linux/slab.h>
   3.104 + #endif /* STATIC */
   3.105 + 
   3.106 ++#include <linux/decompress/bunzip2_mm.h>
   3.107 + #include <linux/decompress/mm.h>
   3.108 + 
   3.109 + #ifndef INT_MAX
   3.110 +
   3.111 +--- linux-2.6.30.6/lib/decompress_inflate.c
   3.112 ++++ linux-2.6.30.6/lib/decompress_inflate.c
   3.113 +@@ -23,6 +23,7 @@
   3.114 + 
   3.115 + #endif /* STATIC */
   3.116 + 
   3.117 ++#include <linux/decompress/inflate_mm.h>
   3.118 + #include <linux/decompress/mm.h>
   3.119 + 
   3.120 + #define GZIP_IOBUF_SIZE (16*1024)
   3.121 +
   3.122 +--- linux-2.6.30.6/lib/decompress_unlzma.c
   3.123 ++++ linux-2.6.30.6/lib/decompress_unlzma.c
   3.124 +@@ -36,6 +36,7 @@
   3.125 + #include <linux/slab.h>
   3.126 + #endif /* STATIC */
   3.127 + 
   3.128 ++#include <linux/decompress/unlzma_mm.h>
   3.129 + #include <linux/decompress/mm.h>
   3.130 + 
   3.131 + #define	MIN(a, b) (((a) < (b)) ? (a) : (b))
   3.132 +@@ -88,7 +89,7 @@
   3.133 + }
   3.134 + 
   3.135 + /* Called twice: once at startup and once in rc_normalize() */
   3.136 +-static void INIT rc_read(struct rc *rc)
   3.137 ++static void INIT rc_read(struct rc *rc, void(*error)(char *x))
   3.138 + {
   3.139 + 	rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE);
   3.140 + 	if (rc->buffer_size <= 0)
   3.141 +@@ -115,13 +116,13 @@
   3.142 + 	rc->range = 0xFFFFFFFF;
   3.143 + }
   3.144 + 
   3.145 +-static inline void INIT rc_init_code(struct rc *rc)
   3.146 ++static inline void INIT rc_init_code(struct rc *rc, void(*error)(char *x))
   3.147 + {
   3.148 + 	int i;
   3.149 + 
   3.150 + 	for (i = 0; i < 5; i++) {
   3.151 + 		if (rc->ptr >= rc->buffer_end)
   3.152 +-			rc_read(rc);
   3.153 ++			rc_read(rc, error);
   3.154 + 		rc->code = (rc->code << 8) | *rc->ptr++;
   3.155 + 	}
   3.156 + }
   3.157 +@@ -134,32 +135,33 @@
   3.158 + }
   3.159 + 
   3.160 + /* Called twice, but one callsite is in inline'd rc_is_bit_0_helper() */
   3.161 +-static void INIT rc_do_normalize(struct rc *rc)
   3.162 ++static void INIT rc_do_normalize(struct rc *rc, void(*error)(char *x))
   3.163 + {
   3.164 + 	if (rc->ptr >= rc->buffer_end)
   3.165 +-		rc_read(rc);
   3.166 ++		rc_read(rc, error);
   3.167 + 	rc->range <<= 8;
   3.168 + 	rc->code = (rc->code << 8) | *rc->ptr++;
   3.169 + }
   3.170 +-static inline void INIT rc_normalize(struct rc *rc)
   3.171 ++static inline void INIT rc_normalize(struct rc *rc, void(*error)(char *x))
   3.172 + {
   3.173 + 	if (rc->range < (1 << RC_TOP_BITS))
   3.174 +-		rc_do_normalize(rc);
   3.175 ++		rc_do_normalize(rc, error);
   3.176 + }
   3.177 + 
   3.178 + /* Called 9 times */
   3.179 + /* Why rc_is_bit_0_helper exists?
   3.180 +  *Because we want to always expose (rc->code < rc->bound) to optimizer
   3.181 +  */
   3.182 +-static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p)
   3.183 ++static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p,
   3.184 ++					       void (*error)(char *x))
   3.185 + {
   3.186 +-	rc_normalize(rc);
   3.187 ++	rc_normalize(rc, error);
   3.188 + 	rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
   3.189 + 	return rc->bound;
   3.190 + }
   3.191 +-static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p)
   3.192 ++static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p, void(*error)(char *x))
   3.193 + {
   3.194 +-	uint32_t t = rc_is_bit_0_helper(rc, p);
   3.195 ++	uint32_t t = rc_is_bit_0_helper(rc, p, error);
   3.196 + 	return rc->code < t;
   3.197 + }
   3.198 + 
   3.199 +@@ -177,9 +179,9 @@
   3.200 + }
   3.201 + 
   3.202 + /* Called 4 times in unlzma loop */
   3.203 +-static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol)
   3.204 ++static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol, void(*error)(char *x))
   3.205 + {
   3.206 +-	if (rc_is_bit_0(rc, p)) {
   3.207 ++	if (rc_is_bit_0(rc, p, error)) {
   3.208 + 		rc_update_bit_0(rc, p);
   3.209 + 		*symbol *= 2;
   3.210 + 		return 0;
   3.211 +@@ -191,9 +193,9 @@
   3.212 + }
   3.213 + 
   3.214 + /* Called once */
   3.215 +-static inline int INIT rc_direct_bit(struct rc *rc)
   3.216 ++static inline int INIT rc_direct_bit(struct rc *rc , void(*error)(char *x))
   3.217 + {
   3.218 +-	rc_normalize(rc);
   3.219 ++	rc_normalize(rc, error);
   3.220 + 	rc->range >>= 1;
   3.221 + 	if (rc->code >= rc->range) {
   3.222 + 		rc->code -= rc->range;
   3.223 +@@ -204,13 +206,14 @@
   3.224 + 
   3.225 + /* Called twice */
   3.226 + static inline void INIT
   3.227 +-rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol)
   3.228 ++rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol,
   3.229 ++							void(*error)(char *x))
   3.230 + {
   3.231 + 	int i = num_levels;
   3.232 + 
   3.233 + 	*symbol = 1;
   3.234 + 	while (i--)
   3.235 +-		rc_get_bit(rc, p + *symbol, symbol);
   3.236 ++		rc_get_bit(rc, p + *symbol, symbol, error);
   3.237 + 	*symbol -= 1 << num_levels;
   3.238 + }
   3.239 + 
   3.240 +@@ -406,7 +409,8 @@
   3.241 + static inline void INIT process_bit0(struct writer *wr, struct rc *rc,
   3.242 + 				     struct cstate *cst, uint16_t *p,
   3.243 + 				     int pos_state, uint16_t *prob,
   3.244 +-				     int lc, uint32_t literal_pos_mask) {
   3.245 ++				     int lc, uint32_t literal_pos_mask,
   3.246 ++				     void(*error)(char *x)) {
   3.247 + 	int mi = 1;
   3.248 + 	static const int state[LZMA_NUM_STATES] = 
   3.249 + 		{ 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
   3.250 +@@ -427,7 +431,7 @@
   3.251 + 			match_byte <<= 1;
   3.252 + 			bit = match_byte & 0x100;
   3.253 + 			prob_lit = prob + 0x100 + bit + mi;
   3.254 +-			if (rc_get_bit(rc, prob_lit, &mi)) {
   3.255 ++			if (rc_get_bit(rc, prob_lit, &mi, error)) {
   3.256 + 				if (!bit)
   3.257 + 					break;
   3.258 + 			} else {
   3.259 +@@ -438,7 +442,7 @@
   3.260 + 	}
   3.261 + 	while (mi < 0x100) {
   3.262 + 		uint16_t *prob_lit = prob + mi;
   3.263 +-		rc_get_bit(rc, prob_lit, &mi);
   3.264 ++		rc_get_bit(rc, prob_lit, &mi, error);
   3.265 + 	}
   3.266 + 	write_byte(wr, mi);
   3.267 + 	cst->state = state[cst->state];
   3.268 +@@ -446,7 +453,8 @@
   3.269 + 
   3.270 + static inline void INIT process_bit1(struct writer *wr, struct rc *rc,
   3.271 + 					    struct cstate *cst, uint16_t *p,
   3.272 +-					    int pos_state, uint16_t *prob) {
   3.273 ++					    int pos_state, uint16_t *prob,
   3.274 ++					    void(*error)(char *x)) {
   3.275 + 	int offset;
   3.276 + 	uint16_t *prob_len;
   3.277 + 	int num_bits;
   3.278 +@@ -454,7 +459,7 @@
   3.279 + 
   3.280 + 	rc_update_bit_1(rc, prob);
   3.281 + 	prob = p + LZMA_IS_REP + cst->state;
   3.282 +-	if (rc_is_bit_0(rc, prob)) {
   3.283 ++	if (rc_is_bit_0(rc, prob, error)) {
   3.284 + 		rc_update_bit_0(rc, prob);
   3.285 + 		cst->rep3 = cst->rep2;
   3.286 + 		cst->rep2 = cst->rep1;
   3.287 +@@ -464,13 +469,13 @@
   3.288 + 	} else {
   3.289 + 		rc_update_bit_1(rc, prob);
   3.290 + 		prob += LZMA_IS_REP_G0 - LZMA_IS_REP;
   3.291 +-		if (rc_is_bit_0(rc, prob)) {
   3.292 ++		if (rc_is_bit_0(rc, prob, error)) {
   3.293 + 			rc_update_bit_0(rc, prob);
   3.294 + 			prob = (p + LZMA_IS_REP_0_LONG
   3.295 + 				+ (cst->state <<
   3.296 + 				   LZMA_NUM_POS_BITS_MAX) +
   3.297 + 				pos_state);
   3.298 +-			if (rc_is_bit_0(rc, prob)) {
   3.299 ++			if (rc_is_bit_0(rc, prob, error)) {
   3.300 + 				rc_update_bit_0(rc, prob);
   3.301 + 
   3.302 + 				cst->state = cst->state < LZMA_NUM_LIT_STATES ?
   3.303 +@@ -485,13 +490,13 @@
   3.304 + 
   3.305 + 			rc_update_bit_1(rc, prob);
   3.306 + 			prob += LZMA_IS_REP_G1 - LZMA_IS_REP_G0;
   3.307 +-			if (rc_is_bit_0(rc, prob)) {
   3.308 ++			if (rc_is_bit_0(rc, prob, error)) {
   3.309 + 				rc_update_bit_0(rc, prob);
   3.310 + 				distance = cst->rep1;
   3.311 + 			} else {
   3.312 + 				rc_update_bit_1(rc, prob);
   3.313 + 				prob += LZMA_IS_REP_G2 - LZMA_IS_REP_G1;
   3.314 +-				if (rc_is_bit_0(rc, prob)) {
   3.315 ++				if (rc_is_bit_0(rc, prob, error)) {
   3.316 + 					rc_update_bit_0(rc, prob);
   3.317 + 					distance = cst->rep2;
   3.318 + 				} else {
   3.319 +@@ -509,7 +514,7 @@
   3.320 + 	}
   3.321 + 
   3.322 + 	prob_len = prob + LZMA_LEN_CHOICE;
   3.323 +-	if (rc_is_bit_0(rc, prob_len)) {
   3.324 ++	if (rc_is_bit_0(rc, prob_len, error)) {
   3.325 + 		rc_update_bit_0(rc, prob_len);
   3.326 + 		prob_len += LZMA_LEN_LOW - LZMA_LEN_CHOICE
   3.327 + 			    + (pos_state <<
   3.328 +@@ -519,7 +524,7 @@
   3.329 + 	} else {
   3.330 + 		rc_update_bit_1(rc, prob_len);
   3.331 + 		prob_len += LZMA_LEN_CHOICE_2 - LZMA_LEN_CHOICE;
   3.332 +-		if (rc_is_bit_0(rc, prob_len)) {
   3.333 ++		if (rc_is_bit_0(rc, prob_len, error)) {
   3.334 + 			rc_update_bit_0(rc, prob_len);
   3.335 + 			prob_len += LZMA_LEN_MID - LZMA_LEN_CHOICE_2
   3.336 + 				    + (pos_state <<
   3.337 +@@ -535,7 +540,7 @@
   3.338 + 		}
   3.339 + 	}
   3.340 + 
   3.341 +-	rc_bit_tree_decode(rc, prob_len, num_bits, &len);
   3.342 ++	rc_bit_tree_decode(rc, prob_len, num_bits, &len, error);
   3.343 + 	len += offset;
   3.344 + 
   3.345 + 	if (cst->state < 4) {
   3.346 +@@ -550,7 +555,7 @@
   3.347 + 			 << LZMA_NUM_POS_SLOT_BITS);
   3.348 + 		rc_bit_tree_decode(rc, prob,
   3.349 + 				   LZMA_NUM_POS_SLOT_BITS,
   3.350 +-				   &pos_slot);
   3.351 ++				   &pos_slot, error);
   3.352 + 		if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
   3.353 + 			int i, mi;
   3.354 + 			num_bits = (pos_slot >> 1) - 1;
   3.355 +@@ -563,7 +568,7 @@
   3.356 + 				num_bits -= LZMA_NUM_ALIGN_BITS;
   3.357 + 				while (num_bits--)
   3.358 + 					cst->rep0 = (cst->rep0 << 1) |
   3.359 +-						rc_direct_bit(rc);
   3.360 ++						rc_direct_bit(rc, error);
   3.361 + 				prob = p + LZMA_ALIGN;
   3.362 + 				cst->rep0 <<= LZMA_NUM_ALIGN_BITS;
   3.363 + 				num_bits = LZMA_NUM_ALIGN_BITS;
   3.364 +@@ -571,7 +576,7 @@
   3.365 + 			i = 1;
   3.366 + 			mi = 1;
   3.367 + 			while (num_bits--) {
   3.368 +-				if (rc_get_bit(rc, prob + mi, &mi))
   3.369 ++				if (rc_get_bit(rc, prob + mi, &mi, error))
   3.370 + 					cst->rep0 |= i;
   3.371 + 				i <<= 1;
   3.372 + 			}
   3.373 +@@ -588,12 +593,12 @@
   3.374 + 
   3.375 + 
   3.376 + 
   3.377 +-STATIC inline int INIT unlzma(unsigned char *buf, int in_len,
   3.378 ++STATIC int INIT unlzma(unsigned char *buf, int in_len,
   3.379 + 			      int(*fill)(void*, unsigned int),
   3.380 + 			      int(*flush)(void*, unsigned int),
   3.381 + 			      unsigned char *output,
   3.382 + 			      int *posp,
   3.383 +-			      void(*error_fn)(char *x)
   3.384 ++			      void(*error)(char *x)
   3.385 + 	)
   3.386 + {
   3.387 + 	extern int cpio_flush_buffer(void*, unsigned int);
   3.388 +@@ -610,7 +615,6 @@
   3.389 + 	unsigned char *inbuf;
   3.390 + 	int ret = -1;
   3.391 + 
   3.392 +-	set_error_fn(error_fn);
   3.393 + 
   3.394 + 	if (buf)
   3.395 + 		inbuf = buf;
   3.396 +@@ -638,7 +642,7 @@
   3.397 + 
   3.398 + 	for (i = 0; i < sizeof(header); i++) {
   3.399 + 		if (rc.ptr >= rc.buffer_end)
   3.400 +-			rc_read(&rc);
   3.401 ++			rc_read(&rc, error);
   3.402 + 		((unsigned char *)&header)[i] = *rc.ptr++;
   3.403 + 	}
   3.404 + 
   3.405 +@@ -683,17 +687,17 @@
   3.406 + 	for (i = 0; i < num_probs; i++)
   3.407 + 		p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
   3.408 + 	wr.max_index = wr.next_index = 0;
   3.409 +-	rc_init_code(&rc);
   3.410 ++	rc_init_code(&rc, error);
   3.411 + 
   3.412 + 	while (get_pos(&wr) < header.dst_size) {
   3.413 + 		int pos_state =	get_pos(&wr) & pos_state_mask;
   3.414 + 		uint16_t *prob = p + LZMA_IS_MATCH +
   3.415 + 			(cst.state << LZMA_NUM_POS_BITS_MAX) + pos_state;
   3.416 +-		if (rc_is_bit_0(&rc, prob))
   3.417 ++		if (rc_is_bit_0(&rc, prob, error))
   3.418 + 			process_bit0(&wr, &rc, &cst, p, pos_state, prob,
   3.419 +-				     lc, literal_pos_mask);
   3.420 ++				     lc, literal_pos_mask, error);
   3.421 + 		else {
   3.422 +-			process_bit1(&wr, &rc, &cst, p, pos_state, prob);
   3.423 ++			process_bit1(&wr, &rc, &cst, p, pos_state, prob, error);
   3.424 + 			if (cst.rep0 == 0)
   3.425 + 				break;
   3.426 + 		}
   3.427 +@@ -727,6 +731,9 @@
   3.428 + exit_0:
   3.429 + 	return ret;
   3.430 + }
   3.431 ++#if defined(CONFIG_DECOMPRESS_LZMA_NEEDED) && !defined(PREBOOT)
   3.432 ++EXPORT_SYMBOL(unlzma);
   3.433 ++#endif
   3.434 + 
   3.435 + #ifdef PREBOOT
   3.436 + STATIC int INIT decompress(unsigned char *buf, int in_len,
   3.437 +
   3.438 +--- linux-2.6.34/fs/squashfs/Kconfig
   3.439 ++++ linux-2.6.34/fs/squashfs/Kconfig
   3.440  @@ -26,6 +26,12 @@
   3.441   
   3.442   	  If unsure, say N.
   3.443 @@ -14,338 +446,32 @@
   3.444   
   3.445   	bool "Additional option for memory-constrained systems" 
   3.446  
   3.447 ---- linux-2.6.30.6/fs/squashfs/Makefile
   3.448 -+++ linux-2.6.30.6/fs/squashfs/Makefile
   3.449 -@@ -4,4 +4,5 @@
   3.450 - 
   3.451 +--- linux-2.6.34/fs/squashfs/Makefile
   3.452 ++++ linux-2.6.34/fs/squashfs/Makefile
   3.453 +@@ -5,3 +5,4 @@
   3.454   obj-$(CONFIG_SQUASHFS) += squashfs.o
   3.455   squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
   3.456 --squashfs-y += namei.o super.o symlink.o
   3.457 -+squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o
   3.458 + squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o
   3.459  +squashfs-$(CONFIG_SQUASHFS_LZMA) += lzma_wrapper.o
   3.460  
   3.461 ---- linux-2.6.30.6/fs/squashfs/block.c
   3.462 -+++ linux-2.6.30.6/fs/squashfs/block.c
   3.463 -@@ -29,15 +29,14 @@
   3.464 - #include <linux/fs.h>
   3.465 - #include <linux/vfs.h>
   3.466 - #include <linux/slab.h>
   3.467 --#include <linux/mutex.h>
   3.468 - #include <linux/string.h>
   3.469 - #include <linux/buffer_head.h>
   3.470 --#include <linux/zlib.h>
   3.471 +--- linux-2.6.34/fs/squashfs/decompressor.c
   3.472 ++++ linux-2.6.34/fs/squashfs/decompressor.c
   3.473 +@@ -50,7 +50,11 @@
   3.474   
   3.475 - #include "squashfs_fs.h"
   3.476 - #include "squashfs_fs_sb.h"
   3.477 - #include "squashfs_fs_i.h"
   3.478 - #include "squashfs.h"
   3.479 -+#include "decompressor.h"
   3.480 - 
   3.481 - /*
   3.482 -  * Read the metadata block length, this is stored in the first two
   3.483 -@@ -153,72 +152,10 @@
   3.484 - 	}
   3.485 - 
   3.486 - 	if (compressed) {
   3.487 --		int zlib_err = 0, zlib_init = 0;
   3.488 --
   3.489 --		/*
   3.490 --		 * Uncompress block.
   3.491 --		 */
   3.492 --
   3.493 --		mutex_lock(&msblk->read_data_mutex);
   3.494 --
   3.495 --		msblk->stream.avail_out = 0;
   3.496 --		msblk->stream.avail_in = 0;
   3.497 --
   3.498 --		bytes = length;
   3.499 --		do {
   3.500 --			if (msblk->stream.avail_in == 0 && k < b) {
   3.501 --				avail = min(bytes, msblk->devblksize - offset);
   3.502 --				bytes -= avail;
   3.503 --				wait_on_buffer(bh[k]);
   3.504 --				if (!buffer_uptodate(bh[k]))
   3.505 --					goto release_mutex;
   3.506 --
   3.507 --				if (avail == 0) {
   3.508 --					offset = 0;
   3.509 --					put_bh(bh[k++]);
   3.510 --					continue;
   3.511 --				}
   3.512 --
   3.513 --				msblk->stream.next_in = bh[k]->b_data + offset;
   3.514 --				msblk->stream.avail_in = avail;
   3.515 --				offset = 0;
   3.516 --			}
   3.517 --
   3.518 --			if (msblk->stream.avail_out == 0 && page < pages) {
   3.519 --				msblk->stream.next_out = buffer[page++];
   3.520 --				msblk->stream.avail_out = PAGE_CACHE_SIZE;
   3.521 --			}
   3.522 --
   3.523 --			if (!zlib_init) {
   3.524 --				zlib_err = zlib_inflateInit(&msblk->stream);
   3.525 --				if (zlib_err != Z_OK) {
   3.526 --					ERROR("zlib_inflateInit returned"
   3.527 --						" unexpected result 0x%x,"
   3.528 --						" srclength %d\n", zlib_err,
   3.529 --						srclength);
   3.530 --					goto release_mutex;
   3.531 --				}
   3.532 --				zlib_init = 1;
   3.533 --			}
   3.534 --
   3.535 --			zlib_err = zlib_inflate(&msblk->stream, Z_SYNC_FLUSH);
   3.536 --
   3.537 --			if (msblk->stream.avail_in == 0 && k < b)
   3.538 --				put_bh(bh[k++]);
   3.539 --		} while (zlib_err == Z_OK);
   3.540 --
   3.541 --		if (zlib_err != Z_STREAM_END) {
   3.542 --			ERROR("zlib_inflate error, data probably corrupt\n");
   3.543 --			goto release_mutex;
   3.544 --		}
   3.545 --
   3.546 --		zlib_err = zlib_inflateEnd(&msblk->stream);
   3.547 --		if (zlib_err != Z_OK) {
   3.548 --			ERROR("zlib_inflate error, data probably corrupt\n");
   3.549 --			goto release_mutex;
   3.550 --		}
   3.551 --		length = msblk->stream.total_out;
   3.552 --		mutex_unlock(&msblk->read_data_mutex);
   3.553 -+		length = squashfs_decompress(msblk, buffer, bh, b, offset,
   3.554 -+			 length, srclength, pages);
   3.555 -+		if (length < 0)
   3.556 -+			goto read_failure;
   3.557 - 	} else {
   3.558 - 		/*
   3.559 - 		 * Block is uncompressed.
   3.560 -@@ -254,9 +191,6 @@
   3.561 - 
   3.562 - 	kfree(bh);
   3.563 - 	return length;
   3.564 --
   3.565 --release_mutex:
   3.566 --	mutex_unlock(&msblk->read_data_mutex);
   3.567 - 
   3.568 - block_release:
   3.569 - 	for (; k < b; k++)
   3.570 -
   3.571 ---- linux-2.6.30.6/fs/squashfs/cache.c
   3.572 -+++ linux-2.6.30.6/fs/squashfs/cache.c
   3.573 -@@ -51,7 +51,6 @@
   3.574 - #include <linux/sched.h>
   3.575 - #include <linux/spinlock.h>
   3.576 - #include <linux/wait.h>
   3.577 --#include <linux/zlib.h>
   3.578 - #include <linux/pagemap.h>
   3.579 - 
   3.580 - #include "squashfs_fs.h"
   3.581 -
   3.582 ---- linux-2.6.30.6/fs/squashfs/decompressor.c
   3.583 -+++ linux-2.6.30.6/fs/squashfs/decompressor.c
   3.584 -@@ -0,0 +1,72 @@
   3.585 -+/*
   3.586 -+ * Squashfs - a compressed read only filesystem for Linux
   3.587 -+ *
   3.588 -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
   3.589 -+ * Phillip Lougher <phillip@lougher.demon.co.uk>
   3.590 -+ *
   3.591 -+ * This program is free software; you can redistribute it and/or
   3.592 -+ * modify it under the terms of the GNU General Public License
   3.593 -+ * as published by the Free Software Foundation; either version 2,
   3.594 -+ * or (at your option) any later version.
   3.595 -+ *
   3.596 -+ * This program is distributed in the hope that it will be useful,
   3.597 -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
   3.598 -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   3.599 -+ * GNU General Public License for more details.
   3.600 -+ *
   3.601 -+ * You should have received a copy of the GNU General Public License
   3.602 -+ * along with this program; if not, write to the Free Software
   3.603 -+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
   3.604 -+ *
   3.605 -+ * decompressor.c
   3.606 -+ */
   3.607 -+
   3.608 -+#include <linux/types.h>
   3.609 -+#include <linux/mutex.h>
   3.610 -+#include <linux/buffer_head.h>
   3.611 -+
   3.612 -+#include "squashfs_fs.h"
   3.613 -+#include "squashfs_fs_sb.h"
   3.614 -+#include "squashfs_fs_i.h"
   3.615 -+#include "decompressor.h"
   3.616 -+#include "squashfs.h"
   3.617 -+
   3.618 -+/*
   3.619 -+ * This file (and decompressor.h) implements a decompressor framework for
   3.620 -+ * Squashfs, allowing multiple decompressors to be easily supported
   3.621 -+ */
   3.622 -+
   3.623 -+static const struct squashfs_decompressor squashfs_lzma_unsupported_comp_ops = {
   3.624 -+	NULL, NULL, NULL, LZMA_COMPRESSION, "lzma", 0
   3.625 -+};
   3.626 -+
   3.627 -+static const struct squashfs_decompressor squashfs_lzo_unsupported_comp_ops = {
   3.628 -+	NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0
   3.629 -+};
   3.630 -+
   3.631 -+static const struct squashfs_decompressor squashfs_unknown_comp_ops = {
   3.632 -+	NULL, NULL, NULL, 0, "unknown", 0
   3.633 -+};
   3.634 -+
   3.635 -+static const struct squashfs_decompressor *decompressor[] = {
   3.636 -+	&squashfs_zlib_comp_ops,
   3.637 + static const struct squashfs_decompressor *decompressor[] = {
   3.638 + 	&squashfs_zlib_comp_ops,
   3.639  +#ifdef CONFIG_SQUASHFS_LZMA
   3.640  +	&squashfs_lzma_comp_ops,
   3.641  +#else
   3.642 -+	&squashfs_lzma_unsupported_comp_ops,
   3.643 + 	&squashfs_lzma_unsupported_comp_ops,
   3.644  +#endif
   3.645 -+	&squashfs_lzo_unsupported_comp_ops,
   3.646 -+	&squashfs_unknown_comp_ops
   3.647 -+};
   3.648 -+
   3.649 -+
   3.650 -+const struct squashfs_decompressor *squashfs_lookup_decompressor(int id)
   3.651 -+{
   3.652 -+	int i;
   3.653 -+
   3.654 -+	for (i = 0; decompressor[i]->id; i++)
   3.655 -+		if (id == decompressor[i]->id)
   3.656 -+			break;
   3.657 -+
   3.658 -+	return decompressor[i];
   3.659 -+}
   3.660 + 	&squashfs_lzo_unsupported_comp_ops,
   3.661 + 	&squashfs_unknown_comp_ops
   3.662 + };
   3.663  
   3.664 ---- linux-2.6.30.6/fs/squashfs/decompressor.h
   3.665 -+++ linux-2.6.30.6/fs/squashfs/decompressor.h
   3.666 -@@ -0,0 +1,55 @@
   3.667 -+#ifndef DECOMPRESSOR_H
   3.668 -+#define DECOMPRESSOR_H
   3.669 -+/*
   3.670 -+ * Squashfs - a compressed read only filesystem for Linux
   3.671 -+ *
   3.672 -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
   3.673 -+ * Phillip Lougher <phillip@lougher.demon.co.uk>
   3.674 -+ *
   3.675 -+ * This program is free software; you can redistribute it and/or
   3.676 -+ * modify it under the terms of the GNU General Public License
   3.677 -+ * as published by the Free Software Foundation; either version 2,
   3.678 -+ * or (at your option) any later version.
   3.679 -+ *
   3.680 -+ * This program is distributed in the hope that it will be useful,
   3.681 -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
   3.682 -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
   3.683 -+ * GNU General Public License for more details.
   3.684 -+ *
   3.685 -+ * You should have received a copy of the GNU General Public License
   3.686 -+ * along with this program; if not, write to the Free Software
   3.687 -+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
   3.688 -+ *
   3.689 -+ * decompressor.h
   3.690 -+ */
   3.691 -+
   3.692 -+struct squashfs_decompressor {
   3.693 -+	void	*(*init)(struct squashfs_sb_info *);
   3.694 -+	void	(*free)(void *);
   3.695 -+	int	(*decompress)(struct squashfs_sb_info *, void **,
   3.696 -+		struct buffer_head **, int, int, int, int, int);
   3.697 -+	int	id;
   3.698 -+	char	*name;
   3.699 -+	int	supported;
   3.700 -+};
   3.701 -+
   3.702 -+static inline void *squashfs_decompressor_init(struct squashfs_sb_info *msblk)
   3.703 -+{
   3.704 -+	return msblk->decompressor->init(msblk);
   3.705 -+}
   3.706 -+
   3.707 -+static inline void squashfs_decompressor_free(struct squashfs_sb_info *msblk,
   3.708 -+	void *s)
   3.709 -+{
   3.710 -+	if (msblk->decompressor)
   3.711 -+		msblk->decompressor->free(s);
   3.712 -+}
   3.713 -+
   3.714 -+static inline int squashfs_decompress(struct squashfs_sb_info *msblk,
   3.715 -+	void **buffer, struct buffer_head **bh, int b, int offset, int length,
   3.716 -+	int srclength, int pages)
   3.717 -+{
   3.718 -+	return msblk->decompressor->decompress(msblk, buffer, bh, b, offset,
   3.719 -+		length, srclength, pages);
   3.720 -+}
   3.721 -+#endif
   3.722 -
   3.723 ---- linux-2.6.30.6/fs/squashfs/dir.c
   3.724 -+++ linux-2.6.30.6/fs/squashfs/dir.c
   3.725 -@@ -30,7 +30,6 @@
   3.726 - #include <linux/fs.h>
   3.727 - #include <linux/vfs.h>
   3.728 - #include <linux/slab.h>
   3.729 --#include <linux/zlib.h>
   3.730 - 
   3.731 - #include "squashfs_fs.h"
   3.732 - #include "squashfs_fs_sb.h"
   3.733 -
   3.734 ---- linux-2.6.30.6/fs/squashfs/export.c
   3.735 -+++ linux-2.6.30.6/fs/squashfs/export.c
   3.736 -@@ -39,7 +39,6 @@
   3.737 - #include <linux/vfs.h>
   3.738 - #include <linux/dcache.h>
   3.739 - #include <linux/exportfs.h>
   3.740 --#include <linux/zlib.h>
   3.741 - #include <linux/slab.h>
   3.742 - 
   3.743 - #include "squashfs_fs.h"
   3.744 -
   3.745 ---- linux-2.6.30.6/fs/squashfs/file.c
   3.746 -+++ linux-2.6.30.6/fs/squashfs/file.c
   3.747 -@@ -47,7 +47,6 @@
   3.748 - #include <linux/string.h>
   3.749 - #include <linux/pagemap.h>
   3.750 - #include <linux/mutex.h>
   3.751 --#include <linux/zlib.h>
   3.752 - 
   3.753 - #include "squashfs_fs.h"
   3.754 - #include "squashfs_fs_sb.h"
   3.755 -
   3.756 ---- linux-2.6.30.6/fs/squashfs/fragment.c
   3.757 -+++ linux-2.6.30.6/fs/squashfs/fragment.c
   3.758 -@@ -36,7 +36,6 @@
   3.759 - #include <linux/fs.h>
   3.760 - #include <linux/vfs.h>
   3.761 - #include <linux/slab.h>
   3.762 --#include <linux/zlib.h>
   3.763 - 
   3.764 - #include "squashfs_fs.h"
   3.765 - #include "squashfs_fs_sb.h"
   3.766 -
   3.767 ---- linux-2.6.30.6/fs/squashfs/id.c
   3.768 -+++ linux-2.6.30.6/fs/squashfs/id.c
   3.769 -@@ -34,7 +34,6 @@
   3.770 - #include <linux/fs.h>
   3.771 - #include <linux/vfs.h>
   3.772 - #include <linux/slab.h>
   3.773 --#include <linux/zlib.h>
   3.774 - 
   3.775 - #include "squashfs_fs.h"
   3.776 - #include "squashfs_fs_sb.h"
   3.777 -
   3.778 ---- linux-2.6.30.6/fs/squashfs/inode.c
   3.779 -+++ linux-2.6.30.6/fs/squashfs/inode.c
   3.780 -@@ -40,7 +40,6 @@
   3.781 - 
   3.782 - #include <linux/fs.h>
   3.783 - #include <linux/vfs.h>
   3.784 --#include <linux/zlib.h>
   3.785 - 
   3.786 - #include "squashfs_fs.h"
   3.787 - #include "squashfs_fs_sb.h"
   3.788 -
   3.789 ---- linux-2.6.30.6/fs/squashfs/lzma_wrapper.c
   3.790 -+++ linux-2.6.30.6/fs/squashfs/lzma_wrapper.c
   3.791 -@@ -0,0 +1,151 @@
   3.792 +--- linux-2.6.34/fs/squashfs/lzma_wrapper.c
   3.793 ++++ linux-2.6.34/fs/squashfs/lzma_wrapper.c
   3.794 +@@ -0,0 +1,152 @@
   3.795  +/*
   3.796  + * Squashfs - a compressed read only filesystem for Linux
   3.797  + *
   3.798 @@ -370,6 +496,7 @@
   3.799  + */
   3.800  +
   3.801  +#include <asm/unaligned.h>
   3.802 ++#include <linux/slab.h>
   3.803  +#include <linux/buffer_head.h>
   3.804  +#include <linux/mutex.h>
   3.805  +#include <linux/vmalloc.h>
   3.806 @@ -498,1127 +625,13 @@
   3.807  +};
   3.808  +
   3.809  
   3.810 ---- linux-2.6.30.6/fs/squashfs/namei.c
   3.811 -+++ linux-2.6.30.6/fs/squashfs/namei.c
   3.812 -@@ -57,7 +57,6 @@
   3.813 - #include <linux/slab.h>
   3.814 - #include <linux/string.h>
   3.815 - #include <linux/dcache.h>
   3.816 --#include <linux/zlib.h>
   3.817 +--- linux-2.6.34/fs/squashfs/squashfs.h
   3.818 ++++ linux-2.6.34/fs/squashfs/squashfs.h
   3.819 +@@ -94,3 +94,6 @@
   3.820   
   3.821 - #include "squashfs_fs.h"
   3.822 - #include "squashfs_fs_sb.h"
   3.823 -
   3.824 ---- linux-2.6.30.6/fs/squashfs/squashfs.h
   3.825 -+++ linux-2.6.30.6/fs/squashfs/squashfs.h
   3.826 -@@ -51,6 +51,9 @@
   3.827 - 				u64, int);
   3.828 - extern int squashfs_read_table(struct super_block *, void *, u64, int);
   3.829 - 
   3.830 -+/* decompressor.c */
   3.831 -+extern const struct squashfs_decompressor *squashfs_lookup_decompressor(int);
   3.832 -+
   3.833 - /* export.c */
   3.834 - extern __le64 *squashfs_read_inode_lookup_table(struct super_block *, u64,
   3.835 - 				unsigned int);
   3.836 -@@ -71,7 +74,7 @@
   3.837 - extern int squashfs_read_inode(struct inode *, long long);
   3.838 - 
   3.839 - /*
   3.840 -- * Inodes and files operations
   3.841 -+ * Inodes, files and decompressor operations
   3.842 -  */
   3.843 - 
   3.844 - /* dir.c */
   3.845 -@@ -88,3 +91,9 @@
   3.846 - 
   3.847 - /* symlink.c */
   3.848 - extern const struct address_space_operations squashfs_symlink_aops;
   3.849 -+
   3.850 -+/* zlib_wrapper.c */
   3.851 -+extern const struct squashfs_decompressor squashfs_zlib_comp_ops;
   3.852 + /* zlib_wrapper.c */
   3.853 + extern const struct squashfs_decompressor squashfs_zlib_comp_ops;
   3.854  +
   3.855  +/* lzma wrapper.c */
   3.856  +extern const struct squashfs_decompressor squashfs_lzma_comp_ops;
   3.857  
   3.858 ---- linux-2.6.30.6/fs/squashfs/squashfs_fs.h
   3.859 -+++ linux-2.6.30.6/fs/squashfs/squashfs_fs.h
   3.860 -@@ -211,7 +211,9 @@
   3.861 - /*
   3.862 -  * definitions for structures on disk
   3.863 -  */
   3.864 --#define ZLIB_COMPRESSION	 1
   3.865 -+#define ZLIB_COMPRESSION	1
   3.866 -+#define LZMA_COMPRESSION	2
   3.867 -+#define LZO_COMPRESSION		3
   3.868 - 
   3.869 - struct squashfs_super_block {
   3.870 - 	__le32			s_magic;
   3.871 -
   3.872 ---- linux-2.6.30.6/fs/squashfs/squashfs_fs_sb.h
   3.873 -+++ linux-2.6.30.6/fs/squashfs/squashfs_fs_sb.h
   3.874 -@@ -52,25 +52,26 @@
   3.875 - };
   3.876 - 
   3.877 - struct squashfs_sb_info {
   3.878 --	int			devblksize;
   3.879 --	int			devblksize_log2;
   3.880 --	struct squashfs_cache	*block_cache;
   3.881 --	struct squashfs_cache	*fragment_cache;
   3.882 --	struct squashfs_cache	*read_page;
   3.883 --	int			next_meta_index;
   3.884 --	__le64			*id_table;
   3.885 --	__le64			*fragment_index;
   3.886 --	unsigned int		*fragment_index_2;
   3.887 --	struct mutex		read_data_mutex;
   3.888 --	struct mutex		meta_index_mutex;
   3.889 --	struct meta_index	*meta_index;
   3.890 --	z_stream		stream;
   3.891 --	__le64			*inode_lookup_table;
   3.892 --	u64			inode_table;
   3.893 --	u64			directory_table;
   3.894 --	unsigned int		block_size;
   3.895 --	unsigned short		block_log;
   3.896 --	long long		bytes_used;
   3.897 --	unsigned int		inodes;
   3.898 -+	const struct squashfs_decompressor	*decompressor;
   3.899 -+	int					devblksize;
   3.900 -+	int					devblksize_log2;
   3.901 -+	struct squashfs_cache			*block_cache;
   3.902 -+	struct squashfs_cache			*fragment_cache;
   3.903 -+	struct squashfs_cache			*read_page;
   3.904 -+	int					next_meta_index;
   3.905 -+	__le64					*id_table;
   3.906 -+	__le64					*fragment_index;
   3.907 -+	unsigned int				*fragment_index_2;
   3.908 -+	struct mutex				read_data_mutex;
   3.909 -+	struct mutex				meta_index_mutex;
   3.910 -+	struct meta_index			*meta_index;
   3.911 -+	void					*stream;
   3.912 -+	__le64					*inode_lookup_table;
   3.913 -+	u64					inode_table;
   3.914 -+	u64					directory_table;
   3.915 -+	unsigned int				block_size;
   3.916 -+	unsigned short				block_log;
   3.917 -+	long long				bytes_used;
   3.918 -+	unsigned int				inodes;
   3.919 - };
   3.920 - #endif
   3.921 -
   3.922 ---- linux-2.6.30.6/fs/squashfs/super.c
   3.923 -+++ linux-2.6.30.6/fs/squashfs/super.c
   3.924 -@@ -30,38 +30,46 @@
   3.925 - #include <linux/fs.h>
   3.926 - #include <linux/vfs.h>
   3.927 - #include <linux/slab.h>
   3.928 -+#include <linux/smp_lock.h>
   3.929 - #include <linux/mutex.h>
   3.930 - #include <linux/pagemap.h>
   3.931 - #include <linux/init.h>
   3.932 - #include <linux/module.h>
   3.933 --#include <linux/zlib.h>
   3.934 - #include <linux/magic.h>
   3.935 - 
   3.936 - #include "squashfs_fs.h"
   3.937 - #include "squashfs_fs_sb.h"
   3.938 - #include "squashfs_fs_i.h"
   3.939 - #include "squashfs.h"
   3.940 -+#include "decompressor.h"
   3.941 - 
   3.942 - static struct file_system_type squashfs_fs_type;
   3.943 --static struct super_operations squashfs_super_ops;
   3.944 -+static const struct super_operations squashfs_super_ops;
   3.945 - 
   3.946 --static int supported_squashfs_filesystem(short major, short minor, short comp)
   3.947 -+static const struct squashfs_decompressor *supported_squashfs_filesystem(short
   3.948 -+	major, short minor, short id)
   3.949 - {
   3.950 -+	const struct squashfs_decompressor *decompressor;
   3.951 -+
   3.952 - 	if (major < SQUASHFS_MAJOR) {
   3.953 - 		ERROR("Major/Minor mismatch, older Squashfs %d.%d "
   3.954 - 			"filesystems are unsupported\n", major, minor);
   3.955 --		return -EINVAL;
   3.956 -+		return NULL;
   3.957 - 	} else if (major > SQUASHFS_MAJOR || minor > SQUASHFS_MINOR) {
   3.958 - 		ERROR("Major/Minor mismatch, trying to mount newer "
   3.959 - 			"%d.%d filesystem\n", major, minor);
   3.960 - 		ERROR("Please update your kernel\n");
   3.961 --		return -EINVAL;
   3.962 -+		return NULL;
   3.963 - 	}
   3.964 - 
   3.965 --	if (comp != ZLIB_COMPRESSION)
   3.966 --		return -EINVAL;
   3.967 -+	decompressor = squashfs_lookup_decompressor(id);
   3.968 -+	if (!decompressor->supported) {
   3.969 -+		ERROR("Filesystem uses \"%s\" compression. This is not "
   3.970 -+			"supported\n", decompressor->name);
   3.971 -+		return NULL;
   3.972 -+	}
   3.973 - 
   3.974 --	return 0;
   3.975 -+	return decompressor;
   3.976 - }
   3.977 - 
   3.978 - 
   3.979 -@@ -86,13 +94,6 @@
   3.980 - 	}
   3.981 - 	msblk = sb->s_fs_info;
   3.982 - 
   3.983 --	msblk->stream.workspace = kmalloc(zlib_inflate_workspacesize(),
   3.984 --		GFP_KERNEL);
   3.985 --	if (msblk->stream.workspace == NULL) {
   3.986 --		ERROR("Failed to allocate zlib workspace\n");
   3.987 --		goto failure;
   3.988 --	}
   3.989 --
   3.990 - 	sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
   3.991 - 	if (sblk == NULL) {
   3.992 - 		ERROR("Failed to allocate squashfs_super_block\n");
   3.993 -@@ -119,25 +120,25 @@
   3.994 - 		goto failed_mount;
   3.995 - 	}
   3.996 - 
   3.997 -+	err = -EINVAL;
   3.998 -+
   3.999 - 	/* Check it is a SQUASHFS superblock */
  3.1000 - 	sb->s_magic = le32_to_cpu(sblk->s_magic);
  3.1001 - 	if (sb->s_magic != SQUASHFS_MAGIC) {
  3.1002 - 		if (!silent)
  3.1003 - 			ERROR("Can't find a SQUASHFS superblock on %s\n",
  3.1004 - 						bdevname(sb->s_bdev, b));
  3.1005 --		err = -EINVAL;
  3.1006 - 		goto failed_mount;
  3.1007 - 	}
  3.1008 - 
  3.1009 --	/* Check the MAJOR & MINOR versions and compression type */
  3.1010 --	err = supported_squashfs_filesystem(le16_to_cpu(sblk->s_major),
  3.1011 -+	/* Check the MAJOR & MINOR versions and lookup compression type */
  3.1012 -+	msblk->decompressor = supported_squashfs_filesystem(
  3.1013 -+			le16_to_cpu(sblk->s_major),
  3.1014 - 			le16_to_cpu(sblk->s_minor),
  3.1015 - 			le16_to_cpu(sblk->compression));
  3.1016 --	if (err < 0)
  3.1017 -+	if (msblk->decompressor == NULL)
  3.1018 - 		goto failed_mount;
  3.1019 - 
  3.1020 --	err = -EINVAL;
  3.1021 --
  3.1022 - 	/*
  3.1023 - 	 * Check if there's xattrs in the filesystem.  These are not
  3.1024 - 	 * supported in this version, so warn that they will be ignored.
  3.1025 -@@ -204,6 +205,10 @@
  3.1026 - 
  3.1027 - 	err = -ENOMEM;
  3.1028 - 
  3.1029 -+	msblk->stream = squashfs_decompressor_init(msblk);
  3.1030 -+	if (msblk->stream == NULL)
  3.1031 -+		goto failed_mount;
  3.1032 -+
  3.1033 - 	msblk->block_cache = squashfs_cache_init("metadata",
  3.1034 - 			SQUASHFS_CACHED_BLKS, SQUASHFS_METADATA_SIZE);
  3.1035 - 	if (msblk->block_cache == NULL)
  3.1036 -@@ -291,17 +296,16 @@
  3.1037 - 	squashfs_cache_delete(msblk->block_cache);
  3.1038 - 	squashfs_cache_delete(msblk->fragment_cache);
  3.1039 - 	squashfs_cache_delete(msblk->read_page);
  3.1040 -+	squashfs_decompressor_free(msblk, msblk->stream);
  3.1041 - 	kfree(msblk->inode_lookup_table);
  3.1042 - 	kfree(msblk->fragment_index);
  3.1043 - 	kfree(msblk->id_table);
  3.1044 --	kfree(msblk->stream.workspace);
  3.1045 - 	kfree(sb->s_fs_info);
  3.1046 - 	sb->s_fs_info = NULL;
  3.1047 - 	kfree(sblk);
  3.1048 - 	return err;
  3.1049 - 
  3.1050 - failure:
  3.1051 --	kfree(msblk->stream.workspace);
  3.1052 - 	kfree(sb->s_fs_info);
  3.1053 - 	sb->s_fs_info = NULL;
  3.1054 - 	return -ENOMEM;
  3.1055 -@@ -338,18 +342,22 @@
  3.1056 - 
  3.1057 - static void squashfs_put_super(struct super_block *sb)
  3.1058 - {
  3.1059 -+	lock_kernel();
  3.1060 -+
  3.1061 - 	if (sb->s_fs_info) {
  3.1062 - 		struct squashfs_sb_info *sbi = sb->s_fs_info;
  3.1063 - 		squashfs_cache_delete(sbi->block_cache);
  3.1064 - 		squashfs_cache_delete(sbi->fragment_cache);
  3.1065 - 		squashfs_cache_delete(sbi->read_page);
  3.1066 -+		squashfs_decompressor_free(sbi, sbi->stream);
  3.1067 - 		kfree(sbi->id_table);
  3.1068 - 		kfree(sbi->fragment_index);
  3.1069 - 		kfree(sbi->meta_index);
  3.1070 --		kfree(sbi->stream.workspace);
  3.1071 - 		kfree(sb->s_fs_info);
  3.1072 - 		sb->s_fs_info = NULL;
  3.1073 - 	}
  3.1074 -+
  3.1075 -+	unlock_kernel();
  3.1076 - }
  3.1077 - 
  3.1078 - 
  3.1079 -@@ -439,7 +447,7 @@
  3.1080 - 	.fs_flags = FS_REQUIRES_DEV
  3.1081 - };
  3.1082 - 
  3.1083 --static struct super_operations squashfs_super_ops = {
  3.1084 -+static const struct super_operations squashfs_super_ops = {
  3.1085 - 	.alloc_inode = squashfs_alloc_inode,
  3.1086 - 	.destroy_inode = squashfs_destroy_inode,
  3.1087 - 	.statfs = squashfs_statfs,
  3.1088 -
  3.1089 ---- linux-2.6.30.6/fs/squashfs/symlink.c
  3.1090 -+++ linux-2.6.30.6/fs/squashfs/symlink.c
  3.1091 -@@ -36,7 +36,6 @@
  3.1092 - #include <linux/slab.h>
  3.1093 - #include <linux/string.h>
  3.1094 - #include <linux/pagemap.h>
  3.1095 --#include <linux/zlib.h>
  3.1096 - 
  3.1097 - #include "squashfs_fs.h"
  3.1098 - #include "squashfs_fs_sb.h"
  3.1099 -
  3.1100 ---- linux-2.6.30.6/fs/squashfs/zlib_wrapper.c
  3.1101 -+++ linux-2.6.30.6/fs/squashfs/zlib_wrapper.c
  3.1102 -@@ -0,0 +1,150 @@
  3.1103 -+/*
  3.1104 -+ * Squashfs - a compressed read only filesystem for Linux
  3.1105 -+ *
  3.1106 -+ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
  3.1107 -+ * Phillip Lougher <phillip@lougher.demon.co.uk>
  3.1108 -+ *
  3.1109 -+ * This program is free software; you can redistribute it and/or
  3.1110 -+ * modify it under the terms of the GNU General Public License
  3.1111 -+ * as published by the Free Software Foundation; either version 2,
  3.1112 -+ * or (at your option) any later version.
  3.1113 -+ *
  3.1114 -+ * This program is distributed in the hope that it will be useful,
  3.1115 -+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
  3.1116 -+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  3.1117 -+ * GNU General Public License for more details.
  3.1118 -+ *
  3.1119 -+ * You should have received a copy of the GNU General Public License
  3.1120 -+ * along with this program; if not, write to the Free Software
  3.1121 -+ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  3.1122 -+ *
  3.1123 -+ * zlib_wrapper.c
  3.1124 -+ */
  3.1125 -+
  3.1126 -+
  3.1127 -+#include <linux/mutex.h>
  3.1128 -+#include <linux/buffer_head.h>
  3.1129 -+#include <linux/zlib.h>
  3.1130 -+
  3.1131 -+#include "squashfs_fs.h"
  3.1132 -+#include "squashfs_fs_sb.h"
  3.1133 -+#include "squashfs_fs_i.h"
  3.1134 -+#include "squashfs.h"
  3.1135 -+#include "decompressor.h"
  3.1136 -+
  3.1137 -+static void *zlib_init(struct squashfs_sb_info *dummy)
  3.1138 -+{
  3.1139 -+	z_stream *stream = kmalloc(sizeof(z_stream), GFP_KERNEL);
  3.1140 -+	if (stream == NULL)
  3.1141 -+		goto failed;
  3.1142 -+	stream->workspace = kmalloc(zlib_inflate_workspacesize(),
  3.1143 -+		GFP_KERNEL);
  3.1144 -+	if (stream->workspace == NULL)
  3.1145 -+		goto failed;
  3.1146 -+
  3.1147 -+	return stream;
  3.1148 -+
  3.1149 -+failed:
  3.1150 -+	ERROR("Failed to allocate zlib workspace\n");
  3.1151 -+	kfree(stream);
  3.1152 -+	return NULL;
  3.1153 -+}
  3.1154 -+
  3.1155 -+
  3.1156 -+static void zlib_free(void *strm)
  3.1157 -+{
  3.1158 -+	z_stream *stream = strm;
  3.1159 -+
  3.1160 -+	if (stream)
  3.1161 -+		kfree(stream->workspace);
  3.1162 -+	kfree(stream);
  3.1163 -+}
  3.1164 -+
  3.1165 -+
  3.1166 -+static int zlib_uncompress(struct squashfs_sb_info *msblk, void **buffer,
  3.1167 -+	struct buffer_head **bh, int b, int offset, int length, int srclength,
  3.1168 -+	int pages)
  3.1169 -+{
  3.1170 -+	int zlib_err = 0, zlib_init = 0;
  3.1171 -+	int avail, bytes, k = 0, page = 0;
  3.1172 -+	z_stream *stream = msblk->stream;
  3.1173 -+
  3.1174 -+	mutex_lock(&msblk->read_data_mutex);
  3.1175 -+
  3.1176 -+	stream->avail_out = 0;
  3.1177 -+	stream->avail_in = 0;
  3.1178 -+
  3.1179 -+	bytes = length;
  3.1180 -+	do {
  3.1181 -+		if (stream->avail_in == 0 && k < b) {
  3.1182 -+			avail = min(bytes, msblk->devblksize - offset);
  3.1183 -+			bytes -= avail;
  3.1184 -+			wait_on_buffer(bh[k]);
  3.1185 -+			if (!buffer_uptodate(bh[k]))
  3.1186 -+				goto release_mutex;
  3.1187 -+
  3.1188 -+			if (avail == 0) {
  3.1189 -+				offset = 0;
  3.1190 -+				put_bh(bh[k++]);
  3.1191 -+				continue;
  3.1192 -+			}
  3.1193 -+
  3.1194 -+			stream->next_in = bh[k]->b_data + offset;
  3.1195 -+			stream->avail_in = avail;
  3.1196 -+			offset = 0;
  3.1197 -+		}
  3.1198 -+
  3.1199 -+		if (stream->avail_out == 0 && page < pages) {
  3.1200 -+			stream->next_out = buffer[page++];
  3.1201 -+			stream->avail_out = PAGE_CACHE_SIZE;
  3.1202 -+		}
  3.1203 -+
  3.1204 -+		if (!zlib_init) {
  3.1205 -+			zlib_err = zlib_inflateInit(stream);
  3.1206 -+			if (zlib_err != Z_OK) {
  3.1207 -+				ERROR("zlib_inflateInit returned unexpected "
  3.1208 -+					"result 0x%x, srclength %d\n",
  3.1209 -+					zlib_err, srclength);
  3.1210 -+				goto release_mutex;
  3.1211 -+			}
  3.1212 -+			zlib_init = 1;
  3.1213 -+		}
  3.1214 -+
  3.1215 -+		zlib_err = zlib_inflate(stream, Z_SYNC_FLUSH);
  3.1216 -+
  3.1217 -+		if (stream->avail_in == 0 && k < b)
  3.1218 -+			put_bh(bh[k++]);
  3.1219 -+	} while (zlib_err == Z_OK);
  3.1220 -+
  3.1221 -+	if (zlib_err != Z_STREAM_END) {
  3.1222 -+		ERROR("zlib_inflate error, data probably corrupt\n");
  3.1223 -+		goto release_mutex;
  3.1224 -+	}
  3.1225 -+
  3.1226 -+	zlib_err = zlib_inflateEnd(stream);
  3.1227 -+	if (zlib_err != Z_OK) {
  3.1228 -+		ERROR("zlib_inflate error, data probably corrupt\n");
  3.1229 -+		goto release_mutex;
  3.1230 -+	}
  3.1231 -+
  3.1232 -+	mutex_unlock(&msblk->read_data_mutex);
  3.1233 -+	return stream->total_out;
  3.1234 -+
  3.1235 -+release_mutex:
  3.1236 -+	mutex_unlock(&msblk->read_data_mutex);
  3.1237 -+
  3.1238 -+	for (; k < b; k++)
  3.1239 -+		put_bh(bh[k]);
  3.1240 -+
  3.1241 -+	return -EIO;
  3.1242 -+}
  3.1243 -+
  3.1244 -+const struct squashfs_decompressor squashfs_zlib_comp_ops = {
  3.1245 -+	.init = zlib_init,
  3.1246 -+	.free = zlib_free,
  3.1247 -+	.decompress = zlib_uncompress,
  3.1248 -+	.id = ZLIB_COMPRESSION,
  3.1249 -+	.name = "zlib",
  3.1250 -+	.supported = 1
  3.1251 -+};
  3.1252 -+
  3.1253 -
  3.1254 ---- linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h
  3.1255 -+++ linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h
  3.1256 -@@ -0,0 +1,13 @@
  3.1257 -+#ifndef BUNZIP2_MM_H
  3.1258 -+#define BUNZIP2_MM_H
  3.1259 -+
  3.1260 -+#ifdef STATIC
  3.1261 -+/* Code active when included from pre-boot environment: */
  3.1262 -+#define INIT
  3.1263 -+#else
  3.1264 -+/* Compile for initramfs/initrd code only */
  3.1265 -+#define INIT __init
  3.1266 -+static void(*error)(char *m);
  3.1267 -+#endif
  3.1268 -+
  3.1269 -+#endif
  3.1270 -
  3.1271 ---- linux-2.6.30.6/include/linux/decompress/inflate_mm.h
  3.1272 -+++ linux-2.6.30.6/include/linux/decompress/inflate_mm.h
  3.1273 -@@ -0,0 +1,13 @@
  3.1274 -+#ifndef INFLATE_MM_H
  3.1275 -+#define INFLATE_MM_H
  3.1276 -+
  3.1277 -+#ifdef STATIC
  3.1278 -+/* Code active when included from pre-boot environment: */
  3.1279 -+#define INIT
  3.1280 -+#else
  3.1281 -+/* Compile for initramfs/initrd code only */
  3.1282 -+#define INIT __init
  3.1283 -+static void(*error)(char *m);
  3.1284 -+#endif
  3.1285 -+
  3.1286 -+#endif
  3.1287 -
  3.1288 ---- linux-2.6.30.6/include/linux/decompress/mm.h
  3.1289 -+++ linux-2.6.30.6/include/linux/decompress/mm.h
  3.1290 -@@ -25,7 +25,7 @@
  3.1291 - 	void *p;
  3.1292 - 
  3.1293 - 	if (size < 0)
  3.1294 --		error("Malloc error");
  3.1295 -+		return NULL;
  3.1296 - 	if (!malloc_ptr)
  3.1297 - 		malloc_ptr = free_mem_ptr;
  3.1298 - 
  3.1299 -@@ -35,7 +35,7 @@
  3.1300 - 	malloc_ptr += size;
  3.1301 - 
  3.1302 - 	if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
  3.1303 --		error("Out of memory");
  3.1304 -+		return NULL;
  3.1305 - 
  3.1306 - 	malloc_count++;
  3.1307 - 	return p;
  3.1308 -@@ -53,8 +53,6 @@
  3.1309 - 
  3.1310 - #define set_error_fn(x)
  3.1311 - 
  3.1312 --#define INIT
  3.1313 --
  3.1314 - #else /* STATIC */
  3.1315 - 
  3.1316 - /* Code active when compiled standalone for use when loading ramdisk: */
  3.1317 -@@ -74,10 +72,8 @@
  3.1318 - #define large_malloc(a) vmalloc(a)
  3.1319 - #define large_free(a) vfree(a)
  3.1320 - 
  3.1321 --static void(*error)(char *m);
  3.1322 - #define set_error_fn(x) error = x;
  3.1323 - 
  3.1324 --#define INIT __init
  3.1325 - #define STATIC
  3.1326 - 
  3.1327 - #include <linux/init.h>
  3.1328 -
  3.1329 ---- linux-2.6.30.6/include/linux/decompress/unlzma_mm.h
  3.1330 -+++ linux-2.6.30.6/include/linux/decompress/unlzma_mm.h
  3.1331 -@@ -0,0 +1,20 @@
  3.1332 -+#ifndef UNLZMA_MM_H
  3.1333 -+#define UNLZMA_MM_H
  3.1334 -+
  3.1335 -+#ifdef STATIC
  3.1336 -+
  3.1337 -+/* Code active when included from pre-boot environment: */
  3.1338 -+#define INIT
  3.1339 -+
  3.1340 -+#elif defined(CONFIG_DECOMPRESS_LZMA_NEEDED)
  3.1341 -+
  3.1342 -+/* Make it available to non initramfs/initrd code */
  3.1343 -+#define INIT
  3.1344 -+#include <linux/module.h>
  3.1345 -+#else
  3.1346 -+
  3.1347 -+/* Compile for initramfs/initrd code only */
  3.1348 -+#define INIT __init
  3.1349 -+#endif
  3.1350 -+
  3.1351 -+#endif
  3.1352 -
  3.1353 ---- linux-2.6.30.6/lib/Kconfig
  3.1354 -+++ linux-2.6.30.6/lib/Kconfig
  3.1355 -@@ -10,6 +10,9 @@
  3.1356 - config BITREVERSE
  3.1357 - 	tristate
  3.1358 - 
  3.1359 -+config RATIONAL
  3.1360 -+	boolean
  3.1361 -+
  3.1362 - config GENERIC_FIND_FIRST_BIT
  3.1363 - 	bool
  3.1364 - 
  3.1365 -@@ -114,6 +117,9 @@
  3.1366 - config DECOMPRESS_LZMA
  3.1367 - 	tristate
  3.1368 - 
  3.1369 -+config DECOMPRESS_LZMA_NEEDED
  3.1370 -+	 boolean
  3.1371 -+
  3.1372 - #
  3.1373 - # Generic allocator support is selected if needed
  3.1374 - #
  3.1375 -@@ -153,6 +159,9 @@
  3.1376 - config TEXTSEARCH_FSM
  3.1377 - 	tristate
  3.1378 - 
  3.1379 -+config BTREE
  3.1380 -+	boolean
  3.1381 -+
  3.1382 - config HAS_IOMEM
  3.1383 - 	boolean
  3.1384 - 	depends on !NO_IOMEM
  3.1385 -@@ -190,5 +199,35 @@
  3.1386 - #
  3.1387 - config NLATTR
  3.1388 - 	bool
  3.1389 -+
  3.1390 -+#
  3.1391 -+# Generic 64-bit atomic support is selected if needed
  3.1392 -+#
  3.1393 -+config GENERIC_ATOMIC64
  3.1394 -+       bool
  3.1395 -+
  3.1396 -+config LRU_CACHE
  3.1397 -+	tristate
  3.1398 -+
  3.1399 -+config SHM_SIGNAL
  3.1400 -+	tristate "SHM Signal - Generic shared-memory signaling mechanism"
  3.1401 -+	default n
  3.1402 -+	help
  3.1403 -+	 Provides a shared-memory based signaling mechanism to indicate
  3.1404 -+         memory-dirty notifications between two end-points.
  3.1405 -+
  3.1406 -+	 If unsure, say N
  3.1407 -+
  3.1408 -+config IOQ
  3.1409 -+	tristate "IO-Queue library - Generic shared-memory queue"
  3.1410 -+	select SHM_SIGNAL
  3.1411 -+	default n
  3.1412 -+	help
  3.1413 -+	 IOQ is a generic shared-memory-queue mechanism that happens to be
  3.1414 -+	 friendly to virtualization boundaries. It can be used in a variety
  3.1415 -+	 of ways, though its intended purpose is to become a low-level
  3.1416 -+	 communication path for paravirtualized drivers.
  3.1417 -+
  3.1418 -+	 If unsure, say N
  3.1419 - 
  3.1420 - endmenu
  3.1421 -
  3.1422 ---- linux-2.6.30.6/lib/decompress_bunzip2.c
  3.1423 -+++ linux-2.6.30.6/lib/decompress_bunzip2.c
  3.1424 -@@ -45,12 +45,15 @@
  3.1425 - */
  3.1426 - 
  3.1427 - 
  3.1428 --#ifndef STATIC
  3.1429 -+#ifdef STATIC
  3.1430 -+#define PREBOOT
  3.1431 -+#else
  3.1432 - #include <linux/decompress/bunzip2.h>
  3.1433 --#endif /* !STATIC */
  3.1434 -+#include <linux/slab.h>
  3.1435 -+#endif /* STATIC */
  3.1436 - 
  3.1437 -+#include <linux/decompress/bunzip2_mm.h>
  3.1438 - #include <linux/decompress/mm.h>
  3.1439 --#include <linux/slab.h>
  3.1440 - 
  3.1441 - #ifndef INT_MAX
  3.1442 - #define INT_MAX 0x7fffffff
  3.1443 -@@ -297,7 +300,7 @@
  3.1444 - 		   again when using them (during symbol decoding).*/
  3.1445 - 		base = hufGroup->base-1;
  3.1446 - 		limit = hufGroup->limit-1;
  3.1447 --		/* Calculate permute[].  Concurently, initialize
  3.1448 -+		/* Calculate permute[].  Concurrently, initialize
  3.1449 - 		 * temp[] and limit[]. */
  3.1450 - 		pp = 0;
  3.1451 - 		for (i = minLen; i <= maxLen; i++) {
  3.1452 -@@ -635,6 +638,8 @@
  3.1453 - 
  3.1454 - 	/* Allocate bunzip_data.  Most fields initialize to zero. */
  3.1455 - 	bd = *bdp = malloc(i);
  3.1456 -+	if (!bd)
  3.1457 -+		return RETVAL_OUT_OF_MEMORY;
  3.1458 - 	memset(bd, 0, sizeof(struct bunzip_data));
  3.1459 - 	/* Setup input buffer */
  3.1460 - 	bd->inbuf = inbuf;
  3.1461 -@@ -662,6 +667,8 @@
  3.1462 - 	bd->dbufSize = 100000*(i-BZh0);
  3.1463 - 
  3.1464 - 	bd->dbuf = large_malloc(bd->dbufSize * sizeof(int));
  3.1465 -+	if (!bd->dbuf)
  3.1466 -+		return RETVAL_OUT_OF_MEMORY;
  3.1467 - 	return RETVAL_OK;
  3.1468 - }
  3.1469 - 
  3.1470 -@@ -681,12 +688,10 @@
  3.1471 - 	set_error_fn(error_fn);
  3.1472 - 	if (flush)
  3.1473 - 		outbuf = malloc(BZIP2_IOBUF_SIZE);
  3.1474 --	else
  3.1475 --		len -= 4; /* Uncompressed size hack active in pre-boot
  3.1476 --			     environment */
  3.1477 -+
  3.1478 - 	if (!outbuf) {
  3.1479 - 		error("Could not allocate output bufer");
  3.1480 --		return -1;
  3.1481 -+		return RETVAL_OUT_OF_MEMORY;
  3.1482 - 	}
  3.1483 - 	if (buf)
  3.1484 - 		inbuf = buf;
  3.1485 -@@ -694,6 +699,7 @@
  3.1486 - 		inbuf = malloc(BZIP2_IOBUF_SIZE);
  3.1487 - 	if (!inbuf) {
  3.1488 - 		error("Could not allocate input bufer");
  3.1489 -+		i = RETVAL_OUT_OF_MEMORY;
  3.1490 - 		goto exit_0;
  3.1491 - 	}
  3.1492 - 	i = start_bunzip(&bd, inbuf, len, fill);
  3.1493 -@@ -720,11 +726,14 @@
  3.1494 - 	} else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) {
  3.1495 - 		error("Compressed file ends unexpectedly");
  3.1496 - 	}
  3.1497 -+	if (!bd)
  3.1498 -+		goto exit_1;
  3.1499 - 	if (bd->dbuf)
  3.1500 - 		large_free(bd->dbuf);
  3.1501 - 	if (pos)
  3.1502 - 		*pos = bd->inbufPos;
  3.1503 - 	free(bd);
  3.1504 -+exit_1:
  3.1505 - 	if (!buf)
  3.1506 - 		free(inbuf);
  3.1507 - exit_0:
  3.1508 -@@ -733,4 +742,14 @@
  3.1509 - 	return i;
  3.1510 - }
  3.1511 - 
  3.1512 --#define decompress bunzip2
  3.1513 -+#ifdef PREBOOT
  3.1514 -+STATIC int INIT decompress(unsigned char *buf, int len,
  3.1515 -+			int(*fill)(void*, unsigned int),
  3.1516 -+			int(*flush)(void*, unsigned int),
  3.1517 -+			unsigned char *outbuf,
  3.1518 -+			int *pos,
  3.1519 -+			void(*error_fn)(char *x))
  3.1520 -+{
  3.1521 -+	return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error_fn);
  3.1522 -+}
  3.1523 -+#endif
  3.1524 -
  3.1525 ---- linux-2.6.30.6/lib/decompress_inflate.c
  3.1526 -+++ linux-2.6.30.6/lib/decompress_inflate.c
  3.1527 -@@ -19,14 +19,20 @@
  3.1528 - #include "zlib_inflate/inflate.h"
  3.1529 - 
  3.1530 - #include "zlib_inflate/infutil.h"
  3.1531 -+#include <linux/slab.h>
  3.1532 - 
  3.1533 - #endif /* STATIC */
  3.1534 - 
  3.1535 -+#include <linux/decompress/inflate_mm.h>
  3.1536 - #include <linux/decompress/mm.h>
  3.1537 --#include <linux/slab.h>
  3.1538 - 
  3.1539 --#define INBUF_LEN (16*1024)
  3.1540 -+#define GZIP_IOBUF_SIZE (16*1024)
  3.1541 - 
  3.1542 -+static int nofill(void *buffer, unsigned int len)
  3.1543 -+{
  3.1544 -+	return -1;
  3.1545 -+}
  3.1546 -+
  3.1547 - /* Included from initramfs et al code */
  3.1548 - STATIC int INIT gunzip(unsigned char *buf, int len,
  3.1549 - 		       int(*fill)(void*, unsigned int),
  3.1550 -@@ -55,7 +61,7 @@
  3.1551 - 	if (buf)
  3.1552 - 		zbuf = buf;
  3.1553 - 	else {
  3.1554 --		zbuf = malloc(INBUF_LEN);
  3.1555 -+		zbuf = malloc(GZIP_IOBUF_SIZE);
  3.1556 - 		len = 0;
  3.1557 - 	}
  3.1558 - 	if (!zbuf) {
  3.1559 -@@ -76,8 +82,11 @@
  3.1560 - 		goto gunzip_nomem4;
  3.1561 - 	}
  3.1562 - 
  3.1563 -+	if (!fill)
  3.1564 -+		fill = nofill;
  3.1565 -+
  3.1566 - 	if (len == 0)
  3.1567 --		len = fill(zbuf, INBUF_LEN);
  3.1568 -+		len = fill(zbuf, GZIP_IOBUF_SIZE);
  3.1569 - 
  3.1570 - 	/* verify the gzip header */
  3.1571 - 	if (len < 10 ||
  3.1572 -@@ -113,7 +122,7 @@
  3.1573 - 	while (rc == Z_OK) {
  3.1574 - 		if (strm->avail_in == 0) {
  3.1575 - 			/* TODO: handle case where both pos and fill are set */
  3.1576 --			len = fill(zbuf, INBUF_LEN);
  3.1577 -+			len = fill(zbuf, GZIP_IOBUF_SIZE);
  3.1578 - 			if (len < 0) {
  3.1579 - 				rc = -1;
  3.1580 - 				error("read error");
  3.1581 -
  3.1582 ---- linux-2.6.30.6/lib/decompress_unlzma.c
  3.1583 -+++ linux-2.6.30.6/lib/decompress_unlzma.c
  3.1584 -@@ -29,12 +29,15 @@
  3.1585 -  *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
  3.1586 -  */
  3.1587 - 
  3.1588 --#ifndef STATIC
  3.1589 -+#ifdef STATIC
  3.1590 -+#define PREBOOT
  3.1591 -+#else
  3.1592 - #include <linux/decompress/unlzma.h>
  3.1593 -+#include <linux/slab.h>
  3.1594 - #endif /* STATIC */
  3.1595 - 
  3.1596 -+#include <linux/decompress/unlzma_mm.h>
  3.1597 - #include <linux/decompress/mm.h>
  3.1598 --#include <linux/slab.h>
  3.1599 - 
  3.1600 - #define	MIN(a, b) (((a) < (b)) ? (a) : (b))
  3.1601 - 
  3.1602 -@@ -80,8 +83,13 @@
  3.1603 - #define RC_MODEL_TOTAL_BITS 11
  3.1604 - 
  3.1605 - 
  3.1606 -+static int nofill(void *buffer, unsigned int len)
  3.1607 -+{
  3.1608 -+	return -1;
  3.1609 -+}
  3.1610 -+
  3.1611 - /* Called twice: once at startup and once in rc_normalize() */
  3.1612 --static void INIT rc_read(struct rc *rc)
  3.1613 -+static void INIT rc_read(struct rc *rc, void(*error)(char *x))
  3.1614 - {
  3.1615 - 	rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE);
  3.1616 - 	if (rc->buffer_size <= 0)
  3.1617 -@@ -95,7 +103,10 @@
  3.1618 - 				       int (*fill)(void*, unsigned int),
  3.1619 - 				       char *buffer, int buffer_size)
  3.1620 - {
  3.1621 --	rc->fill = fill;
  3.1622 -+	if (fill)
  3.1623 -+		rc->fill = fill;
  3.1624 -+	else
  3.1625 -+		rc->fill = nofill;
  3.1626 - 	rc->buffer = (uint8_t *)buffer;
  3.1627 - 	rc->buffer_size = buffer_size;
  3.1628 - 	rc->buffer_end = rc->buffer + rc->buffer_size;
  3.1629 -@@ -105,13 +116,13 @@
  3.1630 - 	rc->range = 0xFFFFFFFF;
  3.1631 - }
  3.1632 - 
  3.1633 --static inline void INIT rc_init_code(struct rc *rc)
  3.1634 -+static inline void INIT rc_init_code(struct rc *rc, void(*error)(char *x))
  3.1635 - {
  3.1636 - 	int i;
  3.1637 - 
  3.1638 - 	for (i = 0; i < 5; i++) {
  3.1639 - 		if (rc->ptr >= rc->buffer_end)
  3.1640 --			rc_read(rc);
  3.1641 -+			rc_read(rc, error);
  3.1642 - 		rc->code = (rc->code << 8) | *rc->ptr++;
  3.1643 - 	}
  3.1644 - }
  3.1645 -@@ -124,32 +135,33 @@
  3.1646 - }
  3.1647 - 
  3.1648 - /* Called twice, but one callsite is in inline'd rc_is_bit_0_helper() */
  3.1649 --static void INIT rc_do_normalize(struct rc *rc)
  3.1650 -+static void INIT rc_do_normalize(struct rc *rc, void(*error)(char *x))
  3.1651 - {
  3.1652 - 	if (rc->ptr >= rc->buffer_end)
  3.1653 --		rc_read(rc);
  3.1654 -+		rc_read(rc, error);
  3.1655 - 	rc->range <<= 8;
  3.1656 - 	rc->code = (rc->code << 8) | *rc->ptr++;
  3.1657 - }
  3.1658 --static inline void INIT rc_normalize(struct rc *rc)
  3.1659 -+static inline void INIT rc_normalize(struct rc *rc, void(*error)(char *x))
  3.1660 - {
  3.1661 - 	if (rc->range < (1 << RC_TOP_BITS))
  3.1662 --		rc_do_normalize(rc);
  3.1663 -+		rc_do_normalize(rc, error);
  3.1664 - }
  3.1665 - 
  3.1666 - /* Called 9 times */
  3.1667 - /* Why rc_is_bit_0_helper exists?
  3.1668 -  *Because we want to always expose (rc->code < rc->bound) to optimizer
  3.1669 -  */
  3.1670 --static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p)
  3.1671 -+static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p,
  3.1672 -+					       void (*error)(char *x))
  3.1673 - {
  3.1674 --	rc_normalize(rc);
  3.1675 -+	rc_normalize(rc, error);
  3.1676 - 	rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
  3.1677 - 	return rc->bound;
  3.1678 - }
  3.1679 --static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p)
  3.1680 -+static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p, void(*error)(char *x))
  3.1681 - {
  3.1682 --	uint32_t t = rc_is_bit_0_helper(rc, p);
  3.1683 -+	uint32_t t = rc_is_bit_0_helper(rc, p, error);
  3.1684 - 	return rc->code < t;
  3.1685 - }
  3.1686 - 
  3.1687 -@@ -167,9 +179,9 @@
  3.1688 - }
  3.1689 - 
  3.1690 - /* Called 4 times in unlzma loop */
  3.1691 --static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol)
  3.1692 -+static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol, void(*error)(char *x))
  3.1693 - {
  3.1694 --	if (rc_is_bit_0(rc, p)) {
  3.1695 -+	if (rc_is_bit_0(rc, p, error)) {
  3.1696 - 		rc_update_bit_0(rc, p);
  3.1697 - 		*symbol *= 2;
  3.1698 - 		return 0;
  3.1699 -@@ -181,9 +193,9 @@
  3.1700 - }
  3.1701 - 
  3.1702 - /* Called once */
  3.1703 --static inline int INIT rc_direct_bit(struct rc *rc)
  3.1704 -+static inline int INIT rc_direct_bit(struct rc *rc , void(*error)(char *x))
  3.1705 - {
  3.1706 --	rc_normalize(rc);
  3.1707 -+	rc_normalize(rc, error);
  3.1708 - 	rc->range >>= 1;
  3.1709 - 	if (rc->code >= rc->range) {
  3.1710 - 		rc->code -= rc->range;
  3.1711 -@@ -194,13 +206,14 @@
  3.1712 - 
  3.1713 - /* Called twice */
  3.1714 - static inline void INIT
  3.1715 --rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol)
  3.1716 -+rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol,
  3.1717 -+							void(*error)(char *x))
  3.1718 - {
  3.1719 - 	int i = num_levels;
  3.1720 - 
  3.1721 - 	*symbol = 1;
  3.1722 - 	while (i--)
  3.1723 --		rc_get_bit(rc, p + *symbol, symbol);
  3.1724 -+		rc_get_bit(rc, p + *symbol, symbol, error);
  3.1725 - 	*symbol -= 1 << num_levels;
  3.1726 - }
  3.1727 - 
  3.1728 -@@ -396,7 +409,8 @@
  3.1729 - static inline void INIT process_bit0(struct writer *wr, struct rc *rc,
  3.1730 - 				     struct cstate *cst, uint16_t *p,
  3.1731 - 				     int pos_state, uint16_t *prob,
  3.1732 --				     int lc, uint32_t literal_pos_mask) {
  3.1733 -+				     int lc, uint32_t literal_pos_mask,
  3.1734 -+				     void(*error)(char *x)) {
  3.1735 - 	int mi = 1;
  3.1736 - 	static const int state[LZMA_NUM_STATES] = 
  3.1737 - 		{ 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
  3.1738 -@@ -417,7 +431,7 @@
  3.1739 - 			match_byte <<= 1;
  3.1740 - 			bit = match_byte & 0x100;
  3.1741 - 			prob_lit = prob + 0x100 + bit + mi;
  3.1742 --			if (rc_get_bit(rc, prob_lit, &mi)) {
  3.1743 -+			if (rc_get_bit(rc, prob_lit, &mi, error)) {
  3.1744 - 				if (!bit)
  3.1745 - 					break;
  3.1746 - 			} else {
  3.1747 -@@ -428,7 +442,7 @@
  3.1748 - 	}
  3.1749 - 	while (mi < 0x100) {
  3.1750 - 		uint16_t *prob_lit = prob + mi;
  3.1751 --		rc_get_bit(rc, prob_lit, &mi);
  3.1752 -+		rc_get_bit(rc, prob_lit, &mi, error);
  3.1753 - 	}
  3.1754 - 	write_byte(wr, mi);
  3.1755 - 	cst->state = state[cst->state];
  3.1756 -@@ -436,7 +450,8 @@
  3.1757 - 
  3.1758 - static inline void INIT process_bit1(struct writer *wr, struct rc *rc,
  3.1759 - 					    struct cstate *cst, uint16_t *p,
  3.1760 --					    int pos_state, uint16_t *prob) {
  3.1761 -+					    int pos_state, uint16_t *prob,
  3.1762 -+					    void(*error)(char *x)) {
  3.1763 - 	int offset;
  3.1764 - 	uint16_t *prob_len;
  3.1765 - 	int num_bits;
  3.1766 -@@ -444,7 +459,7 @@
  3.1767 - 
  3.1768 - 	rc_update_bit_1(rc, prob);
  3.1769 - 	prob = p + LZMA_IS_REP + cst->state;
  3.1770 --	if (rc_is_bit_0(rc, prob)) {
  3.1771 -+	if (rc_is_bit_0(rc, prob, error)) {
  3.1772 - 		rc_update_bit_0(rc, prob);
  3.1773 - 		cst->rep3 = cst->rep2;
  3.1774 - 		cst->rep2 = cst->rep1;
  3.1775 -@@ -454,13 +469,13 @@
  3.1776 - 	} else {
  3.1777 - 		rc_update_bit_1(rc, prob);
  3.1778 - 		prob += LZMA_IS_REP_G0 - LZMA_IS_REP;
  3.1779 --		if (rc_is_bit_0(rc, prob)) {
  3.1780 -+		if (rc_is_bit_0(rc, prob, error)) {
  3.1781 - 			rc_update_bit_0(rc, prob);
  3.1782 - 			prob = (p + LZMA_IS_REP_0_LONG
  3.1783 - 				+ (cst->state <<
  3.1784 - 				   LZMA_NUM_POS_BITS_MAX) +
  3.1785 - 				pos_state);
  3.1786 --			if (rc_is_bit_0(rc, prob)) {
  3.1787 -+			if (rc_is_bit_0(rc, prob, error)) {
  3.1788 - 				rc_update_bit_0(rc, prob);
  3.1789 - 
  3.1790 - 				cst->state = cst->state < LZMA_NUM_LIT_STATES ?
  3.1791 -@@ -475,13 +490,13 @@
  3.1792 - 
  3.1793 - 			rc_update_bit_1(rc, prob);
  3.1794 - 			prob += LZMA_IS_REP_G1 - LZMA_IS_REP_G0;
  3.1795 --			if (rc_is_bit_0(rc, prob)) {
  3.1796 -+			if (rc_is_bit_0(rc, prob, error)) {
  3.1797 - 				rc_update_bit_0(rc, prob);
  3.1798 - 				distance = cst->rep1;
  3.1799 - 			} else {
  3.1800 - 				rc_update_bit_1(rc, prob);
  3.1801 - 				prob += LZMA_IS_REP_G2 - LZMA_IS_REP_G1;
  3.1802 --				if (rc_is_bit_0(rc, prob)) {
  3.1803 -+				if (rc_is_bit_0(rc, prob, error)) {
  3.1804 - 					rc_update_bit_0(rc, prob);
  3.1805 - 					distance = cst->rep2;
  3.1806 - 				} else {
  3.1807 -@@ -499,7 +514,7 @@
  3.1808 - 	}
  3.1809 - 
  3.1810 - 	prob_len = prob + LZMA_LEN_CHOICE;
  3.1811 --	if (rc_is_bit_0(rc, prob_len)) {
  3.1812 -+	if (rc_is_bit_0(rc, prob_len, error)) {
  3.1813 - 		rc_update_bit_0(rc, prob_len);
  3.1814 - 		prob_len += LZMA_LEN_LOW - LZMA_LEN_CHOICE
  3.1815 - 			    + (pos_state <<
  3.1816 -@@ -509,7 +524,7 @@
  3.1817 - 	} else {
  3.1818 - 		rc_update_bit_1(rc, prob_len);
  3.1819 - 		prob_len += LZMA_LEN_CHOICE_2 - LZMA_LEN_CHOICE;
  3.1820 --		if (rc_is_bit_0(rc, prob_len)) {
  3.1821 -+		if (rc_is_bit_0(rc, prob_len, error)) {
  3.1822 - 			rc_update_bit_0(rc, prob_len);
  3.1823 - 			prob_len += LZMA_LEN_MID - LZMA_LEN_CHOICE_2
  3.1824 - 				    + (pos_state <<
  3.1825 -@@ -525,7 +540,7 @@
  3.1826 - 		}
  3.1827 - 	}
  3.1828 - 
  3.1829 --	rc_bit_tree_decode(rc, prob_len, num_bits, &len);
  3.1830 -+	rc_bit_tree_decode(rc, prob_len, num_bits, &len, error);
  3.1831 - 	len += offset;
  3.1832 - 
  3.1833 - 	if (cst->state < 4) {
  3.1834 -@@ -540,7 +555,7 @@
  3.1835 - 			 << LZMA_NUM_POS_SLOT_BITS);
  3.1836 - 		rc_bit_tree_decode(rc, prob,
  3.1837 - 				   LZMA_NUM_POS_SLOT_BITS,
  3.1838 --				   &pos_slot);
  3.1839 -+				   &pos_slot, error);
  3.1840 - 		if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
  3.1841 - 			int i, mi;
  3.1842 - 			num_bits = (pos_slot >> 1) - 1;
  3.1843 -@@ -553,7 +568,7 @@
  3.1844 - 				num_bits -= LZMA_NUM_ALIGN_BITS;
  3.1845 - 				while (num_bits--)
  3.1846 - 					cst->rep0 = (cst->rep0 << 1) |
  3.1847 --						rc_direct_bit(rc);
  3.1848 -+						rc_direct_bit(rc, error);
  3.1849 - 				prob = p + LZMA_ALIGN;
  3.1850 - 				cst->rep0 <<= LZMA_NUM_ALIGN_BITS;
  3.1851 - 				num_bits = LZMA_NUM_ALIGN_BITS;
  3.1852 -@@ -561,7 +576,7 @@
  3.1853 - 			i = 1;
  3.1854 - 			mi = 1;
  3.1855 - 			while (num_bits--) {
  3.1856 --				if (rc_get_bit(rc, prob + mi, &mi))
  3.1857 -+				if (rc_get_bit(rc, prob + mi, &mi, error))
  3.1858 - 					cst->rep0 |= i;
  3.1859 - 				i <<= 1;
  3.1860 - 			}
  3.1861 -@@ -578,12 +593,12 @@
  3.1862 - 
  3.1863 - 
  3.1864 - 
  3.1865 --STATIC inline int INIT unlzma(unsigned char *buf, int in_len,
  3.1866 -+STATIC int INIT unlzma(unsigned char *buf, int in_len,
  3.1867 - 			      int(*fill)(void*, unsigned int),
  3.1868 - 			      int(*flush)(void*, unsigned int),
  3.1869 - 			      unsigned char *output,
  3.1870 - 			      int *posp,
  3.1871 --			      void(*error_fn)(char *x)
  3.1872 -+			      void(*error)(char *x)
  3.1873 - 	)
  3.1874 - {
  3.1875 - 	extern int cpio_flush_buffer(void*, unsigned int);
  3.1876 -@@ -600,10 +615,6 @@
  3.1877 - 	unsigned char *inbuf;
  3.1878 - 	int ret = -1;
  3.1879 - 
  3.1880 --	set_error_fn(error_fn);
  3.1881 --	if (!flush)
  3.1882 --		in_len -= 4; /* Uncompressed size hack active in pre-boot
  3.1883 --				environment */
  3.1884 - 	if (buf)
  3.1885 - 		inbuf = buf;
  3.1886 - 	else
  3.1887 -@@ -630,7 +641,7 @@
  3.1888 - 
  3.1889 - 	for (i = 0; i < sizeof(header); i++) {
  3.1890 - 		if (rc.ptr >= rc.buffer_end)
  3.1891 --			rc_read(&rc);
  3.1892 -+			rc_read(&rc, error);
  3.1893 - 		((unsigned char *)&header)[i] = *rc.ptr++;
  3.1894 - 	}
  3.1895 - 
  3.1896 -@@ -675,17 +686,17 @@
  3.1897 - 	for (i = 0; i < num_probs; i++)
  3.1898 - 		p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
  3.1899 - 	wr.max_index = wr.next_index = 0;
  3.1900 --	rc_init_code(&rc);
  3.1901 -+	rc_init_code(&rc, error);
  3.1902 - 
  3.1903 - 	while (get_pos(&wr) < header.dst_size) {
  3.1904 - 		int pos_state =	get_pos(&wr) & pos_state_mask;
  3.1905 - 		uint16_t *prob = p + LZMA_IS_MATCH +
  3.1906 - 			(cst.state << LZMA_NUM_POS_BITS_MAX) + pos_state;
  3.1907 --		if (rc_is_bit_0(&rc, prob))
  3.1908 -+		if (rc_is_bit_0(&rc, prob, error))
  3.1909 - 			process_bit0(&wr, &rc, &cst, p, pos_state, prob,
  3.1910 --				     lc, literal_pos_mask);
  3.1911 -+				     lc, literal_pos_mask, error);
  3.1912 - 		else {
  3.1913 --			process_bit1(&wr, &rc, &cst, p, pos_state, prob);
  3.1914 -+			process_bit1(&wr, &rc, &cst, p, pos_state, prob, error);
  3.1915 - 			if (cst.rep0 == 0)
  3.1916 - 				break;
  3.1917 - 		}
  3.1918 -@@ -719,5 +730,19 @@
  3.1919 - exit_0:
  3.1920 - 	return ret;
  3.1921 - }
  3.1922 -+#if defined(CONFIG_DECOMPRESS_LZMA_NEEDED) && !defined(PREBOOT)
  3.1923 -+EXPORT_SYMBOL(unlzma);
  3.1924 -+#endif
  3.1925 - 
  3.1926 --#define decompress unlzma
  3.1927 -+#ifdef PREBOOT
  3.1928 -+STATIC int INIT decompress(unsigned char *buf, int in_len,
  3.1929 -+			      int(*fill)(void*, unsigned int),
  3.1930 -+			      int(*flush)(void*, unsigned int),
  3.1931 -+			      unsigned char *output,
  3.1932 -+			      int *posp,
  3.1933 -+			      void(*error_fn)(char *x)
  3.1934 -+	)
  3.1935 -+{
  3.1936 -+	return unlzma(buf, in_len - 4, fill, flush, output, posp, error_fn);
  3.1937 -+}
  3.1938 -+#endif