# HG changeset patch # User Pascal Bellard # Date 1262536896 -3600 # Node ID 0c0c693fe4c61b0e283b2fc18c5f67ca010762a8 # Parent 4911917bb50ff19fb8a28ff351c9b97cb05a2533 linux/squashfs: add lzma support diff -r 4911917bb50f -r 0c0c693fe4c6 dahdi/receipt --- a/dahdi/receipt Sat Jan 02 14:50:04 2010 +0100 +++ b/dahdi/receipt Sun Jan 03 17:41:36 2010 +0100 @@ -5,7 +5,6 @@ CATEGORY="meta" SHORT_DESC="Digium Asterisk Hardware Device Interface." MAINTAINER="pascal.bellard@slitaz.org" -TARBALL="$PACKAGE-$VERSION.tar.gz" WEB_SITE="http://www.asterisk.org/" DEPENDS="dahdi-linux dahdi-tools" PROVIDE="zaptel" diff -r 4911917bb50f -r 0c0c693fe4c6 linux/receipt --- a/linux/receipt Sat Jan 02 14:50:04 2010 +0100 +++ b/linux/receipt Sun Jan 03 17:41:36 2010 +0100 @@ -51,6 +51,7 @@ aufs2-kbuild.patch aufs2-standalone.patch $PACKAGE-header-$VERSION.u +$PACKAGE-squashfs-lzma-$VERSION.u EOT make mrproper cd Documentation/lguest diff -r 4911917bb50f -r 0c0c693fe4c6 linux/stuff/linux-2.6.30.6-slitaz.config --- a/linux/stuff/linux-2.6.30.6-slitaz.config Sat Jan 02 14:50:04 2010 +0100 +++ b/linux/stuff/linux-2.6.30.6-slitaz.config Sun Jan 03 17:41:36 2010 +0100 @@ -1,7 +1,7 @@ # # Automatically generated make config: don't edit # Linux kernel version: 2.6.30.6 -# Mon Nov 30 12:43:49 2009 +# Sun Jan 3 17:28:53 2010 # # CONFIG_64BIT is not set CONFIG_X86_32=y @@ -2149,7 +2149,7 @@ CONFIG_VIDEO_V4L2_COMMON=m CONFIG_VIDEO_ALLOW_V4L1=y CONFIG_VIDEO_V4L1_COMPAT=y -# CONFIG_DVB_CORE is not set +CONFIG_DVB_CORE=m CONFIG_VIDEO_MEDIA=m # @@ -2192,7 +2192,10 @@ # CONFIG_VIDEO_HEXIUM_ORION is not set # CONFIG_VIDEO_HEXIUM_GEMINI is not set # CONFIG_VIDEO_CX88 is not set +# CONFIG_VIDEO_CX23885 is not set +# CONFIG_VIDEO_AU0828 is not set # CONFIG_VIDEO_IVTV is not set +# CONFIG_VIDEO_CX18 is not set # CONFIG_VIDEO_CAFE_CCIC is not set CONFIG_SOC_CAMERA=m # CONFIG_SOC_CAMERA_MT9M001 is not set @@ -2273,8 +2276,54 @@ # CONFIG_USB_SI470X is not set # CONFIG_USB_MR800 is not set # CONFIG_RADIO_TEA5764 is not set +# CONFIG_DVB_DYNAMIC_MINORS is not set +CONFIG_DVB_CAPTURE_DRIVERS=y + +# +# Supported SAA7146 based PCI Adapters +# +# CONFIG_TTPCI_EEPROM is not set +# CONFIG_DVB_AV7110 is not set +# CONFIG_DVB_BUDGET_CORE is not set + +# +# Supported USB Adapters +# +# CONFIG_DVB_USB is not set +# CONFIG_DVB_TTUSB_BUDGET is not set +# CONFIG_DVB_TTUSB_DEC is not set +# CONFIG_DVB_SIANO_SMS1XXX is not set + +# +# Supported FlexCopII (B2C2) Adapters +# +# CONFIG_DVB_B2C2_FLEXCOP is not set + +# +# Supported BT878 Adapters +# + +# +# Supported Pluto2 Adapters +# +# CONFIG_DVB_PLUTO2 is not set + +# +# Supported SDMC DM1105 Adapters +# +# CONFIG_DVB_DM1105 is not set + +# +# Supported FireWire (IEEE 1394) Adapters +# +# CONFIG_DVB_FIREDTV is not set + +# +# Supported DVB Frontends +# +# CONFIG_DVB_FE_CUSTOMISE is not set CONFIG_DAB=y -# CONFIG_USB_DABUSB is not set +CONFIG_USB_DABUSB=m # # Graphics support @@ -2518,7 +2567,8 @@ CONFIG_SND_FM801_TEA575X_BOOL=y CONFIG_SND_FM801_TEA575X=m CONFIG_SND_HDA_INTEL=m -# CONFIG_SND_HDA_HWDEP is not set +CONFIG_SND_HDA_HWDEP=y +# CONFIG_SND_HDA_RECONFIG is not set # CONFIG_SND_HDA_INPUT_BEEP is not set CONFIG_SND_HDA_CODEC_REALTEK=y CONFIG_SND_HDA_CODEC_ANALOG=y @@ -2533,7 +2583,7 @@ CONFIG_SND_HDA_CODEC_SI3054=y CONFIG_SND_HDA_GENERIC=y CONFIG_SND_HDA_POWER_SAVE=y -CONFIG_SND_HDA_POWER_SAVE_DEFAULT=5 +CONFIG_SND_HDA_POWER_SAVE_DEFAULT=60 CONFIG_SND_HDSP=m CONFIG_SND_HDSPM=m CONFIG_SND_HIFIER=m @@ -3026,6 +3076,7 @@ # CONFIG_EFS_FS is not set CONFIG_CRAMFS=m CONFIG_SQUASHFS=m +CONFIG_SQUASHFS_LZMA=y # CONFIG_SQUASHFS_EMBEDDED is not set CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3 # CONFIG_VXFS_FS is not set @@ -3369,6 +3420,7 @@ CONFIG_DECOMPRESS_GZIP=y CONFIG_DECOMPRESS_BZIP2=y CONFIG_DECOMPRESS_LZMA=y +CONFIG_DECOMPRESS_LZMA_NEEDED=y CONFIG_TEXTSEARCH=y CONFIG_TEXTSEARCH_KMP=m CONFIG_TEXTSEARCH_BM=m @@ -3377,3 +3429,5 @@ CONFIG_HAS_IOPORT=y CONFIG_HAS_DMA=y CONFIG_NLATTR=y +# CONFIG_SHM_SIGNAL is not set +# CONFIG_IOQ is not set diff -r 4911917bb50f -r 0c0c693fe4c6 linux/stuff/linux-squashfs-lzma-2.6.30.6.u --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/linux/stuff/linux-squashfs-lzma-2.6.30.6.u Sun Jan 03 17:41:36 2010 +0100 @@ -0,0 +1,1808 @@ +--- linux-2.6.30.6/fs/squashfs/Kconfig ++++ linux-2.6.30.6/fs/squashfs/Kconfig +@@ -26,6 +26,12 @@ + + If unsure, say N. + ++config SQUASHFS_LZMA ++ bool "Include support for LZMA compressed file systems" ++ depends on SQUASHFS ++ select DECOMPRESS_LZMA ++ select DECOMPRESS_LZMA_NEEDED ++ + config SQUASHFS_EMBEDDED + + bool "Additional option for memory-constrained systems" + +--- linux-2.6.30.6/fs/squashfs/Makefile ++++ linux-2.6.30.6/fs/squashfs/Makefile +@@ -4,4 +4,5 @@ + + obj-$(CONFIG_SQUASHFS) += squashfs.o + squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o +-squashfs-y += namei.o super.o symlink.o ++squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o ++squashfs-$(CONFIG_SQUASHFS_LZMA) += lzma_wrapper.o + +--- linux-2.6.30.6/fs/squashfs/block.c ++++ linux-2.6.30.6/fs/squashfs/block.c +@@ -29,15 +29,14 @@ + #include + #include + #include +-#include + #include + #include +-#include + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" + #include "squashfs_fs_i.h" + #include "squashfs.h" ++#include "decompressor.h" + + /* + * Read the metadata block length, this is stored in the first two +@@ -153,72 +152,10 @@ + } + + if (compressed) { +- int zlib_err = 0, zlib_init = 0; +- +- /* +- * Uncompress block. +- */ +- +- mutex_lock(&msblk->read_data_mutex); +- +- msblk->stream.avail_out = 0; +- msblk->stream.avail_in = 0; +- +- bytes = length; +- do { +- if (msblk->stream.avail_in == 0 && k < b) { +- avail = min(bytes, msblk->devblksize - offset); +- bytes -= avail; +- wait_on_buffer(bh[k]); +- if (!buffer_uptodate(bh[k])) +- goto release_mutex; +- +- if (avail == 0) { +- offset = 0; +- put_bh(bh[k++]); +- continue; +- } +- +- msblk->stream.next_in = bh[k]->b_data + offset; +- msblk->stream.avail_in = avail; +- offset = 0; +- } +- +- if (msblk->stream.avail_out == 0 && page < pages) { +- msblk->stream.next_out = buffer[page++]; +- msblk->stream.avail_out = PAGE_CACHE_SIZE; +- } +- +- if (!zlib_init) { +- zlib_err = zlib_inflateInit(&msblk->stream); +- if (zlib_err != Z_OK) { +- ERROR("zlib_inflateInit returned" +- " unexpected result 0x%x," +- " srclength %d\n", zlib_err, +- srclength); +- goto release_mutex; +- } +- zlib_init = 1; +- } +- +- zlib_err = zlib_inflate(&msblk->stream, Z_SYNC_FLUSH); +- +- if (msblk->stream.avail_in == 0 && k < b) +- put_bh(bh[k++]); +- } while (zlib_err == Z_OK); +- +- if (zlib_err != Z_STREAM_END) { +- ERROR("zlib_inflate error, data probably corrupt\n"); +- goto release_mutex; +- } +- +- zlib_err = zlib_inflateEnd(&msblk->stream); +- if (zlib_err != Z_OK) { +- ERROR("zlib_inflate error, data probably corrupt\n"); +- goto release_mutex; +- } +- length = msblk->stream.total_out; +- mutex_unlock(&msblk->read_data_mutex); ++ length = squashfs_decompress(msblk, buffer, bh, b, offset, ++ length, srclength, pages); ++ if (length < 0) ++ goto read_failure; + } else { + /* + * Block is uncompressed. +@@ -254,9 +191,6 @@ + + kfree(bh); + return length; +- +-release_mutex: +- mutex_unlock(&msblk->read_data_mutex); + + block_release: + for (; k < b; k++) + +--- linux-2.6.30.6/fs/squashfs/cache.c ++++ linux-2.6.30.6/fs/squashfs/cache.c +@@ -51,7 +51,6 @@ + #include + #include + #include +-#include + #include + + #include "squashfs_fs.h" + +--- linux-2.6.30.6/fs/squashfs/decompressor.c ++++ linux-2.6.30.6/fs/squashfs/decompressor.c +@@ -0,0 +1,72 @@ ++/* ++ * Squashfs - a compressed read only filesystem for Linux ++ * ++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 ++ * Phillip Lougher ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2, ++ * or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ * ++ * decompressor.c ++ */ ++ ++#include ++#include ++#include ++ ++#include "squashfs_fs.h" ++#include "squashfs_fs_sb.h" ++#include "squashfs_fs_i.h" ++#include "decompressor.h" ++#include "squashfs.h" ++ ++/* ++ * This file (and decompressor.h) implements a decompressor framework for ++ * Squashfs, allowing multiple decompressors to be easily supported ++ */ ++ ++static const struct squashfs_decompressor squashfs_lzma_unsupported_comp_ops = { ++ NULL, NULL, NULL, LZMA_COMPRESSION, "lzma", 0 ++}; ++ ++static const struct squashfs_decompressor squashfs_lzo_unsupported_comp_ops = { ++ NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0 ++}; ++ ++static const struct squashfs_decompressor squashfs_unknown_comp_ops = { ++ NULL, NULL, NULL, 0, "unknown", 0 ++}; ++ ++static const struct squashfs_decompressor *decompressor[] = { ++ &squashfs_zlib_comp_ops, ++#ifdef CONFIG_SQUASHFS_LZMA ++ &squashfs_lzma_comp_ops, ++#else ++ &squashfs_lzma_unsupported_comp_ops, ++#endif ++ &squashfs_lzo_unsupported_comp_ops, ++ &squashfs_unknown_comp_ops ++}; ++ ++ ++const struct squashfs_decompressor *squashfs_lookup_decompressor(int id) ++{ ++ int i; ++ ++ for (i = 0; decompressor[i]->id; i++) ++ if (id == decompressor[i]->id) ++ break; ++ ++ return decompressor[i]; ++} + +--- linux-2.6.30.6/fs/squashfs/decompressor.h ++++ linux-2.6.30.6/fs/squashfs/decompressor.h +@@ -0,0 +1,55 @@ ++#ifndef DECOMPRESSOR_H ++#define DECOMPRESSOR_H ++/* ++ * Squashfs - a compressed read only filesystem for Linux ++ * ++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 ++ * Phillip Lougher ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2, ++ * or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ * ++ * decompressor.h ++ */ ++ ++struct squashfs_decompressor { ++ void *(*init)(struct squashfs_sb_info *); ++ void (*free)(void *); ++ int (*decompress)(struct squashfs_sb_info *, void **, ++ struct buffer_head **, int, int, int, int, int); ++ int id; ++ char *name; ++ int supported; ++}; ++ ++static inline void *squashfs_decompressor_init(struct squashfs_sb_info *msblk) ++{ ++ return msblk->decompressor->init(msblk); ++} ++ ++static inline void squashfs_decompressor_free(struct squashfs_sb_info *msblk, ++ void *s) ++{ ++ if (msblk->decompressor) ++ msblk->decompressor->free(s); ++} ++ ++static inline int squashfs_decompress(struct squashfs_sb_info *msblk, ++ void **buffer, struct buffer_head **bh, int b, int offset, int length, ++ int srclength, int pages) ++{ ++ return msblk->decompressor->decompress(msblk, buffer, bh, b, offset, ++ length, srclength, pages); ++} ++#endif + +--- linux-2.6.30.6/fs/squashfs/dir.c ++++ linux-2.6.30.6/fs/squashfs/dir.c +@@ -30,7 +30,6 @@ + #include + #include + #include +-#include + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" + +--- linux-2.6.30.6/fs/squashfs/export.c ++++ linux-2.6.30.6/fs/squashfs/export.c +@@ -39,7 +39,6 @@ + #include + #include + #include +-#include + #include + + #include "squashfs_fs.h" + +--- linux-2.6.30.6/fs/squashfs/file.c ++++ linux-2.6.30.6/fs/squashfs/file.c +@@ -47,7 +47,6 @@ + #include + #include + #include +-#include + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" + +--- linux-2.6.30.6/fs/squashfs/fragment.c ++++ linux-2.6.30.6/fs/squashfs/fragment.c +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" + +--- linux-2.6.30.6/fs/squashfs/id.c ++++ linux-2.6.30.6/fs/squashfs/id.c +@@ -34,7 +34,6 @@ + #include + #include + #include +-#include + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" + +--- linux-2.6.30.6/fs/squashfs/inode.c ++++ linux-2.6.30.6/fs/squashfs/inode.c +@@ -40,7 +40,6 @@ + + #include + #include +-#include + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" + +--- linux-2.6.30.6/fs/squashfs/lzma_wrapper.c ++++ linux-2.6.30.6/fs/squashfs/lzma_wrapper.c +@@ -0,0 +1,151 @@ ++/* ++ * Squashfs - a compressed read only filesystem for Linux ++ * ++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 ++ * Phillip Lougher ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2, ++ * or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ * ++ * lzma_wrapper.c ++ */ ++ ++#include ++#include ++#include ++#include ++#include ++ ++#include "squashfs_fs.h" ++#include "squashfs_fs_sb.h" ++#include "squashfs_fs_i.h" ++#include "squashfs.h" ++#include "decompressor.h" ++ ++struct squashfs_lzma { ++ void *input; ++ void *output; ++}; ++ ++/* decompress_unlzma.c is currently non re-entrant... */ ++DEFINE_MUTEX(lzma_mutex); ++ ++/* decompress_unlzma.c doesn't provide any context in its callbacks... */ ++static int lzma_error; ++ ++static void error(char *m) ++{ ++ ERROR("unlzma error: %s\n", m); ++ lzma_error = 1; ++} ++ ++ ++static void *lzma_init(struct squashfs_sb_info *msblk) ++{ ++ struct squashfs_lzma *stream = kzalloc(sizeof(*stream), GFP_KERNEL); ++ if (stream == NULL) ++ goto failed; ++ stream->input = vmalloc(msblk->block_size); ++ if (stream->input == NULL) ++ goto failed; ++ stream->output = vmalloc(msblk->block_size); ++ if (stream->output == NULL) ++ goto failed2; ++ ++ return stream; ++ ++failed2: ++ vfree(stream->input); ++failed: ++ ERROR("failed to allocate lzma workspace\n"); ++ kfree(stream); ++ return NULL; ++} ++ ++ ++static void lzma_free(void *strm) ++{ ++ struct squashfs_lzma *stream = strm; ++ ++ if (stream) { ++ vfree(stream->input); ++ vfree(stream->output); ++ } ++ kfree(stream); ++} ++ ++ ++static int lzma_uncompress(struct squashfs_sb_info *msblk, void **buffer, ++ struct buffer_head **bh, int b, int offset, int length, int srclength, ++ int pages) ++{ ++ struct squashfs_lzma *stream = msblk->stream; ++ void *buff = stream->input; ++ int avail, i, bytes = length, res; ++ ++ mutex_lock(&lzma_mutex); ++ ++ for (i = 0; i < b; i++) { ++ wait_on_buffer(bh[i]); ++ if (!buffer_uptodate(bh[i])) ++ goto block_release; ++ ++ avail = min(bytes, msblk->devblksize - offset); ++ memcpy(buff, bh[i]->b_data + offset, avail); ++ buff += avail; ++ bytes -= avail; ++ offset = 0; ++ put_bh(bh[i]); ++ } ++ ++ lzma_error = 0; ++ res = unlzma(stream->input, length, NULL, NULL, stream->output, NULL, ++ error); ++ if (res || lzma_error) ++ goto failed; ++ ++ /* uncompressed size is stored in the LZMA header (5 byte offset) */ ++ res = bytes = get_unaligned_le32(stream->input + 5); ++ for (i = 0, buff = stream->output; bytes && i < pages; i++) { ++ avail = min_t(int, bytes, PAGE_CACHE_SIZE); ++ memcpy(buffer[i], buff, avail); ++ buff += avail; ++ bytes -= avail; ++ } ++ if (bytes) ++ goto failed; ++ ++ mutex_unlock(&lzma_mutex); ++ return res; ++ ++block_release: ++ for (; i < b; i++) ++ put_bh(bh[i]); ++ ++failed: ++ mutex_unlock(&lzma_mutex); ++ ++ ERROR("lzma decompression failed, data probably corrupt\n"); ++ return -EIO; ++} ++ ++const struct squashfs_decompressor squashfs_lzma_comp_ops = { ++ .init = lzma_init, ++ .free = lzma_free, ++ .decompress = lzma_uncompress, ++ .id = LZMA_COMPRESSION, ++ .name = "lzma", ++ .supported = 1 ++}; ++ + +--- linux-2.6.30.6/fs/squashfs/namei.c ++++ linux-2.6.30.6/fs/squashfs/namei.c +@@ -57,7 +57,6 @@ + #include + #include + #include +-#include + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" + +--- linux-2.6.30.6/fs/squashfs/squashfs.h ++++ linux-2.6.30.6/fs/squashfs/squashfs.h +@@ -51,6 +51,9 @@ + u64, int); + extern int squashfs_read_table(struct super_block *, void *, u64, int); + ++/* decompressor.c */ ++extern const struct squashfs_decompressor *squashfs_lookup_decompressor(int); ++ + /* export.c */ + extern __le64 *squashfs_read_inode_lookup_table(struct super_block *, u64, + unsigned int); +@@ -71,7 +74,7 @@ + extern int squashfs_read_inode(struct inode *, long long); + + /* +- * Inodes and files operations ++ * Inodes, files and decompressor operations + */ + + /* dir.c */ +@@ -88,3 +91,9 @@ + + /* symlink.c */ + extern const struct address_space_operations squashfs_symlink_aops; ++ ++/* zlib_wrapper.c */ ++extern const struct squashfs_decompressor squashfs_zlib_comp_ops; ++ ++/* lzma wrapper.c */ ++extern const struct squashfs_decompressor squashfs_lzma_comp_ops; + +--- linux-2.6.30.6/fs/squashfs/squashfs_fs.h ++++ linux-2.6.30.6/fs/squashfs/squashfs_fs.h +@@ -211,7 +211,9 @@ + /* + * definitions for structures on disk + */ +-#define ZLIB_COMPRESSION 1 ++#define ZLIB_COMPRESSION 1 ++#define LZMA_COMPRESSION 2 ++#define LZO_COMPRESSION 3 + + struct squashfs_super_block { + __le32 s_magic; + +--- linux-2.6.30.6/fs/squashfs/squashfs_fs_sb.h ++++ linux-2.6.30.6/fs/squashfs/squashfs_fs_sb.h +@@ -52,25 +52,26 @@ + }; + + struct squashfs_sb_info { +- int devblksize; +- int devblksize_log2; +- struct squashfs_cache *block_cache; +- struct squashfs_cache *fragment_cache; +- struct squashfs_cache *read_page; +- int next_meta_index; +- __le64 *id_table; +- __le64 *fragment_index; +- unsigned int *fragment_index_2; +- struct mutex read_data_mutex; +- struct mutex meta_index_mutex; +- struct meta_index *meta_index; +- z_stream stream; +- __le64 *inode_lookup_table; +- u64 inode_table; +- u64 directory_table; +- unsigned int block_size; +- unsigned short block_log; +- long long bytes_used; +- unsigned int inodes; ++ const struct squashfs_decompressor *decompressor; ++ int devblksize; ++ int devblksize_log2; ++ struct squashfs_cache *block_cache; ++ struct squashfs_cache *fragment_cache; ++ struct squashfs_cache *read_page; ++ int next_meta_index; ++ __le64 *id_table; ++ __le64 *fragment_index; ++ unsigned int *fragment_index_2; ++ struct mutex read_data_mutex; ++ struct mutex meta_index_mutex; ++ struct meta_index *meta_index; ++ void *stream; ++ __le64 *inode_lookup_table; ++ u64 inode_table; ++ u64 directory_table; ++ unsigned int block_size; ++ unsigned short block_log; ++ long long bytes_used; ++ unsigned int inodes; + }; + #endif + +--- linux-2.6.30.6/fs/squashfs/super.c ++++ linux-2.6.30.6/fs/squashfs/super.c +@@ -30,38 +30,46 @@ + #include + #include + #include ++#include + #include + #include + #include + #include +-#include + #include + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" + #include "squashfs_fs_i.h" + #include "squashfs.h" ++#include "decompressor.h" + + static struct file_system_type squashfs_fs_type; +-static struct super_operations squashfs_super_ops; ++static const struct super_operations squashfs_super_ops; + +-static int supported_squashfs_filesystem(short major, short minor, short comp) ++static const struct squashfs_decompressor *supported_squashfs_filesystem(short ++ major, short minor, short id) + { ++ const struct squashfs_decompressor *decompressor; ++ + if (major < SQUASHFS_MAJOR) { + ERROR("Major/Minor mismatch, older Squashfs %d.%d " + "filesystems are unsupported\n", major, minor); +- return -EINVAL; ++ return NULL; + } else if (major > SQUASHFS_MAJOR || minor > SQUASHFS_MINOR) { + ERROR("Major/Minor mismatch, trying to mount newer " + "%d.%d filesystem\n", major, minor); + ERROR("Please update your kernel\n"); +- return -EINVAL; ++ return NULL; + } + +- if (comp != ZLIB_COMPRESSION) +- return -EINVAL; ++ decompressor = squashfs_lookup_decompressor(id); ++ if (!decompressor->supported) { ++ ERROR("Filesystem uses \"%s\" compression. This is not " ++ "supported\n", decompressor->name); ++ return NULL; ++ } + +- return 0; ++ return decompressor; + } + + +@@ -86,13 +94,6 @@ + } + msblk = sb->s_fs_info; + +- msblk->stream.workspace = kmalloc(zlib_inflate_workspacesize(), +- GFP_KERNEL); +- if (msblk->stream.workspace == NULL) { +- ERROR("Failed to allocate zlib workspace\n"); +- goto failure; +- } +- + sblk = kzalloc(sizeof(*sblk), GFP_KERNEL); + if (sblk == NULL) { + ERROR("Failed to allocate squashfs_super_block\n"); +@@ -119,25 +120,25 @@ + goto failed_mount; + } + ++ err = -EINVAL; ++ + /* Check it is a SQUASHFS superblock */ + sb->s_magic = le32_to_cpu(sblk->s_magic); + if (sb->s_magic != SQUASHFS_MAGIC) { + if (!silent) + ERROR("Can't find a SQUASHFS superblock on %s\n", + bdevname(sb->s_bdev, b)); +- err = -EINVAL; + goto failed_mount; + } + +- /* Check the MAJOR & MINOR versions and compression type */ +- err = supported_squashfs_filesystem(le16_to_cpu(sblk->s_major), ++ /* Check the MAJOR & MINOR versions and lookup compression type */ ++ msblk->decompressor = supported_squashfs_filesystem( ++ le16_to_cpu(sblk->s_major), + le16_to_cpu(sblk->s_minor), + le16_to_cpu(sblk->compression)); +- if (err < 0) ++ if (msblk->decompressor == NULL) + goto failed_mount; + +- err = -EINVAL; +- + /* + * Check if there's xattrs in the filesystem. These are not + * supported in this version, so warn that they will be ignored. +@@ -204,6 +205,10 @@ + + err = -ENOMEM; + ++ msblk->stream = squashfs_decompressor_init(msblk); ++ if (msblk->stream == NULL) ++ goto failed_mount; ++ + msblk->block_cache = squashfs_cache_init("metadata", + SQUASHFS_CACHED_BLKS, SQUASHFS_METADATA_SIZE); + if (msblk->block_cache == NULL) +@@ -291,17 +296,16 @@ + squashfs_cache_delete(msblk->block_cache); + squashfs_cache_delete(msblk->fragment_cache); + squashfs_cache_delete(msblk->read_page); ++ squashfs_decompressor_free(msblk, msblk->stream); + kfree(msblk->inode_lookup_table); + kfree(msblk->fragment_index); + kfree(msblk->id_table); +- kfree(msblk->stream.workspace); + kfree(sb->s_fs_info); + sb->s_fs_info = NULL; + kfree(sblk); + return err; + + failure: +- kfree(msblk->stream.workspace); + kfree(sb->s_fs_info); + sb->s_fs_info = NULL; + return -ENOMEM; +@@ -338,18 +342,22 @@ + + static void squashfs_put_super(struct super_block *sb) + { ++ lock_kernel(); ++ + if (sb->s_fs_info) { + struct squashfs_sb_info *sbi = sb->s_fs_info; + squashfs_cache_delete(sbi->block_cache); + squashfs_cache_delete(sbi->fragment_cache); + squashfs_cache_delete(sbi->read_page); ++ squashfs_decompressor_free(sbi, sbi->stream); + kfree(sbi->id_table); + kfree(sbi->fragment_index); + kfree(sbi->meta_index); +- kfree(sbi->stream.workspace); + kfree(sb->s_fs_info); + sb->s_fs_info = NULL; + } ++ ++ unlock_kernel(); + } + + +@@ -439,7 +447,7 @@ + .fs_flags = FS_REQUIRES_DEV + }; + +-static struct super_operations squashfs_super_ops = { ++static const struct super_operations squashfs_super_ops = { + .alloc_inode = squashfs_alloc_inode, + .destroy_inode = squashfs_destroy_inode, + .statfs = squashfs_statfs, + +--- linux-2.6.30.6/fs/squashfs/symlink.c ++++ linux-2.6.30.6/fs/squashfs/symlink.c +@@ -36,7 +36,6 @@ + #include + #include + #include +-#include + + #include "squashfs_fs.h" + #include "squashfs_fs_sb.h" + +--- linux-2.6.30.6/fs/squashfs/zlib_wrapper.c ++++ linux-2.6.30.6/fs/squashfs/zlib_wrapper.c +@@ -0,0 +1,150 @@ ++/* ++ * Squashfs - a compressed read only filesystem for Linux ++ * ++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 ++ * Phillip Lougher ++ * ++ * This program is free software; you can redistribute it and/or ++ * modify it under the terms of the GNU General Public License ++ * as published by the Free Software Foundation; either version 2, ++ * or (at your option) any later version. ++ * ++ * This program is distributed in the hope that it will be useful, ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ++ * GNU General Public License for more details. ++ * ++ * You should have received a copy of the GNU General Public License ++ * along with this program; if not, write to the Free Software ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. ++ * ++ * zlib_wrapper.c ++ */ ++ ++ ++#include ++#include ++#include ++ ++#include "squashfs_fs.h" ++#include "squashfs_fs_sb.h" ++#include "squashfs_fs_i.h" ++#include "squashfs.h" ++#include "decompressor.h" ++ ++static void *zlib_init(struct squashfs_sb_info *dummy) ++{ ++ z_stream *stream = kmalloc(sizeof(z_stream), GFP_KERNEL); ++ if (stream == NULL) ++ goto failed; ++ stream->workspace = kmalloc(zlib_inflate_workspacesize(), ++ GFP_KERNEL); ++ if (stream->workspace == NULL) ++ goto failed; ++ ++ return stream; ++ ++failed: ++ ERROR("Failed to allocate zlib workspace\n"); ++ kfree(stream); ++ return NULL; ++} ++ ++ ++static void zlib_free(void *strm) ++{ ++ z_stream *stream = strm; ++ ++ if (stream) ++ kfree(stream->workspace); ++ kfree(stream); ++} ++ ++ ++static int zlib_uncompress(struct squashfs_sb_info *msblk, void **buffer, ++ struct buffer_head **bh, int b, int offset, int length, int srclength, ++ int pages) ++{ ++ int zlib_err = 0, zlib_init = 0; ++ int avail, bytes, k = 0, page = 0; ++ z_stream *stream = msblk->stream; ++ ++ mutex_lock(&msblk->read_data_mutex); ++ ++ stream->avail_out = 0; ++ stream->avail_in = 0; ++ ++ bytes = length; ++ do { ++ if (stream->avail_in == 0 && k < b) { ++ avail = min(bytes, msblk->devblksize - offset); ++ bytes -= avail; ++ wait_on_buffer(bh[k]); ++ if (!buffer_uptodate(bh[k])) ++ goto release_mutex; ++ ++ if (avail == 0) { ++ offset = 0; ++ put_bh(bh[k++]); ++ continue; ++ } ++ ++ stream->next_in = bh[k]->b_data + offset; ++ stream->avail_in = avail; ++ offset = 0; ++ } ++ ++ if (stream->avail_out == 0 && page < pages) { ++ stream->next_out = buffer[page++]; ++ stream->avail_out = PAGE_CACHE_SIZE; ++ } ++ ++ if (!zlib_init) { ++ zlib_err = zlib_inflateInit(stream); ++ if (zlib_err != Z_OK) { ++ ERROR("zlib_inflateInit returned unexpected " ++ "result 0x%x, srclength %d\n", ++ zlib_err, srclength); ++ goto release_mutex; ++ } ++ zlib_init = 1; ++ } ++ ++ zlib_err = zlib_inflate(stream, Z_SYNC_FLUSH); ++ ++ if (stream->avail_in == 0 && k < b) ++ put_bh(bh[k++]); ++ } while (zlib_err == Z_OK); ++ ++ if (zlib_err != Z_STREAM_END) { ++ ERROR("zlib_inflate error, data probably corrupt\n"); ++ goto release_mutex; ++ } ++ ++ zlib_err = zlib_inflateEnd(stream); ++ if (zlib_err != Z_OK) { ++ ERROR("zlib_inflate error, data probably corrupt\n"); ++ goto release_mutex; ++ } ++ ++ mutex_unlock(&msblk->read_data_mutex); ++ return stream->total_out; ++ ++release_mutex: ++ mutex_unlock(&msblk->read_data_mutex); ++ ++ for (; k < b; k++) ++ put_bh(bh[k]); ++ ++ return -EIO; ++} ++ ++const struct squashfs_decompressor squashfs_zlib_comp_ops = { ++ .init = zlib_init, ++ .free = zlib_free, ++ .decompress = zlib_uncompress, ++ .id = ZLIB_COMPRESSION, ++ .name = "zlib", ++ .supported = 1 ++}; ++ + +--- linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h ++++ linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h +@@ -0,0 +1,13 @@ ++#ifndef BUNZIP2_MM_H ++#define BUNZIP2_MM_H ++ ++#ifdef STATIC ++/* Code active when included from pre-boot environment: */ ++#define INIT ++#else ++/* Compile for initramfs/initrd code only */ ++#define INIT __init ++static void(*error)(char *m); ++#endif ++ ++#endif + +--- linux-2.6.30.6/include/linux/decompress/inflate_mm.h ++++ linux-2.6.30.6/include/linux/decompress/inflate_mm.h +@@ -0,0 +1,13 @@ ++#ifndef INFLATE_MM_H ++#define INFLATE_MM_H ++ ++#ifdef STATIC ++/* Code active when included from pre-boot environment: */ ++#define INIT ++#else ++/* Compile for initramfs/initrd code only */ ++#define INIT __init ++static void(*error)(char *m); ++#endif ++ ++#endif + +--- linux-2.6.30.6/include/linux/decompress/mm.h ++++ linux-2.6.30.6/include/linux/decompress/mm.h +@@ -25,7 +25,7 @@ + void *p; + + if (size < 0) +- error("Malloc error"); ++ return NULL; + if (!malloc_ptr) + malloc_ptr = free_mem_ptr; + +@@ -35,7 +35,7 @@ + malloc_ptr += size; + + if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr) +- error("Out of memory"); ++ return NULL; + + malloc_count++; + return p; +@@ -53,8 +53,6 @@ + + #define set_error_fn(x) + +-#define INIT +- + #else /* STATIC */ + + /* Code active when compiled standalone for use when loading ramdisk: */ +@@ -74,10 +72,8 @@ + #define large_malloc(a) vmalloc(a) + #define large_free(a) vfree(a) + +-static void(*error)(char *m); + #define set_error_fn(x) error = x; + +-#define INIT __init + #define STATIC + + #include + +--- linux-2.6.30.6/include/linux/decompress/unlzma_mm.h ++++ linux-2.6.30.6/include/linux/decompress/unlzma_mm.h +@@ -0,0 +1,20 @@ ++#ifndef UNLZMA_MM_H ++#define UNLZMA_MM_H ++ ++#ifdef STATIC ++ ++/* Code active when included from pre-boot environment: */ ++#define INIT ++ ++#elif defined(CONFIG_DECOMPRESS_LZMA_NEEDED) ++ ++/* Make it available to non initramfs/initrd code */ ++#define INIT ++#include ++#else ++ ++/* Compile for initramfs/initrd code only */ ++#define INIT __init ++#endif ++ ++#endif + +--- linux-2.6.30.6/lib/Kconfig ++++ linux-2.6.30.6/lib/Kconfig +@@ -10,6 +10,9 @@ + config BITREVERSE + tristate + ++config RATIONAL ++ boolean ++ + config GENERIC_FIND_FIRST_BIT + bool + +@@ -114,6 +117,9 @@ + config DECOMPRESS_LZMA + tristate + ++config DECOMPRESS_LZMA_NEEDED ++ boolean ++ + # + # Generic allocator support is selected if needed + # +@@ -153,6 +159,9 @@ + config TEXTSEARCH_FSM + tristate + ++config BTREE ++ boolean ++ + config HAS_IOMEM + boolean + depends on !NO_IOMEM +@@ -190,5 +199,35 @@ + # + config NLATTR + bool ++ ++# ++# Generic 64-bit atomic support is selected if needed ++# ++config GENERIC_ATOMIC64 ++ bool ++ ++config LRU_CACHE ++ tristate ++ ++config SHM_SIGNAL ++ tristate "SHM Signal - Generic shared-memory signaling mechanism" ++ default n ++ help ++ Provides a shared-memory based signaling mechanism to indicate ++ memory-dirty notifications between two end-points. ++ ++ If unsure, say N ++ ++config IOQ ++ tristate "IO-Queue library - Generic shared-memory queue" ++ select SHM_SIGNAL ++ default n ++ help ++ IOQ is a generic shared-memory-queue mechanism that happens to be ++ friendly to virtualization boundaries. It can be used in a variety ++ of ways, though its intended purpose is to become a low-level ++ communication path for paravirtualized drivers. ++ ++ If unsure, say N + + endmenu + +--- linux-2.6.30.6/lib/decompress_bunzip2.c ++++ linux-2.6.30.6/lib/decompress_bunzip2.c +@@ -45,12 +45,15 @@ + */ + + +-#ifndef STATIC ++#ifdef STATIC ++#define PREBOOT ++#else + #include +-#endif /* !STATIC */ ++#include ++#endif /* STATIC */ + ++#include + #include +-#include + + #ifndef INT_MAX + #define INT_MAX 0x7fffffff +@@ -297,7 +300,7 @@ + again when using them (during symbol decoding).*/ + base = hufGroup->base-1; + limit = hufGroup->limit-1; +- /* Calculate permute[]. Concurently, initialize ++ /* Calculate permute[]. Concurrently, initialize + * temp[] and limit[]. */ + pp = 0; + for (i = minLen; i <= maxLen; i++) { +@@ -635,6 +638,8 @@ + + /* Allocate bunzip_data. Most fields initialize to zero. */ + bd = *bdp = malloc(i); ++ if (!bd) ++ return RETVAL_OUT_OF_MEMORY; + memset(bd, 0, sizeof(struct bunzip_data)); + /* Setup input buffer */ + bd->inbuf = inbuf; +@@ -662,6 +667,8 @@ + bd->dbufSize = 100000*(i-BZh0); + + bd->dbuf = large_malloc(bd->dbufSize * sizeof(int)); ++ if (!bd->dbuf) ++ return RETVAL_OUT_OF_MEMORY; + return RETVAL_OK; + } + +@@ -681,12 +688,10 @@ + set_error_fn(error_fn); + if (flush) + outbuf = malloc(BZIP2_IOBUF_SIZE); +- else +- len -= 4; /* Uncompressed size hack active in pre-boot +- environment */ ++ + if (!outbuf) { + error("Could not allocate output bufer"); +- return -1; ++ return RETVAL_OUT_OF_MEMORY; + } + if (buf) + inbuf = buf; +@@ -694,6 +699,7 @@ + inbuf = malloc(BZIP2_IOBUF_SIZE); + if (!inbuf) { + error("Could not allocate input bufer"); ++ i = RETVAL_OUT_OF_MEMORY; + goto exit_0; + } + i = start_bunzip(&bd, inbuf, len, fill); +@@ -720,11 +726,14 @@ + } else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) { + error("Compressed file ends unexpectedly"); + } ++ if (!bd) ++ goto exit_1; + if (bd->dbuf) + large_free(bd->dbuf); + if (pos) + *pos = bd->inbufPos; + free(bd); ++exit_1: + if (!buf) + free(inbuf); + exit_0: +@@ -733,4 +742,14 @@ + return i; + } + +-#define decompress bunzip2 ++#ifdef PREBOOT ++STATIC int INIT decompress(unsigned char *buf, int len, ++ int(*fill)(void*, unsigned int), ++ int(*flush)(void*, unsigned int), ++ unsigned char *outbuf, ++ int *pos, ++ void(*error_fn)(char *x)) ++{ ++ return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error_fn); ++} ++#endif + +--- linux-2.6.30.6/lib/decompress_inflate.c ++++ linux-2.6.30.6/lib/decompress_inflate.c +@@ -19,14 +19,20 @@ + #include "zlib_inflate/inflate.h" + + #include "zlib_inflate/infutil.h" ++#include + + #endif /* STATIC */ + ++#include + #include +-#include + +-#define INBUF_LEN (16*1024) ++#define GZIP_IOBUF_SIZE (16*1024) + ++static int nofill(void *buffer, unsigned int len) ++{ ++ return -1; ++} ++ + /* Included from initramfs et al code */ + STATIC int INIT gunzip(unsigned char *buf, int len, + int(*fill)(void*, unsigned int), +@@ -55,7 +61,7 @@ + if (buf) + zbuf = buf; + else { +- zbuf = malloc(INBUF_LEN); ++ zbuf = malloc(GZIP_IOBUF_SIZE); + len = 0; + } + if (!zbuf) { +@@ -76,8 +82,11 @@ + goto gunzip_nomem4; + } + ++ if (!fill) ++ fill = nofill; ++ + if (len == 0) +- len = fill(zbuf, INBUF_LEN); ++ len = fill(zbuf, GZIP_IOBUF_SIZE); + + /* verify the gzip header */ + if (len < 10 || +@@ -113,7 +122,7 @@ + while (rc == Z_OK) { + if (strm->avail_in == 0) { + /* TODO: handle case where both pos and fill are set */ +- len = fill(zbuf, INBUF_LEN); ++ len = fill(zbuf, GZIP_IOBUF_SIZE); + if (len < 0) { + rc = -1; + error("read error"); + +--- linux-2.6.30.6/lib/decompress_unlzma.c ++++ linux-2.6.30.6/lib/decompress_unlzma.c +@@ -29,12 +29,15 @@ + *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA + */ + +-#ifndef STATIC ++#ifdef STATIC ++#define PREBOOT ++#else + #include ++#include + #endif /* STATIC */ + ++#include + #include +-#include + + #define MIN(a, b) (((a) < (b)) ? (a) : (b)) + +@@ -80,8 +83,13 @@ + #define RC_MODEL_TOTAL_BITS 11 + + ++static int nofill(void *buffer, unsigned int len) ++{ ++ return -1; ++} ++ + /* Called twice: once at startup and once in rc_normalize() */ +-static void INIT rc_read(struct rc *rc) ++static void INIT rc_read(struct rc *rc, void(*error)(char *x)) + { + rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE); + if (rc->buffer_size <= 0) +@@ -95,7 +103,10 @@ + int (*fill)(void*, unsigned int), + char *buffer, int buffer_size) + { +- rc->fill = fill; ++ if (fill) ++ rc->fill = fill; ++ else ++ rc->fill = nofill; + rc->buffer = (uint8_t *)buffer; + rc->buffer_size = buffer_size; + rc->buffer_end = rc->buffer + rc->buffer_size; +@@ -105,13 +116,13 @@ + rc->range = 0xFFFFFFFF; + } + +-static inline void INIT rc_init_code(struct rc *rc) ++static inline void INIT rc_init_code(struct rc *rc, void(*error)(char *x)) + { + int i; + + for (i = 0; i < 5; i++) { + if (rc->ptr >= rc->buffer_end) +- rc_read(rc); ++ rc_read(rc, error); + rc->code = (rc->code << 8) | *rc->ptr++; + } + } +@@ -124,32 +135,33 @@ + } + + /* Called twice, but one callsite is in inline'd rc_is_bit_0_helper() */ +-static void INIT rc_do_normalize(struct rc *rc) ++static void INIT rc_do_normalize(struct rc *rc, void(*error)(char *x)) + { + if (rc->ptr >= rc->buffer_end) +- rc_read(rc); ++ rc_read(rc, error); + rc->range <<= 8; + rc->code = (rc->code << 8) | *rc->ptr++; + } +-static inline void INIT rc_normalize(struct rc *rc) ++static inline void INIT rc_normalize(struct rc *rc, void(*error)(char *x)) + { + if (rc->range < (1 << RC_TOP_BITS)) +- rc_do_normalize(rc); ++ rc_do_normalize(rc, error); + } + + /* Called 9 times */ + /* Why rc_is_bit_0_helper exists? + *Because we want to always expose (rc->code < rc->bound) to optimizer + */ +-static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p) ++static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p, ++ void (*error)(char *x)) + { +- rc_normalize(rc); ++ rc_normalize(rc, error); + rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS); + return rc->bound; + } +-static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p) ++static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p, void(*error)(char *x)) + { +- uint32_t t = rc_is_bit_0_helper(rc, p); ++ uint32_t t = rc_is_bit_0_helper(rc, p, error); + return rc->code < t; + } + +@@ -167,9 +179,9 @@ + } + + /* Called 4 times in unlzma loop */ +-static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol) ++static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol, void(*error)(char *x)) + { +- if (rc_is_bit_0(rc, p)) { ++ if (rc_is_bit_0(rc, p, error)) { + rc_update_bit_0(rc, p); + *symbol *= 2; + return 0; +@@ -181,9 +193,9 @@ + } + + /* Called once */ +-static inline int INIT rc_direct_bit(struct rc *rc) ++static inline int INIT rc_direct_bit(struct rc *rc , void(*error)(char *x)) + { +- rc_normalize(rc); ++ rc_normalize(rc, error); + rc->range >>= 1; + if (rc->code >= rc->range) { + rc->code -= rc->range; +@@ -194,13 +206,14 @@ + + /* Called twice */ + static inline void INIT +-rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol) ++rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol, ++ void(*error)(char *x)) + { + int i = num_levels; + + *symbol = 1; + while (i--) +- rc_get_bit(rc, p + *symbol, symbol); ++ rc_get_bit(rc, p + *symbol, symbol, error); + *symbol -= 1 << num_levels; + } + +@@ -278,10 +291,6 @@ + size_t global_pos; + int(*flush)(void*, unsigned int); + struct lzma_header *header; +- int is_cpio_flush; +- uint8_t **buffer_index; +- int next_index; +- int max_index; + }; + + struct cstate { +@@ -298,14 +307,6 @@ + static inline uint8_t INIT peek_old_byte(struct writer *wr, + uint32_t offs) + { +- if (wr->is_cpio_flush) { +- int32_t pos; +- while (offs > wr->header->dict_size) +- offs -= wr->header->dict_size; +- pos = wr->buffer_pos - offs; +- return wr->buffer_index[pos / LZMA_IOBUF_SIZE] +- [pos % LZMA_IOBUF_SIZE]; +- } + if (!wr->flush) { + int32_t pos; + while (offs > wr->header->dict_size) +@@ -321,41 +322,8 @@ + + } + +-static inline void INIT write_byte_if_cpio(struct writer *wr, uint8_t byte) +-{ +- if (wr->buffer_pos % LZMA_IOBUF_SIZE == 0) { +- // if the following large_malloc fails, the initramfs +- // whould not be load with is_cpio_flush forced 0 too. +- // Remember we do not allocate historic buffer. +- // Let's assume it will never fail ! +- if (wr->next_index >= wr->max_index) { +- // realloc wr->buffer_index +- uint8_t **p = wr->buffer_index; +- wr->buffer_index = (uint8_t **) +- large_malloc(LZMA_IOBUF_SIZE + +- sizeof(*p) * wr->max_index); +- if (wr->max_index) { +- memcpy(wr->buffer_index, p, +- sizeof(*p) * wr->max_index); +- free(p); +- } +- wr->max_index += LZMA_IOBUF_SIZE / sizeof(*p); +- } +- wr->buffer_index[wr->next_index++] = +- (uint8_t *) large_malloc(LZMA_IOBUF_SIZE); +- } +- wr->buffer_index[wr->buffer_pos / LZMA_IOBUF_SIZE] +- [wr->buffer_pos % LZMA_IOBUF_SIZE] = +- wr->previous_byte = byte; +- wr->buffer_pos++; +-} +- + static inline void INIT write_byte(struct writer *wr, uint8_t byte) + { +- if (wr->is_cpio_flush) { +- write_byte_if_cpio(wr, byte); +- return; +- } + wr->buffer[wr->buffer_pos++] = wr->previous_byte = byte; + if (wr->flush && wr->buffer_pos == wr->header->dict_size) { + wr->buffer_pos = 0; +@@ -373,21 +341,7 @@ + static inline void INIT copy_bytes(struct writer *wr, + uint32_t rep0, int len) + { +- if (wr->is_cpio_flush) { +- int32_t pos; +- uint32_t offs = rep0; +- while (offs > wr->header->dict_size) +- offs -= wr->header->dict_size; +- pos = wr->buffer_pos - offs; +- do { +- write_byte_if_cpio(wr, +- wr->buffer_index[pos / LZMA_IOBUF_SIZE] +- [pos % LZMA_IOBUF_SIZE]); +- pos++; +- len--; +- } while (len != 0 && wr->buffer_pos < wr->header->dst_size); +- } +- else do { ++ do { + copy_byte(wr, rep0); + len--; + } while (len != 0 && wr->buffer_pos < wr->header->dst_size); +@@ -396,11 +350,9 @@ + static inline void INIT process_bit0(struct writer *wr, struct rc *rc, + struct cstate *cst, uint16_t *p, + int pos_state, uint16_t *prob, +- int lc, uint32_t literal_pos_mask) { ++ int lc, uint32_t literal_pos_mask, ++ void(*error)(char *x)) { + int mi = 1; +- static const int state[LZMA_NUM_STATES] = +- { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 }; +- + rc_update_bit_0(rc, prob); + prob = (p + LZMA_LITERAL + + (LZMA_LIT_SIZE +@@ -417,7 +369,7 @@ + match_byte <<= 1; + bit = match_byte & 0x100; + prob_lit = prob + 0x100 + bit + mi; +- if (rc_get_bit(rc, prob_lit, &mi)) { ++ if (rc_get_bit(rc, prob_lit, &mi, error)) { + if (!bit) + break; + } else { +@@ -428,23 +380,29 @@ + } + while (mi < 0x100) { + uint16_t *prob_lit = prob + mi; +- rc_get_bit(rc, prob_lit, &mi); ++ rc_get_bit(rc, prob_lit, &mi, error); + } + write_byte(wr, mi); +- cst->state = state[cst->state]; ++ if (cst->state < 4) ++ cst->state = 0; ++ else if (cst->state < 10) ++ cst->state -= 3; ++ else ++ cst->state -= 6; + } + + static inline void INIT process_bit1(struct writer *wr, struct rc *rc, + struct cstate *cst, uint16_t *p, +- int pos_state, uint16_t *prob) { +- int offset; ++ int pos_state, uint16_t *prob, ++ void(*error)(char *x)) { ++ int offset; + uint16_t *prob_len; + int num_bits; + int len; + + rc_update_bit_1(rc, prob); + prob = p + LZMA_IS_REP + cst->state; +- if (rc_is_bit_0(rc, prob)) { ++ if (rc_is_bit_0(rc, prob, error)) { + rc_update_bit_0(rc, prob); + cst->rep3 = cst->rep2; + cst->rep2 = cst->rep1; +@@ -453,14 +411,14 @@ + prob = p + LZMA_LEN_CODER; + } else { + rc_update_bit_1(rc, prob); +- prob += LZMA_IS_REP_G0 - LZMA_IS_REP; +- if (rc_is_bit_0(rc, prob)) { ++ prob = p + LZMA_IS_REP_G0 + cst->state; ++ if (rc_is_bit_0(rc, prob, error)) { + rc_update_bit_0(rc, prob); + prob = (p + LZMA_IS_REP_0_LONG + + (cst->state << + LZMA_NUM_POS_BITS_MAX) + + pos_state); +- if (rc_is_bit_0(rc, prob)) { ++ if (rc_is_bit_0(rc, prob, error)) { + rc_update_bit_0(rc, prob); + + cst->state = cst->state < LZMA_NUM_LIT_STATES ? +@@ -474,14 +432,14 @@ + uint32_t distance; + + rc_update_bit_1(rc, prob); +- prob += LZMA_IS_REP_G1 - LZMA_IS_REP_G0; +- if (rc_is_bit_0(rc, prob)) { ++ prob = p + LZMA_IS_REP_G1 + cst->state; ++ if (rc_is_bit_0(rc, prob, error)) { + rc_update_bit_0(rc, prob); + distance = cst->rep1; + } else { + rc_update_bit_1(rc, prob); +- prob += LZMA_IS_REP_G2 - LZMA_IS_REP_G1; +- if (rc_is_bit_0(rc, prob)) { ++ prob = p + LZMA_IS_REP_G2 + cst->state; ++ if (rc_is_bit_0(rc, prob, error)) { + rc_update_bit_0(rc, prob); + distance = cst->rep2; + } else { +@@ -499,33 +457,33 @@ + } + + prob_len = prob + LZMA_LEN_CHOICE; +- if (rc_is_bit_0(rc, prob_len)) { ++ if (rc_is_bit_0(rc, prob_len, error)) { + rc_update_bit_0(rc, prob_len); +- prob_len += LZMA_LEN_LOW - LZMA_LEN_CHOICE ++ prob_len = (prob + LZMA_LEN_LOW + + (pos_state << +- LZMA_LEN_NUM_LOW_BITS); ++ LZMA_LEN_NUM_LOW_BITS)); + offset = 0; + num_bits = LZMA_LEN_NUM_LOW_BITS; + } else { + rc_update_bit_1(rc, prob_len); +- prob_len += LZMA_LEN_CHOICE_2 - LZMA_LEN_CHOICE; +- if (rc_is_bit_0(rc, prob_len)) { ++ prob_len = prob + LZMA_LEN_CHOICE_2; ++ if (rc_is_bit_0(rc, prob_len, error)) { + rc_update_bit_0(rc, prob_len); +- prob_len += LZMA_LEN_MID - LZMA_LEN_CHOICE_2 ++ prob_len = (prob + LZMA_LEN_MID + + (pos_state << +- LZMA_LEN_NUM_MID_BITS); ++ LZMA_LEN_NUM_MID_BITS)); + offset = 1 << LZMA_LEN_NUM_LOW_BITS; + num_bits = LZMA_LEN_NUM_MID_BITS; + } else { + rc_update_bit_1(rc, prob_len); +- prob_len += LZMA_LEN_HIGH - LZMA_LEN_CHOICE_2; ++ prob_len = prob + LZMA_LEN_HIGH; + offset = ((1 << LZMA_LEN_NUM_LOW_BITS) + + (1 << LZMA_LEN_NUM_MID_BITS)); + num_bits = LZMA_LEN_NUM_HIGH_BITS; + } + } + +- rc_bit_tree_decode(rc, prob_len, num_bits, &len); ++ rc_bit_tree_decode(rc, prob_len, num_bits, &len, error); + len += offset; + + if (cst->state < 4) { +@@ -540,7 +498,7 @@ + << LZMA_NUM_POS_SLOT_BITS); + rc_bit_tree_decode(rc, prob, + LZMA_NUM_POS_SLOT_BITS, +- &pos_slot); ++ &pos_slot, error); + if (pos_slot >= LZMA_START_POS_MODEL_INDEX) { + int i, mi; + num_bits = (pos_slot >> 1) - 1; +@@ -553,7 +511,7 @@ + num_bits -= LZMA_NUM_ALIGN_BITS; + while (num_bits--) + cst->rep0 = (cst->rep0 << 1) | +- rc_direct_bit(rc); ++ rc_direct_bit(rc, error); + prob = p + LZMA_ALIGN; + cst->rep0 <<= LZMA_NUM_ALIGN_BITS; + num_bits = LZMA_NUM_ALIGN_BITS; +@@ -561,7 +519,7 @@ + i = 1; + mi = 1; + while (num_bits--) { +- if (rc_get_bit(rc, prob + mi, &mi)) ++ if (rc_get_bit(rc, prob + mi, &mi, error)) + cst->rep0 |= i; + i <<= 1; + } +@@ -578,15 +536,14 @@ + + + +-STATIC inline int INIT unlzma(unsigned char *buf, int in_len, ++STATIC int INIT unlzma(unsigned char *buf, int in_len, + int(*fill)(void*, unsigned int), + int(*flush)(void*, unsigned int), + unsigned char *output, + int *posp, +- void(*error_fn)(char *x) ++ void(*error)(char *x) + ) + { +- extern int cpio_flush_buffer(void*, unsigned int); + struct lzma_header header; + int lc, pb, lp; + uint32_t pos_state_mask; +@@ -600,10 +557,6 @@ + unsigned char *inbuf; + int ret = -1; + +- set_error_fn(error_fn); +- if (!flush) +- in_len -= 4; /* Uncompressed size hack active in pre-boot +- environment */ + if (buf) + inbuf = buf; + else +@@ -621,16 +574,12 @@ + wr.global_pos = 0; + wr.previous_byte = 0; + wr.buffer_pos = 0; +- wr.is_cpio_flush = 0; +- if (flush == cpio_flush_buffer) +- wr.is_cpio_flush = 1; +- wr.buffer_index = NULL; + + rc_init(&rc, fill, inbuf, in_len); + + for (i = 0; i < sizeof(header); i++) { + if (rc.ptr >= rc.buffer_end) +- rc_read(&rc); ++ rc_read(&rc, error); + ((unsigned char *)&header)[i] = *rc.ptr++; + } + +@@ -658,34 +607,34 @@ + if (header.dict_size == 0) + header.dict_size = 1; + +- if (output || wr.is_cpio_flush) ++ if (output) + wr.buffer = output; + else { + wr.bufsize = MIN(header.dst_size, header.dict_size); + wr.buffer = large_malloc(wr.bufsize); + } +- if (wr.buffer == NULL && !wr.is_cpio_flush) ++ if (wr.buffer == NULL) + goto exit_1; + + num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)); + p = (uint16_t *) large_malloc(num_probs * sizeof(*p)); + if (p == 0) + goto exit_2; +- num_probs += LZMA_LITERAL - LZMA_BASE_SIZE; ++ num_probs = LZMA_LITERAL + (LZMA_LIT_SIZE << (lc + lp)); + for (i = 0; i < num_probs; i++) + p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1; +- wr.max_index = wr.next_index = 0; +- rc_init_code(&rc); + ++ rc_init_code(&rc, error); ++ + while (get_pos(&wr) < header.dst_size) { + int pos_state = get_pos(&wr) & pos_state_mask; + uint16_t *prob = p + LZMA_IS_MATCH + + (cst.state << LZMA_NUM_POS_BITS_MAX) + pos_state; +- if (rc_is_bit_0(&rc, prob)) ++ if (rc_is_bit_0(&rc, prob, error)) + process_bit0(&wr, &rc, &cst, p, pos_state, prob, +- lc, literal_pos_mask); ++ lc, literal_pos_mask, error); + else { +- process_bit1(&wr, &rc, &cst, p, pos_state, prob); ++ process_bit1(&wr, &rc, &cst, p, pos_state, prob, error); + if (cst.rep0 == 0) + break; + } +@@ -693,25 +642,12 @@ + + if (posp) + *posp = rc.ptr-rc.buffer; +- if (wr.is_cpio_flush) { +- int i; +- for (i = 0; i < wr.next_index -1; i++) { +- wr.flush(wr.buffer_index[i], LZMA_IOBUF_SIZE); +- large_free(wr.buffer_index[i]); +- } +- if (i < wr.next_index) { +- wr.flush(wr.buffer_index[i], +- wr.buffer_pos % LZMA_IOBUF_SIZE); +- large_free(wr.buffer_index[i]); +- } +- large_free(wr.buffer_index); +- } +- else if (wr.flush) ++ if (wr.flush) + wr.flush(wr.buffer, wr.buffer_pos); + ret = 0; + large_free(p); + exit_2: +- if (!output && !wr.is_cpio_flush) ++ if (!output) + large_free(wr.buffer); + exit_1: + if (!buf) +@@ -719,5 +655,19 @@ + exit_0: + return ret; + } ++#if defined(CONFIG_DECOMPRESS_LZMA_NEEDED) && !defined(PREBOOT) ++EXPORT_SYMBOL(unlzma); ++#endif + +-#define decompress unlzma ++#ifdef PREBOOT ++STATIC int INIT decompress(unsigned char *buf, int in_len, ++ int(*fill)(void*, unsigned int), ++ int(*flush)(void*, unsigned int), ++ unsigned char *output, ++ int *posp, ++ void(*error_fn)(char *x) ++ ) ++{ ++ return unlzma(buf, in_len - 4, fill, flush, output, posp, error_fn); ++} ++#endif diff -r 4911917bb50f -r 0c0c693fe4c6 tazndis/receipt --- a/tazndis/receipt Sat Jan 02 14:50:04 2010 +0100 +++ b/tazndis/receipt Sun Jan 03 17:41:36 2010 +0100 @@ -6,7 +6,6 @@ SHORT_DESC="ndiswrapper replacement for SliTaz with a GUI" MAINTAINER="erjo@slitaz.org" DEPENDS="perl-core wireless_tools ndiswrapper-driver" -TARBALL="$PACKAGE-$VERSION.tar.gz" WEB_SITE="http://www.slitaz.org" # Rules to gen a SliTaz package suitable for Tazpkg. diff -r 4911917bb50f -r 0c0c693fe4c6 xfce4/receipt --- a/xfce4/receipt Sat Jan 02 14:50:04 2010 +0100 +++ b/xfce4/receipt Sun Jan 03 17:41:36 2010 +0100 @@ -8,7 +8,6 @@ DEPENDS="libxfce4util xfconf libxfcegui4 libxfce4menu libexo xfce4-panel thunar xfce4-settings xfce4-session xfwm4 xfdesktop thunar-volman thunar-archive-plugin xfce-utils xfce4-slitaz-config" -TARBALL="$PACKAGE-$VERSION.tar.gz" WEB_SITE="http://www.xfce.org" # Rules to gen a SliTaz package suitable for Tazpkg.