1 diff -Nur linux-2.6.12.5-brcm-squashfs/fs/squashfs/LzmaDecode.c linux-2.6.12.5-brcm-squashfs-lzma/fs/squashfs/LzmaDecode.c
2 --- linux-2.6.12.5-brcm-squashfs/fs/squashfs/LzmaDecode.c 1970-01-01 01:00:00.000000000 +0100
3 +++ linux-2.6.12.5-brcm-squashfs-lzma/fs/squashfs/LzmaDecode.c 2005-08-29 00:02:44.099124176 +0200
9 + LZMA SDK 4.05 Copyright (c) 1999-2004 Igor Pavlov (2004-08-25)
10 + http://www.7-zip.org/
12 + LZMA SDK is licensed under two licenses:
13 + 1) GNU Lesser General Public License (GNU LGPL)
14 + 2) Common Public License (CPL)
15 + It means that you can select one of these two licenses and
16 + follow rules of that license.
19 + Igor Pavlov, as the author of this code, expressly permits you to
20 + statically or dynamically link your code (or bind by name) to the
21 + interfaces of this file without subjecting your linked code to the
22 + terms of the CPL or GNU LGPL. Any modifications or additions
23 + to this file, however, are subject to the LGPL or CPL terms.
26 +#include "LzmaDecode.h"
29 +#define Byte unsigned char
32 +#define kNumTopBits 24
33 +#define kTopValue ((UInt32)1 << kNumTopBits)
35 +#define kNumBitModelTotalBits 11
36 +#define kBitModelTotal (1 << kNumBitModelTotalBits)
37 +#define kNumMoveBits 5
39 +typedef struct _CRangeDecoder
46 + ILzmaInCallback *InCallback;
52 +Byte RangeDecoderReadByte(CRangeDecoder *rd)
54 + if (rd->Buffer == rd->BufferLim)
58 + rd->Result = rd->InCallback->Read(rd->InCallback, &rd->Buffer, &size);
59 + rd->BufferLim = rd->Buffer + size;
67 + return (*rd->Buffer++);
70 +/* #define ReadByte (*rd->Buffer++) */
71 +#define ReadByte (RangeDecoderReadByte(rd))
73 +void RangeDecoderInit(CRangeDecoder *rd,
75 + ILzmaInCallback *inCallback
77 + Byte *stream, UInt32 bufferSize
83 + rd->InCallback = inCallback;
84 + rd->Buffer = rd->BufferLim = 0;
86 + rd->Buffer = stream;
87 + rd->BufferLim = stream + bufferSize;
91 + rd->Range = (0xFFFFFFFF);
92 + for(i = 0; i < 5; i++)
93 + rd->Code = (rd->Code << 8) | ReadByte;
96 +#define RC_INIT_VAR UInt32 range = rd->Range; UInt32 code = rd->Code;
97 +#define RC_FLUSH_VAR rd->Range = range; rd->Code = code;
98 +#define RC_NORMALIZE if (range < kTopValue) { range <<= 8; code = (code << 8) | ReadByte; }
100 +UInt32 RangeDecoderDecodeDirectBits(CRangeDecoder *rd, int numTotalBits)
105 + for (i = numTotalBits; i > 0; i--)
117 + t = (code - range) >> 31;
119 + code -= range & (t - 1);
120 + result = (result + result) | (1 - t);
128 +int RangeDecoderBitDecode(CProb *prob, CRangeDecoder *rd)
130 + UInt32 bound = (rd->Range >> kNumBitModelTotalBits) * *prob;
131 + if (rd->Code < bound)
134 + *prob += (kBitModelTotal - *prob) >> kNumMoveBits;
135 + if (rd->Range < kTopValue)
137 + rd->Code = (rd->Code << 8) | ReadByte;
144 + rd->Range -= bound;
146 + *prob -= (*prob) >> kNumMoveBits;
147 + if (rd->Range < kTopValue)
149 + rd->Code = (rd->Code << 8) | ReadByte;
156 +#define RC_GET_BIT2(prob, mi, A0, A1) \
157 + UInt32 bound = (range >> kNumBitModelTotalBits) * *prob; \
158 + if (code < bound) \
159 + { A0; range = bound; *prob += (kBitModelTotal - *prob) >> kNumMoveBits; mi <<= 1; } \
161 + { A1; range -= bound; code -= bound; *prob -= (*prob) >> kNumMoveBits; mi = (mi + mi) + 1; } \
164 +#define RC_GET_BIT(prob, mi) RC_GET_BIT2(prob, mi, ; , ;)
166 +int RangeDecoderBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd)
170 + #ifdef _LZMA_LOC_OPT
173 + for(i = numLevels; i > 0; i--)
175 + #ifdef _LZMA_LOC_OPT
176 + CProb *prob = probs + mi;
177 + RC_GET_BIT(prob, mi)
179 + mi = (mi + mi) + RangeDecoderBitDecode(probs + mi, rd);
182 + #ifdef _LZMA_LOC_OPT
185 + return mi - (1 << numLevels);
188 +int RangeDecoderReverseBitTreeDecode(CProb *probs, int numLevels, CRangeDecoder *rd)
193 + #ifdef _LZMA_LOC_OPT
196 + for(i = 0; i < numLevels; i++)
198 + #ifdef _LZMA_LOC_OPT
199 + CProb *prob = probs + mi;
200 + RC_GET_BIT2(prob, mi, ; , symbol |= (1 << i))
202 + int bit = RangeDecoderBitDecode(probs + mi, rd);
203 + mi = mi + mi + bit;
204 + symbol |= (bit << i);
207 + #ifdef _LZMA_LOC_OPT
213 +Byte LzmaLiteralDecode(CProb *probs, CRangeDecoder *rd)
216 + #ifdef _LZMA_LOC_OPT
221 + #ifdef _LZMA_LOC_OPT
222 + CProb *prob = probs + symbol;
223 + RC_GET_BIT(prob, symbol)
225 + symbol = (symbol + symbol) | RangeDecoderBitDecode(probs + symbol, rd);
228 + while (symbol < 0x100);
229 + #ifdef _LZMA_LOC_OPT
235 +Byte LzmaLiteralDecodeMatch(CProb *probs, CRangeDecoder *rd, Byte matchByte)
238 + #ifdef _LZMA_LOC_OPT
244 + int matchBit = (matchByte >> 7) & 1;
246 + #ifdef _LZMA_LOC_OPT
248 + CProb *prob = probs + ((1 + matchBit) << 8) + symbol;
249 + RC_GET_BIT2(prob, symbol, bit = 0, bit = 1)
252 + bit = RangeDecoderBitDecode(probs + ((1 + matchBit) << 8) + symbol, rd);
253 + symbol = (symbol << 1) | bit;
255 + if (matchBit != bit)
257 + while (symbol < 0x100)
259 + #ifdef _LZMA_LOC_OPT
260 + CProb *prob = probs + symbol;
261 + RC_GET_BIT(prob, symbol)
263 + symbol = (symbol + symbol) | RangeDecoderBitDecode(probs + symbol, rd);
269 + while (symbol < 0x100);
270 + #ifdef _LZMA_LOC_OPT
276 +#define kNumPosBitsMax 4
277 +#define kNumPosStatesMax (1 << kNumPosBitsMax)
279 +#define kLenNumLowBits 3
280 +#define kLenNumLowSymbols (1 << kLenNumLowBits)
281 +#define kLenNumMidBits 3
282 +#define kLenNumMidSymbols (1 << kLenNumMidBits)
283 +#define kLenNumHighBits 8
284 +#define kLenNumHighSymbols (1 << kLenNumHighBits)
287 +#define LenChoice2 (LenChoice + 1)
288 +#define LenLow (LenChoice2 + 1)
289 +#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits))
290 +#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits))
291 +#define kNumLenProbs (LenHigh + kLenNumHighSymbols)
293 +int LzmaLenDecode(CProb *p, CRangeDecoder *rd, int posState)
295 + if(RangeDecoderBitDecode(p + LenChoice, rd) == 0)
296 + return RangeDecoderBitTreeDecode(p + LenLow +
297 + (posState << kLenNumLowBits), kLenNumLowBits, rd);
298 + if(RangeDecoderBitDecode(p + LenChoice2, rd) == 0)
299 + return kLenNumLowSymbols + RangeDecoderBitTreeDecode(p + LenMid +
300 + (posState << kLenNumMidBits), kLenNumMidBits, rd);
301 + return kLenNumLowSymbols + kLenNumMidSymbols +
302 + RangeDecoderBitTreeDecode(p + LenHigh, kLenNumHighBits, rd);
305 +#define kNumStates 12
307 +#define kStartPosModelIndex 4
308 +#define kEndPosModelIndex 14
309 +#define kNumFullDistances (1 << (kEndPosModelIndex >> 1))
311 +#define kNumPosSlotBits 6
312 +#define kNumLenToPosStates 4
314 +#define kNumAlignBits 4
315 +#define kAlignTableSize (1 << kNumAlignBits)
317 +#define kMatchMinLen 2
320 +#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax))
321 +#define IsRepG0 (IsRep + kNumStates)
322 +#define IsRepG1 (IsRepG0 + kNumStates)
323 +#define IsRepG2 (IsRepG1 + kNumStates)
324 +#define IsRep0Long (IsRepG2 + kNumStates)
325 +#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax))
326 +#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits))
327 +#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex)
328 +#define LenCoder (Align + kAlignTableSize)
329 +#define RepLenCoder (LenCoder + kNumLenProbs)
330 +#define Literal (RepLenCoder + kNumLenProbs)
332 +#if Literal != LZMA_BASE_SIZE
336 +#ifdef _LZMA_OUT_READ
338 +typedef struct _LzmaVarState
340 + CRangeDecoder RangeDecoder;
342 + UInt32 DictionarySize;
343 + UInt32 DictionaryPos;
350 + int PreviousIsMatch;
354 +int LzmaDecoderInit(
355 + unsigned char *buffer, UInt32 bufferSize,
356 + int lc, int lp, int pb,
357 + unsigned char *dictionary, UInt32 dictionarySize,
359 + ILzmaInCallback *inCallback
361 + unsigned char *inStream, UInt32 inSize
365 + LzmaVarState *vs = (LzmaVarState *)buffer;
366 + CProb *p = (CProb *)(buffer + sizeof(LzmaVarState));
367 + UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + lp));
369 + if (bufferSize < numProbs * sizeof(CProb) + sizeof(LzmaVarState))
370 + return LZMA_RESULT_NOT_ENOUGH_MEM;
371 + vs->Dictionary = dictionary;
372 + vs->DictionarySize = dictionarySize;
373 + vs->DictionaryPos = 0;
375 + vs->Reps[0] = vs->Reps[1] = vs->Reps[2] = vs->Reps[3] = 1;
380 + vs->PreviousIsMatch = 0;
382 + dictionary[dictionarySize - 1] = 0;
383 + for (i = 0; i < numProbs; i++)
384 + p[i] = kBitModelTotal >> 1;
385 + RangeDecoderInit(&vs->RangeDecoder,
392 + return LZMA_RESULT_OK;
395 +int LzmaDecode(unsigned char *buffer,
396 + unsigned char *outStream, UInt32 outSize,
397 + UInt32 *outSizeProcessed)
399 + LzmaVarState *vs = (LzmaVarState *)buffer;
400 + CProb *p = (CProb *)(buffer + sizeof(LzmaVarState));
401 + CRangeDecoder rd = vs->RangeDecoder;
402 + int state = vs->State;
403 + int previousIsMatch = vs->PreviousIsMatch;
405 + UInt32 rep0 = vs->Reps[0], rep1 = vs->Reps[1], rep2 = vs->Reps[2], rep3 = vs->Reps[3];
407 + UInt32 posStateMask = (1 << (vs->pb)) - 1;
408 + UInt32 literalPosMask = (1 << (vs->lp)) - 1;
410 + int len = vs->RemainLen;
411 + UInt32 globalPos = vs->GlobalPos;
413 + Byte *dictionary = vs->Dictionary;
414 + UInt32 dictionarySize = vs->DictionarySize;
415 + UInt32 dictionaryPos = vs->DictionaryPos;
419 + *outSizeProcessed = 0;
420 + return LZMA_RESULT_OK;
423 + while(len > 0 && nowPos < outSize)
425 + UInt32 pos = dictionaryPos - rep0;
426 + if (pos >= dictionarySize)
427 + pos += dictionarySize;
428 + outStream[nowPos++] = dictionary[dictionaryPos] = dictionary[pos];
429 + if (++dictionaryPos == dictionarySize)
433 + if (dictionaryPos == 0)
434 + previousByte = dictionary[dictionarySize - 1];
436 + previousByte = dictionary[dictionaryPos - 1];
440 + Byte *buffer, UInt32 bufferSize,
441 + int lc, int lp, int pb,
443 + ILzmaInCallback *inCallback,
445 + unsigned char *inStream, UInt32 inSize,
447 + unsigned char *outStream, UInt32 outSize,
448 + UInt32 *outSizeProcessed)
450 + UInt32 numProbs = Literal + ((UInt32)LZMA_LIT_SIZE << (lc + lp));
451 + CProb *p = (CProb *)buffer;
455 + int previousIsMatch = 0;
456 + Byte previousByte = 0;
457 + UInt32 rep0 = 1, rep1 = 1, rep2 = 1, rep3 = 1;
459 + UInt32 posStateMask = (1 << pb) - 1;
460 + UInt32 literalPosMask = (1 << lp) - 1;
462 + if (bufferSize < numProbs * sizeof(CProb))
463 + return LZMA_RESULT_NOT_ENOUGH_MEM;
464 + for (i = 0; i < numProbs; i++)
465 + p[i] = kBitModelTotal >> 1;
466 + RangeDecoderInit(&rd,
475 + *outSizeProcessed = 0;
476 + while(nowPos < outSize)
478 + int posState = (int)(
480 + #ifdef _LZMA_OUT_READ
486 + if (rd.Result != LZMA_RESULT_OK)
489 + if (rd.ExtraBytes != 0)
490 + return LZMA_RESULT_DATA_ERROR;
491 + if (RangeDecoderBitDecode(p + IsMatch + (state << kNumPosBitsMax) + posState, &rd) == 0)
493 + CProb *probs = p + Literal + (LZMA_LIT_SIZE *
496 + #ifdef _LZMA_OUT_READ
500 + & literalPosMask) << lc) + (previousByte >> (8 - lc))));
502 + if (state < 4) state = 0;
503 + else if (state < 10) state -= 3;
505 + if (previousIsMatch)
508 + #ifdef _LZMA_OUT_READ
509 + UInt32 pos = dictionaryPos - rep0;
510 + if (pos >= dictionarySize)
511 + pos += dictionarySize;
512 + matchByte = dictionary[pos];
514 + matchByte = outStream[nowPos - rep0];
516 + previousByte = LzmaLiteralDecodeMatch(probs, &rd, matchByte);
517 + previousIsMatch = 0;
520 + previousByte = LzmaLiteralDecode(probs, &rd);
521 + outStream[nowPos++] = previousByte;
522 + #ifdef _LZMA_OUT_READ
523 + dictionary[dictionaryPos] = previousByte;
524 + if (++dictionaryPos == dictionarySize)
530 + previousIsMatch = 1;
531 + if (RangeDecoderBitDecode(p + IsRep + state, &rd) == 1)
533 + if (RangeDecoderBitDecode(p + IsRepG0 + state, &rd) == 0)
535 + if (RangeDecoderBitDecode(p + IsRep0Long + (state << kNumPosBitsMax) + posState, &rd) == 0)
537 + #ifdef _LZMA_OUT_READ
542 + #ifdef _LZMA_OUT_READ
547 + return LZMA_RESULT_DATA_ERROR;
548 + state = state < 7 ? 9 : 11;
549 + #ifdef _LZMA_OUT_READ
550 + pos = dictionaryPos - rep0;
551 + if (pos >= dictionarySize)
552 + pos += dictionarySize;
553 + previousByte = dictionary[pos];
554 + dictionary[dictionaryPos] = previousByte;
555 + if (++dictionaryPos == dictionarySize)
558 + previousByte = outStream[nowPos - rep0];
560 + outStream[nowPos++] = previousByte;
567 + if(RangeDecoderBitDecode(p + IsRepG1 + state, &rd) == 0)
571 + if(RangeDecoderBitDecode(p + IsRepG2 + state, &rd) == 0)
583 + len = LzmaLenDecode(p + RepLenCoder, &rd, posState);
584 + state = state < 7 ? 8 : 11;
592 + state = state < 7 ? 7 : 10;
593 + len = LzmaLenDecode(p + LenCoder, &rd, posState);
594 + posSlot = RangeDecoderBitTreeDecode(p + PosSlot +
595 + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) <<
596 + kNumPosSlotBits), kNumPosSlotBits, &rd);
597 + if (posSlot >= kStartPosModelIndex)
599 + int numDirectBits = ((posSlot >> 1) - 1);
600 + rep0 = ((2 | ((UInt32)posSlot & 1)) << numDirectBits);
601 + if (posSlot < kEndPosModelIndex)
603 + rep0 += RangeDecoderReverseBitTreeDecode(
604 + p + SpecPos + rep0 - posSlot - 1, numDirectBits, &rd);
608 + rep0 += RangeDecoderDecodeDirectBits(&rd,
609 + numDirectBits - kNumAlignBits) << kNumAlignBits;
610 + rep0 += RangeDecoderReverseBitTreeDecode(p + Align, kNumAlignBits, &rd);
617 + if (rep0 == (UInt32)(0))
619 + /* it's for stream version */
624 + #ifdef _LZMA_OUT_READ
629 + return LZMA_RESULT_DATA_ERROR;
631 + len += kMatchMinLen;
634 + #ifdef _LZMA_OUT_READ
635 + UInt32 pos = dictionaryPos - rep0;
636 + if (pos >= dictionarySize)
637 + pos += dictionarySize;
638 + previousByte = dictionary[pos];
639 + dictionary[dictionaryPos] = previousByte;
640 + if (++dictionaryPos == dictionarySize)
643 + previousByte = outStream[nowPos - rep0];
645 + outStream[nowPos++] = previousByte;
648 + while(len > 0 && nowPos < outSize);
652 + #ifdef _LZMA_OUT_READ
653 + vs->RangeDecoder = rd;
654 + vs->DictionaryPos = dictionaryPos;
655 + vs->GlobalPos = globalPos + nowPos;
656 + vs->Reps[0] = rep0;
657 + vs->Reps[1] = rep1;
658 + vs->Reps[2] = rep2;
659 + vs->Reps[3] = rep3;
661 + vs->PreviousIsMatch = previousIsMatch;
662 + vs->RemainLen = len;
665 + *outSizeProcessed = nowPos;
666 + return LZMA_RESULT_OK;
668 diff -Nur linux-2.6.12.5-brcm-squashfs/fs/squashfs/LzmaDecode.h linux-2.6.12.5-brcm-squashfs-lzma/fs/squashfs/LzmaDecode.h
669 --- linux-2.6.12.5-brcm-squashfs/fs/squashfs/LzmaDecode.h 1970-01-01 01:00:00.000000000 +0100
670 +++ linux-2.6.12.5-brcm-squashfs-lzma/fs/squashfs/LzmaDecode.h 2005-08-29 00:02:44.099124176 +0200
674 + LZMA Decoder interface
676 + LZMA SDK 4.05 Copyright (c) 1999-2004 Igor Pavlov (2004-08-25)
677 + http://www.7-zip.org/
679 + LZMA SDK is licensed under two licenses:
680 + 1) GNU Lesser General Public License (GNU LGPL)
681 + 2) Common Public License (CPL)
682 + It means that you can select one of these two licenses and
683 + follow rules of that license.
686 + Igor Pavlov, as the author of this code, expressly permits you to
687 + statically or dynamically link your code (or bind by name) to the
688 + interfaces of this file without subjecting your linked code to the
689 + terms of the CPL or GNU LGPL. Any modifications or additions
690 + to this file, however, are subject to the LGPL or CPL terms.
693 +#ifndef __LZMADECODE_H
694 +#define __LZMADECODE_H
696 +/* #define _LZMA_IN_CB */
697 +/* Use callback for input data */
699 +/* #define _LZMA_OUT_READ */
700 +/* Use read function for output data */
702 +/* #define _LZMA_PROB32 */
703 +/* It can increase speed on some 32-bit CPUs,
704 + but memory usage will be doubled in that case */
706 +/* #define _LZMA_LOC_OPT */
707 +/* Enable local speed optimizations inside code */
710 +#ifdef _LZMA_UINT32_IS_ULONG
711 +#define UInt32 unsigned long
713 +#define UInt32 unsigned int
718 +#define CProb UInt32
720 +#define CProb unsigned short
723 +#define LZMA_RESULT_OK 0
724 +#define LZMA_RESULT_DATA_ERROR 1
725 +#define LZMA_RESULT_NOT_ENOUGH_MEM 2
728 +typedef struct _ILzmaInCallback
730 + int (*Read)(void *object, unsigned char **buffer, UInt32 *bufferSize);
734 +#define LZMA_BASE_SIZE 1846
735 +#define LZMA_LIT_SIZE 768
738 +bufferSize = (LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)))* sizeof(CProb)
739 +bufferSize += 100 in case of _LZMA_OUT_READ
740 +by default CProb is unsigned short,
741 +but if specify _LZMA_PROB_32, CProb will be UInt32(unsigned int)
744 +#ifdef _LZMA_OUT_READ
745 +int LzmaDecoderInit(
746 + unsigned char *buffer, UInt32 bufferSize,
747 + int lc, int lp, int pb,
748 + unsigned char *dictionary, UInt32 dictionarySize,
750 + ILzmaInCallback *inCallback
752 + unsigned char *inStream, UInt32 inSize
758 + unsigned char *buffer,
759 + #ifndef _LZMA_OUT_READ
761 + int lc, int lp, int pb,
763 + ILzmaInCallback *inCallback,
765 + unsigned char *inStream, UInt32 inSize,
768 + unsigned char *outStream, UInt32 outSize,
769 + UInt32 *outSizeProcessed);
772 diff -Nur linux-2.6.12.5-brcm-squashfs/fs/squashfs/Makefile linux-2.6.12.5-brcm-squashfs-lzma/fs/squashfs/Makefile
773 --- linux-2.6.12.5-brcm-squashfs/fs/squashfs/Makefile 2005-08-28 23:44:05.046246000 +0200
774 +++ linux-2.6.12.5-brcm-squashfs-lzma/fs/squashfs/Makefile 2005-08-29 00:06:21.872017664 +0200
777 obj-$(CONFIG_SQUASHFS) += squashfs.o
779 -squashfs-objs := inode.o
780 +squashfs-objs := inode.o LzmaDecode.o
781 diff -Nur linux-2.6.12.5-brcm-squashfs/fs/squashfs/inode.c linux-2.6.12.5-brcm-squashfs-lzma/fs/squashfs/inode.c
782 --- linux-2.6.12.5-brcm-squashfs/fs/squashfs/inode.c 2005-08-28 23:44:05.045246000 +0200
783 +++ linux-2.6.12.5-brcm-squashfs-lzma/fs/squashfs/inode.c 2005-08-29 00:19:48.473476904 +0200
786 * Copyright (c) 2002, 2003, 2004, 2005 Phillip Lougher <phillip@lougher.demon.co.uk>
788 + * LZMA decompressor support added by Oleg I. Vdovikin
789 + * Copyright (c) 2005 Oleg I.Vdovikin <oleg@cs.msu.su>
791 * This program is free software; you can redistribute it and/or
792 * modify it under the terms of the GNU General Public License
793 * as published by the Free Software Foundation; either version 2,
798 +#define SQUASHFS_LZMA
800 +#ifndef SQUASHFS_LZMA
801 #define SQUASHFS_1_0_COMPATIBILITY
804 #include <linux/types.h>
805 #include <linux/squashfs_fs.h>
807 #include <linux/blkdev.h>
808 #include <linux/vmalloc.h>
810 +#ifdef SQUASHFS_LZMA
811 +#include "LzmaDecode.h"
813 +/* default LZMA settings, should be in sync with mksquashfs */
818 +#define LZMA_WORKSPACE_SIZE ((LZMA_BASE_SIZE + \
819 + (LZMA_LIT_SIZE << (LZMA_LC + LZMA_LP))) * sizeof(CProb))
823 #ifdef SQUASHFS_TRACE
824 #define TRACE(s, args...) printk(KERN_NOTICE "SQUASHFS: "s, ## args)
828 DECLARE_MUTEX(read_data_mutex);
830 +#ifdef SQUASHFS_LZMA
831 +static unsigned char lzma_workspace[LZMA_WORKSPACE_SIZE];
833 static z_stream stream;
836 static struct file_system_type squashfs_fs_type = {
837 .owner = THIS_MODULE,
842 +#ifdef SQUASHFS_LZMA
843 + if ((zlib_err = LzmaDecode(lzma_workspace,
844 + LZMA_WORKSPACE_SIZE, LZMA_LC, LZMA_LP, LZMA_PB,
845 + c_buffer, c_byte, buffer, msBlk->read_size, &bytes)) != LZMA_RESULT_OK)
847 + ERROR("lzma returned unexpected result 0x%x\n", zlib_err);
851 stream.next_in = c_buffer;
852 stream.avail_in = c_byte;
853 stream.next_out = buffer;
857 bytes = stream.total_out;
859 up(&read_data_mutex);
862 @@ -1725,14 +1759,17 @@
864 printk(KERN_INFO "Squashfs 2.2 (released 2005/07/03) (C) 2002-2005 Phillip Lougher\n");
866 +#ifndef SQUASHFS_LZMA
867 if(!(stream.workspace = (char *) vmalloc(zlib_inflate_workspacesize()))) {
868 ERROR("Failed to allocate zlib workspace\n");
869 destroy_inodecache();
874 if((err = register_filesystem(&squashfs_fs_type))) {
875 +#ifndef SQUASHFS_LZMA
876 vfree(stream.workspace);
878 destroy_inodecache();
881 @@ -1742,7 +1779,9 @@
883 static void __exit exit_squashfs_fs(void)
885 +#ifndef SQUASHFS_LZMA
886 vfree(stream.workspace);
888 unregister_filesystem(&squashfs_fs_type);
889 destroy_inodecache();