mtd-utils: update to 2.0.2
[openwrt/openwrt.git] / package / utils / mtd-utils / patches / 130-lzma_jffs2.patch
index 8c3794d..d9cbfee 100644 (file)
@@ -1,25 +1,29 @@
---- a/Makefile
-+++ b/Makefile
-@@ -3,7 +3,7 @@
+--- a/jffsX-utils/Makemodule.am
++++ b/jffsX-utils/Makemodule.am
+@@ -4,11 +4,19 @@ mkfs_jffs2_SOURCES = \
+       jffsX-utils/compr_zlib.c \
+       jffsX-utils/compr.h \
+       jffsX-utils/rbtree.c \
+-      jffsX-utils/compr_lzo.c \
++      jffsX-utils/compr_lzma.c \
++      jffsX-utils/lzma/LzFind.c \
++      jffsX-utils/lzma/LzmaEnc.c \
++      jffsX-utils/lzma/LzmaDec.c \
+       jffsX-utils/compr.c \
+       jffsX-utils/compr_rtime.c
++
++if !WITHOUT_LZO
++mkfs_jffs2_SOURCES += jffsX-utils/compr_lzo.c
++endif
++
+ mkfs_jffs2_LDADD = libmtd.a $(ZLIB_LIBS) $(LZO_LIBS)
+-mkfs_jffs2_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS)
++mkfs_jffs2_CPPFLAGS = $(AM_CPPFLAGS) $(ZLIB_CFLAGS) $(LZO_CFLAGS) -I./include/linux/lzma
  
- VERSION = 1.5.1
--CPPFLAGS += -D_GNU_SOURCE -I./include -I$(BUILDDIR)/include -I./ubi-utils/include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) $(UUIDCPPFLAGS)
-+CPPFLAGS += -D_GNU_SOURCE -I./include -I$(BUILDDIR)/include -I./ubi-utils/include $(ZLIBCPPFLAGS) $(LZOCPPFLAGS) $(UUIDCPPFLAGS) -I./include/linux/lzma
- ifeq ($(WITHOUT_XATTR), 1)
-   CPPFLAGS += -DWITHOUT_XATTR
-@@ -84,7 +84,7 @@ $(BUILDDIR)/include/version.h.tmp:
- #
- # Utils in top level
- #
--obj-mkfs.jffs2 = compr_rtime.o compr_zlib.o compr_lzo.o compr.o rbtree.o
-+obj-mkfs.jffs2 = compr_rtime.o compr_zlib.o $(if $(WITHOUT_LZO),,compr_lzo.o) compr_lzma.o lzma/LzFind.o lzma/LzmaEnc.o lzma/LzmaDec.o compr.o rbtree.o
- LDFLAGS_mkfs.jffs2 = $(ZLIBLDFLAGS) $(LZOLDFLAGS)
- LDLIBS_mkfs.jffs2  = -lz $(LZOLDLIBS)
---- a/compr.c
-+++ b/compr.c
+ jffs2reader_SOURCES = jffsX-utils/jffs2reader.c
+ jffs2reader_LDADD = libmtd.a $(ZLIB_LIBS) $(LZO_LIBS)
+--- a/jffsX-utils/compr.c
++++ b/jffsX-utils/compr.c
 @@ -520,6 +520,9 @@ int jffs2_compressors_init(void)
  #ifdef CONFIG_JFFS2_LZO
        jffs2_lzo_init();
@@ -39,8 +43,8 @@
 +#endif
        return 0;
  }
---- a/compr.h
-+++ b/compr.h
+--- a/jffsX-utils/compr.h
++++ b/jffsX-utils/compr.h
 @@ -18,13 +18,14 @@
  
  #define CONFIG_JFFS2_ZLIB
@@ -71,7 +75,7 @@
  
  #endif /* __JFFS2_COMPR_H__ */
 --- /dev/null
-+++ b/compr_lzma.c
++++ b/jffsX-utils/compr_lzma.c
 @@ -0,0 +1,128 @@
 +/*
 + * JFFS2 -- Journalling Flash File System, Version 2.
 +}
 +
 +STATIC int jffs2_lzma_compress(unsigned char *data_in, unsigned char *cpage_out,
-+                            uint32_t *sourcelen, uint32_t *dstlen, void *model)
++                            uint32_t *sourcelen, uint32_t *dstlen)
 +{
 +      SizeT compress_size = (SizeT)(*dstlen);
 +      int ret;
 +}
 +
 +STATIC int jffs2_lzma_decompress(unsigned char *data_in, unsigned char *cpage_out,
-+                               uint32_t srclen, uint32_t destlen, void *model)
++                               uint32_t srclen, uint32_t destlen)
 +{
 +      int ret;
 +      SizeT dl = (SizeT)destlen;
 +
 +      ret = lzma_alloc_workspace(&props);
 +      if (ret < 0)
-+      return ret;
++              return ret;
 +
 +      ret = jffs2_register_compressor(&jffs2_lzma_comp);
 +      if (ret)
 +      #define LZMA_FREE free
 +      #define PRINT_ERROR(msg) fprintf(stderr, msg)
 +      #define INIT
-+      #define STATIC
++      #define STATIC static
 +#endif
 +
 +#include "lzma/LzmaDec.h"
 +
 +#endif
 --- /dev/null
-+++ b/lzma/LzFind.c
++++ b/jffsX-utils/lzma/LzFind.c
 @@ -0,0 +1,753 @@
 +/* LzFind.c  -- Match finder for LZ algorithms
 +2008-04-04
 +}
 +
 +Byte *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p) { return p->buffer; }
-+Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
++static Byte MatchFinder_GetIndexByte(CMatchFinder *p, Int32 index) { return p->buffer[index]; }
 +
-+UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
++static UInt32 MatchFinder_GetNumAvailableBytes(CMatchFinder *p) { return p->streamPos - p->pos; }
 +
 +void MatchFinder_ReduceOffsets(CMatchFinder *p, UInt32 subValue)
 +{
 +  }
 +}
 --- /dev/null
-+++ b/lzma/LzmaDec.c
++++ b/jffsX-utils/lzma/LzmaDec.c
 @@ -0,0 +1,1014 @@
 +/* LzmaDec.c -- LZMA Decoder
 +2008-04-29
 +  p->needFlush = 0;
 +}
 +
-+void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) 
++static void LzmaDec_InitDicAndState(CLzmaDec *p, Bool initDic, Bool initState) 
 +{ 
 +  p->needFlush = 1; 
 +  p->remainLen = 0; 
 +  return res;
 +}
 --- /dev/null
-+++ b/lzma/LzmaEnc.c
++++ b/jffsX-utils/lzma/LzmaEnc.c
 @@ -0,0 +1,2335 @@
 +/* LzmaEnc.c -- LZMA Encoder
 +2008-04-28
 +#define kNumLogBits (9 + (int)sizeof(size_t) / 2)
 +#define kDicLogSizeMaxCompress ((kNumLogBits - 1) * 2 + 7)
 +
-+void LzmaEnc_FastPosInit(Byte *g_FastPos)
++static void LzmaEnc_FastPosInit(Byte *g_FastPos)
 +{
 +  int c = 2, slotFast;
 +  g_FastPos[0] = 0;
 +  CSaveState saveState;
 +} CLzmaEnc;
 +
-+void LzmaEnc_SaveState(CLzmaEncHandle pp)
++static void LzmaEnc_SaveState(CLzmaEncHandle pp)
 +{
 +  CLzmaEnc *p = (CLzmaEnc *)pp;
 +  CSaveState *dest = &p->saveState;
 +  memcpy(dest->litProbs, p->litProbs, (0x300 << p->lclp) * sizeof(CLzmaProb));
 +}
 +
-+void LzmaEnc_RestoreState(CLzmaEncHandle pp)
++static void LzmaEnc_RestoreState(CLzmaEncHandle pp)
 +{
 +  CLzmaEnc *dest = (CLzmaEnc *)pp;
 +  const CSaveState *p = &dest->saveState;
 +  while (symbol < 0x10000);
 +}
 +
-+void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
++static void LzmaEnc_InitPriceTables(UInt32 *ProbPrices)
 +{
 +  UInt32 i;
 +  for (i = (1 << kNumMoveReducingBits) / 2; i < kBitModelTotal; i += (1 << kNumMoveReducingBits))
 +  p->matchPriceCount = 0;
 +}
 +
-+void LzmaEnc_Construct(CLzmaEnc *p)
++static void LzmaEnc_Construct(CLzmaEnc *p)
 +{
 +  RangeEnc_Construct(&p->rc);
 +  MatchFinder_Construct(&p->matchFinderBase);
 +  return p;
 +}
 +
-+void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
++static void LzmaEnc_FreeLits(CLzmaEnc *p, ISzAlloc *alloc)
 +{
 +  alloc->Free(alloc, p->litProbs);
 +  alloc->Free(alloc, p->saveState.litProbs);
 +  p->saveState.litProbs = 0;
 +}
 +
-+void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
++static void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig)
 +{
 +  #ifdef COMPRESS_MF_MT
 +  MatchFinderMt_Destruct(&p->matchFinderMt, allocBig);
 +  return SZ_OK;
 +}
 +
-+void LzmaEnc_Init(CLzmaEnc *p)
++static void LzmaEnc_Init(CLzmaEnc *p)
 +{
 +  UInt32 i;
 +  p->state = 0;
 +  p->lpMask = (1 << p->lp) - 1;
 +}
 +
-+void LzmaEnc_InitPrices(CLzmaEnc *p)
++static void LzmaEnc_InitPrices(CLzmaEnc *p)
 +{
 +  if (!p->fastMode)
 +  {
 +  return LzmaEnc_AllocAndInit(p, 0, alloc, allocBig);
 +}
 +
-+SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, 
++static SRes LzmaEnc_PrepareForLzma2(CLzmaEncHandle pp, 
 +    ISeqInStream *inStream, UInt32 keepWindowSize,
 +    ISzAlloc *alloc, ISzAlloc *allocBig)
 +{
 +  p->seqBufInStream.rem = srcLen;
 +}
 +
-+SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
++static SRes LzmaEnc_MemPrepare(CLzmaEncHandle pp, const Byte *src, SizeT srcLen,
 +    UInt32 keepWindowSize, ISzAlloc *alloc, ISzAlloc *allocBig)
 +{
 +  CLzmaEnc *p = (CLzmaEnc *)pp;
 +  return LzmaEnc_AllocAndInit(p, keepWindowSize, alloc, allocBig);
 +}
 +
-+void LzmaEnc_Finish(CLzmaEncHandle pp)
++static void LzmaEnc_Finish(CLzmaEncHandle pp)
 +{
 +  #ifdef COMPRESS_MF_MT
 +  CLzmaEnc *p = (CLzmaEnc *)pp;
 +}
 +
 +
-+UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
++static UInt32 LzmaEnc_GetNumAvailableBytes(CLzmaEncHandle pp)
 +{
 +  const CLzmaEnc *p = (CLzmaEnc *)pp;
 +  return p->matchFinder.GetNumAvailableBytes(p->matchFinderObj);
 +}
 +
-+const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
++static const Byte *LzmaEnc_GetCurBuf(CLzmaEncHandle pp)
 +{
 +  const CLzmaEnc *p = (CLzmaEnc *)pp;
 +  return p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - p->additionalOffset;
 +}
 +
-+SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, 
++static SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, Bool reInit, 
 +    Byte *dest, size_t *destLen, UInt32 desiredPackSize, UInt32 *unpackSize)
 +{
 +  CLzmaEnc *p = (CLzmaEnc *)pp;
 +  LzmaEnc_Destroy(p, alloc, allocBig);
 +  return res;
 +}
---- a/mkfs.jffs2.c
-+++ b/mkfs.jffs2.c
-@@ -1659,11 +1659,11 @@ int main(int argc, char **argv)
+--- a/jffsX-utils/mkfs.jffs2.c
++++ b/jffsX-utils/mkfs.jffs2.c
+@@ -1666,11 +1666,11 @@ int main(int argc, char **argv)
                                                  }
                                                  erase_block_size *= units;