wok-6.x rev 4701
linux/squashfs: add lzma support
author | Pascal Bellard <pascal.bellard@slitaz.org> |
---|---|
date | Sun Jan 03 17:41:36 2010 +0100 (2010-01-03) |
parents | 4911917bb50f |
children | 7b34aa2dd3aa |
files | dahdi/receipt linux/receipt linux/stuff/linux-2.6.30.6-slitaz.config linux/stuff/linux-squashfs-lzma-2.6.30.6.u tazndis/receipt xfce4/receipt |
line diff
1.1 --- a/dahdi/receipt Sat Jan 02 14:50:04 2010 +0100 1.2 +++ b/dahdi/receipt Sun Jan 03 17:41:36 2010 +0100 1.3 @@ -5,7 +5,6 @@ 1.4 CATEGORY="meta" 1.5 SHORT_DESC="Digium Asterisk Hardware Device Interface." 1.6 MAINTAINER="pascal.bellard@slitaz.org" 1.7 -TARBALL="$PACKAGE-$VERSION.tar.gz" 1.8 WEB_SITE="http://www.asterisk.org/" 1.9 DEPENDS="dahdi-linux dahdi-tools" 1.10 PROVIDE="zaptel"
2.1 --- a/linux/receipt Sat Jan 02 14:50:04 2010 +0100 2.2 +++ b/linux/receipt Sun Jan 03 17:41:36 2010 +0100 2.3 @@ -51,6 +51,7 @@ 2.4 aufs2-kbuild.patch 2.5 aufs2-standalone.patch 2.6 $PACKAGE-header-$VERSION.u 2.7 +$PACKAGE-squashfs-lzma-$VERSION.u 2.8 EOT 2.9 make mrproper 2.10 cd Documentation/lguest
3.1 --- a/linux/stuff/linux-2.6.30.6-slitaz.config Sat Jan 02 14:50:04 2010 +0100 3.2 +++ b/linux/stuff/linux-2.6.30.6-slitaz.config Sun Jan 03 17:41:36 2010 +0100 3.3 @@ -1,7 +1,7 @@ 3.4 # 3.5 # Automatically generated make config: don't edit 3.6 # Linux kernel version: 2.6.30.6 3.7 -# Mon Nov 30 12:43:49 2009 3.8 +# Sun Jan 3 17:28:53 2010 3.9 # 3.10 # CONFIG_64BIT is not set 3.11 CONFIG_X86_32=y 3.12 @@ -2149,7 +2149,7 @@ 3.13 CONFIG_VIDEO_V4L2_COMMON=m 3.14 CONFIG_VIDEO_ALLOW_V4L1=y 3.15 CONFIG_VIDEO_V4L1_COMPAT=y 3.16 -# CONFIG_DVB_CORE is not set 3.17 +CONFIG_DVB_CORE=m 3.18 CONFIG_VIDEO_MEDIA=m 3.19 3.20 # 3.21 @@ -2192,7 +2192,10 @@ 3.22 # CONFIG_VIDEO_HEXIUM_ORION is not set 3.23 # CONFIG_VIDEO_HEXIUM_GEMINI is not set 3.24 # CONFIG_VIDEO_CX88 is not set 3.25 +# CONFIG_VIDEO_CX23885 is not set 3.26 +# CONFIG_VIDEO_AU0828 is not set 3.27 # CONFIG_VIDEO_IVTV is not set 3.28 +# CONFIG_VIDEO_CX18 is not set 3.29 # CONFIG_VIDEO_CAFE_CCIC is not set 3.30 CONFIG_SOC_CAMERA=m 3.31 # CONFIG_SOC_CAMERA_MT9M001 is not set 3.32 @@ -2273,8 +2276,54 @@ 3.33 # CONFIG_USB_SI470X is not set 3.34 # CONFIG_USB_MR800 is not set 3.35 # CONFIG_RADIO_TEA5764 is not set 3.36 +# CONFIG_DVB_DYNAMIC_MINORS is not set 3.37 +CONFIG_DVB_CAPTURE_DRIVERS=y 3.38 + 3.39 +# 3.40 +# Supported SAA7146 based PCI Adapters 3.41 +# 3.42 +# CONFIG_TTPCI_EEPROM is not set 3.43 +# CONFIG_DVB_AV7110 is not set 3.44 +# CONFIG_DVB_BUDGET_CORE is not set 3.45 + 3.46 +# 3.47 +# Supported USB Adapters 3.48 +# 3.49 +# CONFIG_DVB_USB is not set 3.50 +# CONFIG_DVB_TTUSB_BUDGET is not set 3.51 +# CONFIG_DVB_TTUSB_DEC is not set 3.52 +# CONFIG_DVB_SIANO_SMS1XXX is not set 3.53 + 3.54 +# 3.55 +# Supported FlexCopII (B2C2) Adapters 3.56 +# 3.57 +# CONFIG_DVB_B2C2_FLEXCOP is not set 3.58 + 3.59 +# 3.60 +# Supported BT878 Adapters 3.61 +# 3.62 + 3.63 +# 3.64 +# Supported Pluto2 Adapters 3.65 +# 3.66 +# CONFIG_DVB_PLUTO2 is not set 3.67 + 3.68 +# 3.69 +# Supported SDMC DM1105 Adapters 3.70 +# 3.71 +# CONFIG_DVB_DM1105 is not set 3.72 + 3.73 +# 3.74 +# Supported FireWire (IEEE 1394) Adapters 3.75 +# 3.76 +# CONFIG_DVB_FIREDTV is not set 3.77 + 3.78 +# 3.79 +# Supported DVB Frontends 3.80 +# 3.81 +# CONFIG_DVB_FE_CUSTOMISE is not set 3.82 CONFIG_DAB=y 3.83 -# CONFIG_USB_DABUSB is not set 3.84 +CONFIG_USB_DABUSB=m 3.85 3.86 # 3.87 # Graphics support 3.88 @@ -2518,7 +2567,8 @@ 3.89 CONFIG_SND_FM801_TEA575X_BOOL=y 3.90 CONFIG_SND_FM801_TEA575X=m 3.91 CONFIG_SND_HDA_INTEL=m 3.92 -# CONFIG_SND_HDA_HWDEP is not set 3.93 +CONFIG_SND_HDA_HWDEP=y 3.94 +# CONFIG_SND_HDA_RECONFIG is not set 3.95 # CONFIG_SND_HDA_INPUT_BEEP is not set 3.96 CONFIG_SND_HDA_CODEC_REALTEK=y 3.97 CONFIG_SND_HDA_CODEC_ANALOG=y 3.98 @@ -2533,7 +2583,7 @@ 3.99 CONFIG_SND_HDA_CODEC_SI3054=y 3.100 CONFIG_SND_HDA_GENERIC=y 3.101 CONFIG_SND_HDA_POWER_SAVE=y 3.102 -CONFIG_SND_HDA_POWER_SAVE_DEFAULT=5 3.103 +CONFIG_SND_HDA_POWER_SAVE_DEFAULT=60 3.104 CONFIG_SND_HDSP=m 3.105 CONFIG_SND_HDSPM=m 3.106 CONFIG_SND_HIFIER=m 3.107 @@ -3026,6 +3076,7 @@ 3.108 # CONFIG_EFS_FS is not set 3.109 CONFIG_CRAMFS=m 3.110 CONFIG_SQUASHFS=m 3.111 +CONFIG_SQUASHFS_LZMA=y 3.112 # CONFIG_SQUASHFS_EMBEDDED is not set 3.113 CONFIG_SQUASHFS_FRAGMENT_CACHE_SIZE=3 3.114 # CONFIG_VXFS_FS is not set 3.115 @@ -3369,6 +3420,7 @@ 3.116 CONFIG_DECOMPRESS_GZIP=y 3.117 CONFIG_DECOMPRESS_BZIP2=y 3.118 CONFIG_DECOMPRESS_LZMA=y 3.119 +CONFIG_DECOMPRESS_LZMA_NEEDED=y 3.120 CONFIG_TEXTSEARCH=y 3.121 CONFIG_TEXTSEARCH_KMP=m 3.122 CONFIG_TEXTSEARCH_BM=m 3.123 @@ -3377,3 +3429,5 @@ 3.124 CONFIG_HAS_IOPORT=y 3.125 CONFIG_HAS_DMA=y 3.126 CONFIG_NLATTR=y 3.127 +# CONFIG_SHM_SIGNAL is not set 3.128 +# CONFIG_IOQ is not set
4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 4.2 +++ b/linux/stuff/linux-squashfs-lzma-2.6.30.6.u Sun Jan 03 17:41:36 2010 +0100 4.3 @@ -0,0 +1,1808 @@ 4.4 +--- linux-2.6.30.6/fs/squashfs/Kconfig 4.5 ++++ linux-2.6.30.6/fs/squashfs/Kconfig 4.6 +@@ -26,6 +26,12 @@ 4.7 + 4.8 + If unsure, say N. 4.9 + 4.10 ++config SQUASHFS_LZMA 4.11 ++ bool "Include support for LZMA compressed file systems" 4.12 ++ depends on SQUASHFS 4.13 ++ select DECOMPRESS_LZMA 4.14 ++ select DECOMPRESS_LZMA_NEEDED 4.15 ++ 4.16 + config SQUASHFS_EMBEDDED 4.17 + 4.18 + bool "Additional option for memory-constrained systems" 4.19 + 4.20 +--- linux-2.6.30.6/fs/squashfs/Makefile 4.21 ++++ linux-2.6.30.6/fs/squashfs/Makefile 4.22 +@@ -4,4 +4,5 @@ 4.23 + 4.24 + obj-$(CONFIG_SQUASHFS) += squashfs.o 4.25 + squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o 4.26 +-squashfs-y += namei.o super.o symlink.o 4.27 ++squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o 4.28 ++squashfs-$(CONFIG_SQUASHFS_LZMA) += lzma_wrapper.o 4.29 + 4.30 +--- linux-2.6.30.6/fs/squashfs/block.c 4.31 ++++ linux-2.6.30.6/fs/squashfs/block.c 4.32 +@@ -29,15 +29,14 @@ 4.33 + #include <linux/fs.h> 4.34 + #include <linux/vfs.h> 4.35 + #include <linux/slab.h> 4.36 +-#include <linux/mutex.h> 4.37 + #include <linux/string.h> 4.38 + #include <linux/buffer_head.h> 4.39 +-#include <linux/zlib.h> 4.40 + 4.41 + #include "squashfs_fs.h" 4.42 + #include "squashfs_fs_sb.h" 4.43 + #include "squashfs_fs_i.h" 4.44 + #include "squashfs.h" 4.45 ++#include "decompressor.h" 4.46 + 4.47 + /* 4.48 + * Read the metadata block length, this is stored in the first two 4.49 +@@ -153,72 +152,10 @@ 4.50 + } 4.51 + 4.52 + if (compressed) { 4.53 +- int zlib_err = 0, zlib_init = 0; 4.54 +- 4.55 +- /* 4.56 +- * Uncompress block. 4.57 +- */ 4.58 +- 4.59 +- mutex_lock(&msblk->read_data_mutex); 4.60 +- 4.61 +- msblk->stream.avail_out = 0; 4.62 +- msblk->stream.avail_in = 0; 4.63 +- 4.64 +- bytes = length; 4.65 +- do { 4.66 +- if (msblk->stream.avail_in == 0 && k < b) { 4.67 +- avail = min(bytes, msblk->devblksize - offset); 4.68 +- bytes -= avail; 4.69 +- wait_on_buffer(bh[k]); 4.70 +- if (!buffer_uptodate(bh[k])) 4.71 +- goto release_mutex; 4.72 +- 4.73 +- if (avail == 0) { 4.74 +- offset = 0; 4.75 +- put_bh(bh[k++]); 4.76 +- continue; 4.77 +- } 4.78 +- 4.79 +- msblk->stream.next_in = bh[k]->b_data + offset; 4.80 +- msblk->stream.avail_in = avail; 4.81 +- offset = 0; 4.82 +- } 4.83 +- 4.84 +- if (msblk->stream.avail_out == 0 && page < pages) { 4.85 +- msblk->stream.next_out = buffer[page++]; 4.86 +- msblk->stream.avail_out = PAGE_CACHE_SIZE; 4.87 +- } 4.88 +- 4.89 +- if (!zlib_init) { 4.90 +- zlib_err = zlib_inflateInit(&msblk->stream); 4.91 +- if (zlib_err != Z_OK) { 4.92 +- ERROR("zlib_inflateInit returned" 4.93 +- " unexpected result 0x%x," 4.94 +- " srclength %d\n", zlib_err, 4.95 +- srclength); 4.96 +- goto release_mutex; 4.97 +- } 4.98 +- zlib_init = 1; 4.99 +- } 4.100 +- 4.101 +- zlib_err = zlib_inflate(&msblk->stream, Z_SYNC_FLUSH); 4.102 +- 4.103 +- if (msblk->stream.avail_in == 0 && k < b) 4.104 +- put_bh(bh[k++]); 4.105 +- } while (zlib_err == Z_OK); 4.106 +- 4.107 +- if (zlib_err != Z_STREAM_END) { 4.108 +- ERROR("zlib_inflate error, data probably corrupt\n"); 4.109 +- goto release_mutex; 4.110 +- } 4.111 +- 4.112 +- zlib_err = zlib_inflateEnd(&msblk->stream); 4.113 +- if (zlib_err != Z_OK) { 4.114 +- ERROR("zlib_inflate error, data probably corrupt\n"); 4.115 +- goto release_mutex; 4.116 +- } 4.117 +- length = msblk->stream.total_out; 4.118 +- mutex_unlock(&msblk->read_data_mutex); 4.119 ++ length = squashfs_decompress(msblk, buffer, bh, b, offset, 4.120 ++ length, srclength, pages); 4.121 ++ if (length < 0) 4.122 ++ goto read_failure; 4.123 + } else { 4.124 + /* 4.125 + * Block is uncompressed. 4.126 +@@ -254,9 +191,6 @@ 4.127 + 4.128 + kfree(bh); 4.129 + return length; 4.130 +- 4.131 +-release_mutex: 4.132 +- mutex_unlock(&msblk->read_data_mutex); 4.133 + 4.134 + block_release: 4.135 + for (; k < b; k++) 4.136 + 4.137 +--- linux-2.6.30.6/fs/squashfs/cache.c 4.138 ++++ linux-2.6.30.6/fs/squashfs/cache.c 4.139 +@@ -51,7 +51,6 @@ 4.140 + #include <linux/sched.h> 4.141 + #include <linux/spinlock.h> 4.142 + #include <linux/wait.h> 4.143 +-#include <linux/zlib.h> 4.144 + #include <linux/pagemap.h> 4.145 + 4.146 + #include "squashfs_fs.h" 4.147 + 4.148 +--- linux-2.6.30.6/fs/squashfs/decompressor.c 4.149 ++++ linux-2.6.30.6/fs/squashfs/decompressor.c 4.150 +@@ -0,0 +1,72 @@ 4.151 ++/* 4.152 ++ * Squashfs - a compressed read only filesystem for Linux 4.153 ++ * 4.154 ++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 4.155 ++ * Phillip Lougher <phillip@lougher.demon.co.uk> 4.156 ++ * 4.157 ++ * This program is free software; you can redistribute it and/or 4.158 ++ * modify it under the terms of the GNU General Public License 4.159 ++ * as published by the Free Software Foundation; either version 2, 4.160 ++ * or (at your option) any later version. 4.161 ++ * 4.162 ++ * This program is distributed in the hope that it will be useful, 4.163 ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of 4.164 ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 4.165 ++ * GNU General Public License for more details. 4.166 ++ * 4.167 ++ * You should have received a copy of the GNU General Public License 4.168 ++ * along with this program; if not, write to the Free Software 4.169 ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 4.170 ++ * 4.171 ++ * decompressor.c 4.172 ++ */ 4.173 ++ 4.174 ++#include <linux/types.h> 4.175 ++#include <linux/mutex.h> 4.176 ++#include <linux/buffer_head.h> 4.177 ++ 4.178 ++#include "squashfs_fs.h" 4.179 ++#include "squashfs_fs_sb.h" 4.180 ++#include "squashfs_fs_i.h" 4.181 ++#include "decompressor.h" 4.182 ++#include "squashfs.h" 4.183 ++ 4.184 ++/* 4.185 ++ * This file (and decompressor.h) implements a decompressor framework for 4.186 ++ * Squashfs, allowing multiple decompressors to be easily supported 4.187 ++ */ 4.188 ++ 4.189 ++static const struct squashfs_decompressor squashfs_lzma_unsupported_comp_ops = { 4.190 ++ NULL, NULL, NULL, LZMA_COMPRESSION, "lzma", 0 4.191 ++}; 4.192 ++ 4.193 ++static const struct squashfs_decompressor squashfs_lzo_unsupported_comp_ops = { 4.194 ++ NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0 4.195 ++}; 4.196 ++ 4.197 ++static const struct squashfs_decompressor squashfs_unknown_comp_ops = { 4.198 ++ NULL, NULL, NULL, 0, "unknown", 0 4.199 ++}; 4.200 ++ 4.201 ++static const struct squashfs_decompressor *decompressor[] = { 4.202 ++ &squashfs_zlib_comp_ops, 4.203 ++#ifdef CONFIG_SQUASHFS_LZMA 4.204 ++ &squashfs_lzma_comp_ops, 4.205 ++#else 4.206 ++ &squashfs_lzma_unsupported_comp_ops, 4.207 ++#endif 4.208 ++ &squashfs_lzo_unsupported_comp_ops, 4.209 ++ &squashfs_unknown_comp_ops 4.210 ++}; 4.211 ++ 4.212 ++ 4.213 ++const struct squashfs_decompressor *squashfs_lookup_decompressor(int id) 4.214 ++{ 4.215 ++ int i; 4.216 ++ 4.217 ++ for (i = 0; decompressor[i]->id; i++) 4.218 ++ if (id == decompressor[i]->id) 4.219 ++ break; 4.220 ++ 4.221 ++ return decompressor[i]; 4.222 ++} 4.223 + 4.224 +--- linux-2.6.30.6/fs/squashfs/decompressor.h 4.225 ++++ linux-2.6.30.6/fs/squashfs/decompressor.h 4.226 +@@ -0,0 +1,55 @@ 4.227 ++#ifndef DECOMPRESSOR_H 4.228 ++#define DECOMPRESSOR_H 4.229 ++/* 4.230 ++ * Squashfs - a compressed read only filesystem for Linux 4.231 ++ * 4.232 ++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 4.233 ++ * Phillip Lougher <phillip@lougher.demon.co.uk> 4.234 ++ * 4.235 ++ * This program is free software; you can redistribute it and/or 4.236 ++ * modify it under the terms of the GNU General Public License 4.237 ++ * as published by the Free Software Foundation; either version 2, 4.238 ++ * or (at your option) any later version. 4.239 ++ * 4.240 ++ * This program is distributed in the hope that it will be useful, 4.241 ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of 4.242 ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 4.243 ++ * GNU General Public License for more details. 4.244 ++ * 4.245 ++ * You should have received a copy of the GNU General Public License 4.246 ++ * along with this program; if not, write to the Free Software 4.247 ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 4.248 ++ * 4.249 ++ * decompressor.h 4.250 ++ */ 4.251 ++ 4.252 ++struct squashfs_decompressor { 4.253 ++ void *(*init)(struct squashfs_sb_info *); 4.254 ++ void (*free)(void *); 4.255 ++ int (*decompress)(struct squashfs_sb_info *, void **, 4.256 ++ struct buffer_head **, int, int, int, int, int); 4.257 ++ int id; 4.258 ++ char *name; 4.259 ++ int supported; 4.260 ++}; 4.261 ++ 4.262 ++static inline void *squashfs_decompressor_init(struct squashfs_sb_info *msblk) 4.263 ++{ 4.264 ++ return msblk->decompressor->init(msblk); 4.265 ++} 4.266 ++ 4.267 ++static inline void squashfs_decompressor_free(struct squashfs_sb_info *msblk, 4.268 ++ void *s) 4.269 ++{ 4.270 ++ if (msblk->decompressor) 4.271 ++ msblk->decompressor->free(s); 4.272 ++} 4.273 ++ 4.274 ++static inline int squashfs_decompress(struct squashfs_sb_info *msblk, 4.275 ++ void **buffer, struct buffer_head **bh, int b, int offset, int length, 4.276 ++ int srclength, int pages) 4.277 ++{ 4.278 ++ return msblk->decompressor->decompress(msblk, buffer, bh, b, offset, 4.279 ++ length, srclength, pages); 4.280 ++} 4.281 ++#endif 4.282 + 4.283 +--- linux-2.6.30.6/fs/squashfs/dir.c 4.284 ++++ linux-2.6.30.6/fs/squashfs/dir.c 4.285 +@@ -30,7 +30,6 @@ 4.286 + #include <linux/fs.h> 4.287 + #include <linux/vfs.h> 4.288 + #include <linux/slab.h> 4.289 +-#include <linux/zlib.h> 4.290 + 4.291 + #include "squashfs_fs.h" 4.292 + #include "squashfs_fs_sb.h" 4.293 + 4.294 +--- linux-2.6.30.6/fs/squashfs/export.c 4.295 ++++ linux-2.6.30.6/fs/squashfs/export.c 4.296 +@@ -39,7 +39,6 @@ 4.297 + #include <linux/vfs.h> 4.298 + #include <linux/dcache.h> 4.299 + #include <linux/exportfs.h> 4.300 +-#include <linux/zlib.h> 4.301 + #include <linux/slab.h> 4.302 + 4.303 + #include "squashfs_fs.h" 4.304 + 4.305 +--- linux-2.6.30.6/fs/squashfs/file.c 4.306 ++++ linux-2.6.30.6/fs/squashfs/file.c 4.307 +@@ -47,7 +47,6 @@ 4.308 + #include <linux/string.h> 4.309 + #include <linux/pagemap.h> 4.310 + #include <linux/mutex.h> 4.311 +-#include <linux/zlib.h> 4.312 + 4.313 + #include "squashfs_fs.h" 4.314 + #include "squashfs_fs_sb.h" 4.315 + 4.316 +--- linux-2.6.30.6/fs/squashfs/fragment.c 4.317 ++++ linux-2.6.30.6/fs/squashfs/fragment.c 4.318 +@@ -36,7 +36,6 @@ 4.319 + #include <linux/fs.h> 4.320 + #include <linux/vfs.h> 4.321 + #include <linux/slab.h> 4.322 +-#include <linux/zlib.h> 4.323 + 4.324 + #include "squashfs_fs.h" 4.325 + #include "squashfs_fs_sb.h" 4.326 + 4.327 +--- linux-2.6.30.6/fs/squashfs/id.c 4.328 ++++ linux-2.6.30.6/fs/squashfs/id.c 4.329 +@@ -34,7 +34,6 @@ 4.330 + #include <linux/fs.h> 4.331 + #include <linux/vfs.h> 4.332 + #include <linux/slab.h> 4.333 +-#include <linux/zlib.h> 4.334 + 4.335 + #include "squashfs_fs.h" 4.336 + #include "squashfs_fs_sb.h" 4.337 + 4.338 +--- linux-2.6.30.6/fs/squashfs/inode.c 4.339 ++++ linux-2.6.30.6/fs/squashfs/inode.c 4.340 +@@ -40,7 +40,6 @@ 4.341 + 4.342 + #include <linux/fs.h> 4.343 + #include <linux/vfs.h> 4.344 +-#include <linux/zlib.h> 4.345 + 4.346 + #include "squashfs_fs.h" 4.347 + #include "squashfs_fs_sb.h" 4.348 + 4.349 +--- linux-2.6.30.6/fs/squashfs/lzma_wrapper.c 4.350 ++++ linux-2.6.30.6/fs/squashfs/lzma_wrapper.c 4.351 +@@ -0,0 +1,151 @@ 4.352 ++/* 4.353 ++ * Squashfs - a compressed read only filesystem for Linux 4.354 ++ * 4.355 ++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 4.356 ++ * Phillip Lougher <phillip@lougher.demon.co.uk> 4.357 ++ * 4.358 ++ * This program is free software; you can redistribute it and/or 4.359 ++ * modify it under the terms of the GNU General Public License 4.360 ++ * as published by the Free Software Foundation; either version 2, 4.361 ++ * or (at your option) any later version. 4.362 ++ * 4.363 ++ * This program is distributed in the hope that it will be useful, 4.364 ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of 4.365 ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 4.366 ++ * GNU General Public License for more details. 4.367 ++ * 4.368 ++ * You should have received a copy of the GNU General Public License 4.369 ++ * along with this program; if not, write to the Free Software 4.370 ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 4.371 ++ * 4.372 ++ * lzma_wrapper.c 4.373 ++ */ 4.374 ++ 4.375 ++#include <asm/unaligned.h> 4.376 ++#include <linux/buffer_head.h> 4.377 ++#include <linux/mutex.h> 4.378 ++#include <linux/vmalloc.h> 4.379 ++#include <linux/decompress/unlzma.h> 4.380 ++ 4.381 ++#include "squashfs_fs.h" 4.382 ++#include "squashfs_fs_sb.h" 4.383 ++#include "squashfs_fs_i.h" 4.384 ++#include "squashfs.h" 4.385 ++#include "decompressor.h" 4.386 ++ 4.387 ++struct squashfs_lzma { 4.388 ++ void *input; 4.389 ++ void *output; 4.390 ++}; 4.391 ++ 4.392 ++/* decompress_unlzma.c is currently non re-entrant... */ 4.393 ++DEFINE_MUTEX(lzma_mutex); 4.394 ++ 4.395 ++/* decompress_unlzma.c doesn't provide any context in its callbacks... */ 4.396 ++static int lzma_error; 4.397 ++ 4.398 ++static void error(char *m) 4.399 ++{ 4.400 ++ ERROR("unlzma error: %s\n", m); 4.401 ++ lzma_error = 1; 4.402 ++} 4.403 ++ 4.404 ++ 4.405 ++static void *lzma_init(struct squashfs_sb_info *msblk) 4.406 ++{ 4.407 ++ struct squashfs_lzma *stream = kzalloc(sizeof(*stream), GFP_KERNEL); 4.408 ++ if (stream == NULL) 4.409 ++ goto failed; 4.410 ++ stream->input = vmalloc(msblk->block_size); 4.411 ++ if (stream->input == NULL) 4.412 ++ goto failed; 4.413 ++ stream->output = vmalloc(msblk->block_size); 4.414 ++ if (stream->output == NULL) 4.415 ++ goto failed2; 4.416 ++ 4.417 ++ return stream; 4.418 ++ 4.419 ++failed2: 4.420 ++ vfree(stream->input); 4.421 ++failed: 4.422 ++ ERROR("failed to allocate lzma workspace\n"); 4.423 ++ kfree(stream); 4.424 ++ return NULL; 4.425 ++} 4.426 ++ 4.427 ++ 4.428 ++static void lzma_free(void *strm) 4.429 ++{ 4.430 ++ struct squashfs_lzma *stream = strm; 4.431 ++ 4.432 ++ if (stream) { 4.433 ++ vfree(stream->input); 4.434 ++ vfree(stream->output); 4.435 ++ } 4.436 ++ kfree(stream); 4.437 ++} 4.438 ++ 4.439 ++ 4.440 ++static int lzma_uncompress(struct squashfs_sb_info *msblk, void **buffer, 4.441 ++ struct buffer_head **bh, int b, int offset, int length, int srclength, 4.442 ++ int pages) 4.443 ++{ 4.444 ++ struct squashfs_lzma *stream = msblk->stream; 4.445 ++ void *buff = stream->input; 4.446 ++ int avail, i, bytes = length, res; 4.447 ++ 4.448 ++ mutex_lock(&lzma_mutex); 4.449 ++ 4.450 ++ for (i = 0; i < b; i++) { 4.451 ++ wait_on_buffer(bh[i]); 4.452 ++ if (!buffer_uptodate(bh[i])) 4.453 ++ goto block_release; 4.454 ++ 4.455 ++ avail = min(bytes, msblk->devblksize - offset); 4.456 ++ memcpy(buff, bh[i]->b_data + offset, avail); 4.457 ++ buff += avail; 4.458 ++ bytes -= avail; 4.459 ++ offset = 0; 4.460 ++ put_bh(bh[i]); 4.461 ++ } 4.462 ++ 4.463 ++ lzma_error = 0; 4.464 ++ res = unlzma(stream->input, length, NULL, NULL, stream->output, NULL, 4.465 ++ error); 4.466 ++ if (res || lzma_error) 4.467 ++ goto failed; 4.468 ++ 4.469 ++ /* uncompressed size is stored in the LZMA header (5 byte offset) */ 4.470 ++ res = bytes = get_unaligned_le32(stream->input + 5); 4.471 ++ for (i = 0, buff = stream->output; bytes && i < pages; i++) { 4.472 ++ avail = min_t(int, bytes, PAGE_CACHE_SIZE); 4.473 ++ memcpy(buffer[i], buff, avail); 4.474 ++ buff += avail; 4.475 ++ bytes -= avail; 4.476 ++ } 4.477 ++ if (bytes) 4.478 ++ goto failed; 4.479 ++ 4.480 ++ mutex_unlock(&lzma_mutex); 4.481 ++ return res; 4.482 ++ 4.483 ++block_release: 4.484 ++ for (; i < b; i++) 4.485 ++ put_bh(bh[i]); 4.486 ++ 4.487 ++failed: 4.488 ++ mutex_unlock(&lzma_mutex); 4.489 ++ 4.490 ++ ERROR("lzma decompression failed, data probably corrupt\n"); 4.491 ++ return -EIO; 4.492 ++} 4.493 ++ 4.494 ++const struct squashfs_decompressor squashfs_lzma_comp_ops = { 4.495 ++ .init = lzma_init, 4.496 ++ .free = lzma_free, 4.497 ++ .decompress = lzma_uncompress, 4.498 ++ .id = LZMA_COMPRESSION, 4.499 ++ .name = "lzma", 4.500 ++ .supported = 1 4.501 ++}; 4.502 ++ 4.503 + 4.504 +--- linux-2.6.30.6/fs/squashfs/namei.c 4.505 ++++ linux-2.6.30.6/fs/squashfs/namei.c 4.506 +@@ -57,7 +57,6 @@ 4.507 + #include <linux/slab.h> 4.508 + #include <linux/string.h> 4.509 + #include <linux/dcache.h> 4.510 +-#include <linux/zlib.h> 4.511 + 4.512 + #include "squashfs_fs.h" 4.513 + #include "squashfs_fs_sb.h" 4.514 + 4.515 +--- linux-2.6.30.6/fs/squashfs/squashfs.h 4.516 ++++ linux-2.6.30.6/fs/squashfs/squashfs.h 4.517 +@@ -51,6 +51,9 @@ 4.518 + u64, int); 4.519 + extern int squashfs_read_table(struct super_block *, void *, u64, int); 4.520 + 4.521 ++/* decompressor.c */ 4.522 ++extern const struct squashfs_decompressor *squashfs_lookup_decompressor(int); 4.523 ++ 4.524 + /* export.c */ 4.525 + extern __le64 *squashfs_read_inode_lookup_table(struct super_block *, u64, 4.526 + unsigned int); 4.527 +@@ -71,7 +74,7 @@ 4.528 + extern int squashfs_read_inode(struct inode *, long long); 4.529 + 4.530 + /* 4.531 +- * Inodes and files operations 4.532 ++ * Inodes, files and decompressor operations 4.533 + */ 4.534 + 4.535 + /* dir.c */ 4.536 +@@ -88,3 +91,9 @@ 4.537 + 4.538 + /* symlink.c */ 4.539 + extern const struct address_space_operations squashfs_symlink_aops; 4.540 ++ 4.541 ++/* zlib_wrapper.c */ 4.542 ++extern const struct squashfs_decompressor squashfs_zlib_comp_ops; 4.543 ++ 4.544 ++/* lzma wrapper.c */ 4.545 ++extern const struct squashfs_decompressor squashfs_lzma_comp_ops; 4.546 + 4.547 +--- linux-2.6.30.6/fs/squashfs/squashfs_fs.h 4.548 ++++ linux-2.6.30.6/fs/squashfs/squashfs_fs.h 4.549 +@@ -211,7 +211,9 @@ 4.550 + /* 4.551 + * definitions for structures on disk 4.552 + */ 4.553 +-#define ZLIB_COMPRESSION 1 4.554 ++#define ZLIB_COMPRESSION 1 4.555 ++#define LZMA_COMPRESSION 2 4.556 ++#define LZO_COMPRESSION 3 4.557 + 4.558 + struct squashfs_super_block { 4.559 + __le32 s_magic; 4.560 + 4.561 +--- linux-2.6.30.6/fs/squashfs/squashfs_fs_sb.h 4.562 ++++ linux-2.6.30.6/fs/squashfs/squashfs_fs_sb.h 4.563 +@@ -52,25 +52,26 @@ 4.564 + }; 4.565 + 4.566 + struct squashfs_sb_info { 4.567 +- int devblksize; 4.568 +- int devblksize_log2; 4.569 +- struct squashfs_cache *block_cache; 4.570 +- struct squashfs_cache *fragment_cache; 4.571 +- struct squashfs_cache *read_page; 4.572 +- int next_meta_index; 4.573 +- __le64 *id_table; 4.574 +- __le64 *fragment_index; 4.575 +- unsigned int *fragment_index_2; 4.576 +- struct mutex read_data_mutex; 4.577 +- struct mutex meta_index_mutex; 4.578 +- struct meta_index *meta_index; 4.579 +- z_stream stream; 4.580 +- __le64 *inode_lookup_table; 4.581 +- u64 inode_table; 4.582 +- u64 directory_table; 4.583 +- unsigned int block_size; 4.584 +- unsigned short block_log; 4.585 +- long long bytes_used; 4.586 +- unsigned int inodes; 4.587 ++ const struct squashfs_decompressor *decompressor; 4.588 ++ int devblksize; 4.589 ++ int devblksize_log2; 4.590 ++ struct squashfs_cache *block_cache; 4.591 ++ struct squashfs_cache *fragment_cache; 4.592 ++ struct squashfs_cache *read_page; 4.593 ++ int next_meta_index; 4.594 ++ __le64 *id_table; 4.595 ++ __le64 *fragment_index; 4.596 ++ unsigned int *fragment_index_2; 4.597 ++ struct mutex read_data_mutex; 4.598 ++ struct mutex meta_index_mutex; 4.599 ++ struct meta_index *meta_index; 4.600 ++ void *stream; 4.601 ++ __le64 *inode_lookup_table; 4.602 ++ u64 inode_table; 4.603 ++ u64 directory_table; 4.604 ++ unsigned int block_size; 4.605 ++ unsigned short block_log; 4.606 ++ long long bytes_used; 4.607 ++ unsigned int inodes; 4.608 + }; 4.609 + #endif 4.610 + 4.611 +--- linux-2.6.30.6/fs/squashfs/super.c 4.612 ++++ linux-2.6.30.6/fs/squashfs/super.c 4.613 +@@ -30,38 +30,46 @@ 4.614 + #include <linux/fs.h> 4.615 + #include <linux/vfs.h> 4.616 + #include <linux/slab.h> 4.617 ++#include <linux/smp_lock.h> 4.618 + #include <linux/mutex.h> 4.619 + #include <linux/pagemap.h> 4.620 + #include <linux/init.h> 4.621 + #include <linux/module.h> 4.622 +-#include <linux/zlib.h> 4.623 + #include <linux/magic.h> 4.624 + 4.625 + #include "squashfs_fs.h" 4.626 + #include "squashfs_fs_sb.h" 4.627 + #include "squashfs_fs_i.h" 4.628 + #include "squashfs.h" 4.629 ++#include "decompressor.h" 4.630 + 4.631 + static struct file_system_type squashfs_fs_type; 4.632 +-static struct super_operations squashfs_super_ops; 4.633 ++static const struct super_operations squashfs_super_ops; 4.634 + 4.635 +-static int supported_squashfs_filesystem(short major, short minor, short comp) 4.636 ++static const struct squashfs_decompressor *supported_squashfs_filesystem(short 4.637 ++ major, short minor, short id) 4.638 + { 4.639 ++ const struct squashfs_decompressor *decompressor; 4.640 ++ 4.641 + if (major < SQUASHFS_MAJOR) { 4.642 + ERROR("Major/Minor mismatch, older Squashfs %d.%d " 4.643 + "filesystems are unsupported\n", major, minor); 4.644 +- return -EINVAL; 4.645 ++ return NULL; 4.646 + } else if (major > SQUASHFS_MAJOR || minor > SQUASHFS_MINOR) { 4.647 + ERROR("Major/Minor mismatch, trying to mount newer " 4.648 + "%d.%d filesystem\n", major, minor); 4.649 + ERROR("Please update your kernel\n"); 4.650 +- return -EINVAL; 4.651 ++ return NULL; 4.652 + } 4.653 + 4.654 +- if (comp != ZLIB_COMPRESSION) 4.655 +- return -EINVAL; 4.656 ++ decompressor = squashfs_lookup_decompressor(id); 4.657 ++ if (!decompressor->supported) { 4.658 ++ ERROR("Filesystem uses \"%s\" compression. This is not " 4.659 ++ "supported\n", decompressor->name); 4.660 ++ return NULL; 4.661 ++ } 4.662 + 4.663 +- return 0; 4.664 ++ return decompressor; 4.665 + } 4.666 + 4.667 + 4.668 +@@ -86,13 +94,6 @@ 4.669 + } 4.670 + msblk = sb->s_fs_info; 4.671 + 4.672 +- msblk->stream.workspace = kmalloc(zlib_inflate_workspacesize(), 4.673 +- GFP_KERNEL); 4.674 +- if (msblk->stream.workspace == NULL) { 4.675 +- ERROR("Failed to allocate zlib workspace\n"); 4.676 +- goto failure; 4.677 +- } 4.678 +- 4.679 + sblk = kzalloc(sizeof(*sblk), GFP_KERNEL); 4.680 + if (sblk == NULL) { 4.681 + ERROR("Failed to allocate squashfs_super_block\n"); 4.682 +@@ -119,25 +120,25 @@ 4.683 + goto failed_mount; 4.684 + } 4.685 + 4.686 ++ err = -EINVAL; 4.687 ++ 4.688 + /* Check it is a SQUASHFS superblock */ 4.689 + sb->s_magic = le32_to_cpu(sblk->s_magic); 4.690 + if (sb->s_magic != SQUASHFS_MAGIC) { 4.691 + if (!silent) 4.692 + ERROR("Can't find a SQUASHFS superblock on %s\n", 4.693 + bdevname(sb->s_bdev, b)); 4.694 +- err = -EINVAL; 4.695 + goto failed_mount; 4.696 + } 4.697 + 4.698 +- /* Check the MAJOR & MINOR versions and compression type */ 4.699 +- err = supported_squashfs_filesystem(le16_to_cpu(sblk->s_major), 4.700 ++ /* Check the MAJOR & MINOR versions and lookup compression type */ 4.701 ++ msblk->decompressor = supported_squashfs_filesystem( 4.702 ++ le16_to_cpu(sblk->s_major), 4.703 + le16_to_cpu(sblk->s_minor), 4.704 + le16_to_cpu(sblk->compression)); 4.705 +- if (err < 0) 4.706 ++ if (msblk->decompressor == NULL) 4.707 + goto failed_mount; 4.708 + 4.709 +- err = -EINVAL; 4.710 +- 4.711 + /* 4.712 + * Check if there's xattrs in the filesystem. These are not 4.713 + * supported in this version, so warn that they will be ignored. 4.714 +@@ -204,6 +205,10 @@ 4.715 + 4.716 + err = -ENOMEM; 4.717 + 4.718 ++ msblk->stream = squashfs_decompressor_init(msblk); 4.719 ++ if (msblk->stream == NULL) 4.720 ++ goto failed_mount; 4.721 ++ 4.722 + msblk->block_cache = squashfs_cache_init("metadata", 4.723 + SQUASHFS_CACHED_BLKS, SQUASHFS_METADATA_SIZE); 4.724 + if (msblk->block_cache == NULL) 4.725 +@@ -291,17 +296,16 @@ 4.726 + squashfs_cache_delete(msblk->block_cache); 4.727 + squashfs_cache_delete(msblk->fragment_cache); 4.728 + squashfs_cache_delete(msblk->read_page); 4.729 ++ squashfs_decompressor_free(msblk, msblk->stream); 4.730 + kfree(msblk->inode_lookup_table); 4.731 + kfree(msblk->fragment_index); 4.732 + kfree(msblk->id_table); 4.733 +- kfree(msblk->stream.workspace); 4.734 + kfree(sb->s_fs_info); 4.735 + sb->s_fs_info = NULL; 4.736 + kfree(sblk); 4.737 + return err; 4.738 + 4.739 + failure: 4.740 +- kfree(msblk->stream.workspace); 4.741 + kfree(sb->s_fs_info); 4.742 + sb->s_fs_info = NULL; 4.743 + return -ENOMEM; 4.744 +@@ -338,18 +342,22 @@ 4.745 + 4.746 + static void squashfs_put_super(struct super_block *sb) 4.747 + { 4.748 ++ lock_kernel(); 4.749 ++ 4.750 + if (sb->s_fs_info) { 4.751 + struct squashfs_sb_info *sbi = sb->s_fs_info; 4.752 + squashfs_cache_delete(sbi->block_cache); 4.753 + squashfs_cache_delete(sbi->fragment_cache); 4.754 + squashfs_cache_delete(sbi->read_page); 4.755 ++ squashfs_decompressor_free(sbi, sbi->stream); 4.756 + kfree(sbi->id_table); 4.757 + kfree(sbi->fragment_index); 4.758 + kfree(sbi->meta_index); 4.759 +- kfree(sbi->stream.workspace); 4.760 + kfree(sb->s_fs_info); 4.761 + sb->s_fs_info = NULL; 4.762 + } 4.763 ++ 4.764 ++ unlock_kernel(); 4.765 + } 4.766 + 4.767 + 4.768 +@@ -439,7 +447,7 @@ 4.769 + .fs_flags = FS_REQUIRES_DEV 4.770 + }; 4.771 + 4.772 +-static struct super_operations squashfs_super_ops = { 4.773 ++static const struct super_operations squashfs_super_ops = { 4.774 + .alloc_inode = squashfs_alloc_inode, 4.775 + .destroy_inode = squashfs_destroy_inode, 4.776 + .statfs = squashfs_statfs, 4.777 + 4.778 +--- linux-2.6.30.6/fs/squashfs/symlink.c 4.779 ++++ linux-2.6.30.6/fs/squashfs/symlink.c 4.780 +@@ -36,7 +36,6 @@ 4.781 + #include <linux/slab.h> 4.782 + #include <linux/string.h> 4.783 + #include <linux/pagemap.h> 4.784 +-#include <linux/zlib.h> 4.785 + 4.786 + #include "squashfs_fs.h" 4.787 + #include "squashfs_fs_sb.h" 4.788 + 4.789 +--- linux-2.6.30.6/fs/squashfs/zlib_wrapper.c 4.790 ++++ linux-2.6.30.6/fs/squashfs/zlib_wrapper.c 4.791 +@@ -0,0 +1,150 @@ 4.792 ++/* 4.793 ++ * Squashfs - a compressed read only filesystem for Linux 4.794 ++ * 4.795 ++ * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 4.796 ++ * Phillip Lougher <phillip@lougher.demon.co.uk> 4.797 ++ * 4.798 ++ * This program is free software; you can redistribute it and/or 4.799 ++ * modify it under the terms of the GNU General Public License 4.800 ++ * as published by the Free Software Foundation; either version 2, 4.801 ++ * or (at your option) any later version. 4.802 ++ * 4.803 ++ * This program is distributed in the hope that it will be useful, 4.804 ++ * but WITHOUT ANY WARRANTY; without even the implied warranty of 4.805 ++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 4.806 ++ * GNU General Public License for more details. 4.807 ++ * 4.808 ++ * You should have received a copy of the GNU General Public License 4.809 ++ * along with this program; if not, write to the Free Software 4.810 ++ * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 4.811 ++ * 4.812 ++ * zlib_wrapper.c 4.813 ++ */ 4.814 ++ 4.815 ++ 4.816 ++#include <linux/mutex.h> 4.817 ++#include <linux/buffer_head.h> 4.818 ++#include <linux/zlib.h> 4.819 ++ 4.820 ++#include "squashfs_fs.h" 4.821 ++#include "squashfs_fs_sb.h" 4.822 ++#include "squashfs_fs_i.h" 4.823 ++#include "squashfs.h" 4.824 ++#include "decompressor.h" 4.825 ++ 4.826 ++static void *zlib_init(struct squashfs_sb_info *dummy) 4.827 ++{ 4.828 ++ z_stream *stream = kmalloc(sizeof(z_stream), GFP_KERNEL); 4.829 ++ if (stream == NULL) 4.830 ++ goto failed; 4.831 ++ stream->workspace = kmalloc(zlib_inflate_workspacesize(), 4.832 ++ GFP_KERNEL); 4.833 ++ if (stream->workspace == NULL) 4.834 ++ goto failed; 4.835 ++ 4.836 ++ return stream; 4.837 ++ 4.838 ++failed: 4.839 ++ ERROR("Failed to allocate zlib workspace\n"); 4.840 ++ kfree(stream); 4.841 ++ return NULL; 4.842 ++} 4.843 ++ 4.844 ++ 4.845 ++static void zlib_free(void *strm) 4.846 ++{ 4.847 ++ z_stream *stream = strm; 4.848 ++ 4.849 ++ if (stream) 4.850 ++ kfree(stream->workspace); 4.851 ++ kfree(stream); 4.852 ++} 4.853 ++ 4.854 ++ 4.855 ++static int zlib_uncompress(struct squashfs_sb_info *msblk, void **buffer, 4.856 ++ struct buffer_head **bh, int b, int offset, int length, int srclength, 4.857 ++ int pages) 4.858 ++{ 4.859 ++ int zlib_err = 0, zlib_init = 0; 4.860 ++ int avail, bytes, k = 0, page = 0; 4.861 ++ z_stream *stream = msblk->stream; 4.862 ++ 4.863 ++ mutex_lock(&msblk->read_data_mutex); 4.864 ++ 4.865 ++ stream->avail_out = 0; 4.866 ++ stream->avail_in = 0; 4.867 ++ 4.868 ++ bytes = length; 4.869 ++ do { 4.870 ++ if (stream->avail_in == 0 && k < b) { 4.871 ++ avail = min(bytes, msblk->devblksize - offset); 4.872 ++ bytes -= avail; 4.873 ++ wait_on_buffer(bh[k]); 4.874 ++ if (!buffer_uptodate(bh[k])) 4.875 ++ goto release_mutex; 4.876 ++ 4.877 ++ if (avail == 0) { 4.878 ++ offset = 0; 4.879 ++ put_bh(bh[k++]); 4.880 ++ continue; 4.881 ++ } 4.882 ++ 4.883 ++ stream->next_in = bh[k]->b_data + offset; 4.884 ++ stream->avail_in = avail; 4.885 ++ offset = 0; 4.886 ++ } 4.887 ++ 4.888 ++ if (stream->avail_out == 0 && page < pages) { 4.889 ++ stream->next_out = buffer[page++]; 4.890 ++ stream->avail_out = PAGE_CACHE_SIZE; 4.891 ++ } 4.892 ++ 4.893 ++ if (!zlib_init) { 4.894 ++ zlib_err = zlib_inflateInit(stream); 4.895 ++ if (zlib_err != Z_OK) { 4.896 ++ ERROR("zlib_inflateInit returned unexpected " 4.897 ++ "result 0x%x, srclength %d\n", 4.898 ++ zlib_err, srclength); 4.899 ++ goto release_mutex; 4.900 ++ } 4.901 ++ zlib_init = 1; 4.902 ++ } 4.903 ++ 4.904 ++ zlib_err = zlib_inflate(stream, Z_SYNC_FLUSH); 4.905 ++ 4.906 ++ if (stream->avail_in == 0 && k < b) 4.907 ++ put_bh(bh[k++]); 4.908 ++ } while (zlib_err == Z_OK); 4.909 ++ 4.910 ++ if (zlib_err != Z_STREAM_END) { 4.911 ++ ERROR("zlib_inflate error, data probably corrupt\n"); 4.912 ++ goto release_mutex; 4.913 ++ } 4.914 ++ 4.915 ++ zlib_err = zlib_inflateEnd(stream); 4.916 ++ if (zlib_err != Z_OK) { 4.917 ++ ERROR("zlib_inflate error, data probably corrupt\n"); 4.918 ++ goto release_mutex; 4.919 ++ } 4.920 ++ 4.921 ++ mutex_unlock(&msblk->read_data_mutex); 4.922 ++ return stream->total_out; 4.923 ++ 4.924 ++release_mutex: 4.925 ++ mutex_unlock(&msblk->read_data_mutex); 4.926 ++ 4.927 ++ for (; k < b; k++) 4.928 ++ put_bh(bh[k]); 4.929 ++ 4.930 ++ return -EIO; 4.931 ++} 4.932 ++ 4.933 ++const struct squashfs_decompressor squashfs_zlib_comp_ops = { 4.934 ++ .init = zlib_init, 4.935 ++ .free = zlib_free, 4.936 ++ .decompress = zlib_uncompress, 4.937 ++ .id = ZLIB_COMPRESSION, 4.938 ++ .name = "zlib", 4.939 ++ .supported = 1 4.940 ++}; 4.941 ++ 4.942 + 4.943 +--- linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h 4.944 ++++ linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h 4.945 +@@ -0,0 +1,13 @@ 4.946 ++#ifndef BUNZIP2_MM_H 4.947 ++#define BUNZIP2_MM_H 4.948 ++ 4.949 ++#ifdef STATIC 4.950 ++/* Code active when included from pre-boot environment: */ 4.951 ++#define INIT 4.952 ++#else 4.953 ++/* Compile for initramfs/initrd code only */ 4.954 ++#define INIT __init 4.955 ++static void(*error)(char *m); 4.956 ++#endif 4.957 ++ 4.958 ++#endif 4.959 + 4.960 +--- linux-2.6.30.6/include/linux/decompress/inflate_mm.h 4.961 ++++ linux-2.6.30.6/include/linux/decompress/inflate_mm.h 4.962 +@@ -0,0 +1,13 @@ 4.963 ++#ifndef INFLATE_MM_H 4.964 ++#define INFLATE_MM_H 4.965 ++ 4.966 ++#ifdef STATIC 4.967 ++/* Code active when included from pre-boot environment: */ 4.968 ++#define INIT 4.969 ++#else 4.970 ++/* Compile for initramfs/initrd code only */ 4.971 ++#define INIT __init 4.972 ++static void(*error)(char *m); 4.973 ++#endif 4.974 ++ 4.975 ++#endif 4.976 + 4.977 +--- linux-2.6.30.6/include/linux/decompress/mm.h 4.978 ++++ linux-2.6.30.6/include/linux/decompress/mm.h 4.979 +@@ -25,7 +25,7 @@ 4.980 + void *p; 4.981 + 4.982 + if (size < 0) 4.983 +- error("Malloc error"); 4.984 ++ return NULL; 4.985 + if (!malloc_ptr) 4.986 + malloc_ptr = free_mem_ptr; 4.987 + 4.988 +@@ -35,7 +35,7 @@ 4.989 + malloc_ptr += size; 4.990 + 4.991 + if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr) 4.992 +- error("Out of memory"); 4.993 ++ return NULL; 4.994 + 4.995 + malloc_count++; 4.996 + return p; 4.997 +@@ -53,8 +53,6 @@ 4.998 + 4.999 + #define set_error_fn(x) 4.1000 + 4.1001 +-#define INIT 4.1002 +- 4.1003 + #else /* STATIC */ 4.1004 + 4.1005 + /* Code active when compiled standalone for use when loading ramdisk: */ 4.1006 +@@ -74,10 +72,8 @@ 4.1007 + #define large_malloc(a) vmalloc(a) 4.1008 + #define large_free(a) vfree(a) 4.1009 + 4.1010 +-static void(*error)(char *m); 4.1011 + #define set_error_fn(x) error = x; 4.1012 + 4.1013 +-#define INIT __init 4.1014 + #define STATIC 4.1015 + 4.1016 + #include <linux/init.h> 4.1017 + 4.1018 +--- linux-2.6.30.6/include/linux/decompress/unlzma_mm.h 4.1019 ++++ linux-2.6.30.6/include/linux/decompress/unlzma_mm.h 4.1020 +@@ -0,0 +1,20 @@ 4.1021 ++#ifndef UNLZMA_MM_H 4.1022 ++#define UNLZMA_MM_H 4.1023 ++ 4.1024 ++#ifdef STATIC 4.1025 ++ 4.1026 ++/* Code active when included from pre-boot environment: */ 4.1027 ++#define INIT 4.1028 ++ 4.1029 ++#elif defined(CONFIG_DECOMPRESS_LZMA_NEEDED) 4.1030 ++ 4.1031 ++/* Make it available to non initramfs/initrd code */ 4.1032 ++#define INIT 4.1033 ++#include <linux/module.h> 4.1034 ++#else 4.1035 ++ 4.1036 ++/* Compile for initramfs/initrd code only */ 4.1037 ++#define INIT __init 4.1038 ++#endif 4.1039 ++ 4.1040 ++#endif 4.1041 + 4.1042 +--- linux-2.6.30.6/lib/Kconfig 4.1043 ++++ linux-2.6.30.6/lib/Kconfig 4.1044 +@@ -10,6 +10,9 @@ 4.1045 + config BITREVERSE 4.1046 + tristate 4.1047 + 4.1048 ++config RATIONAL 4.1049 ++ boolean 4.1050 ++ 4.1051 + config GENERIC_FIND_FIRST_BIT 4.1052 + bool 4.1053 + 4.1054 +@@ -114,6 +117,9 @@ 4.1055 + config DECOMPRESS_LZMA 4.1056 + tristate 4.1057 + 4.1058 ++config DECOMPRESS_LZMA_NEEDED 4.1059 ++ boolean 4.1060 ++ 4.1061 + # 4.1062 + # Generic allocator support is selected if needed 4.1063 + # 4.1064 +@@ -153,6 +159,9 @@ 4.1065 + config TEXTSEARCH_FSM 4.1066 + tristate 4.1067 + 4.1068 ++config BTREE 4.1069 ++ boolean 4.1070 ++ 4.1071 + config HAS_IOMEM 4.1072 + boolean 4.1073 + depends on !NO_IOMEM 4.1074 +@@ -190,5 +199,35 @@ 4.1075 + # 4.1076 + config NLATTR 4.1077 + bool 4.1078 ++ 4.1079 ++# 4.1080 ++# Generic 64-bit atomic support is selected if needed 4.1081 ++# 4.1082 ++config GENERIC_ATOMIC64 4.1083 ++ bool 4.1084 ++ 4.1085 ++config LRU_CACHE 4.1086 ++ tristate 4.1087 ++ 4.1088 ++config SHM_SIGNAL 4.1089 ++ tristate "SHM Signal - Generic shared-memory signaling mechanism" 4.1090 ++ default n 4.1091 ++ help 4.1092 ++ Provides a shared-memory based signaling mechanism to indicate 4.1093 ++ memory-dirty notifications between two end-points. 4.1094 ++ 4.1095 ++ If unsure, say N 4.1096 ++ 4.1097 ++config IOQ 4.1098 ++ tristate "IO-Queue library - Generic shared-memory queue" 4.1099 ++ select SHM_SIGNAL 4.1100 ++ default n 4.1101 ++ help 4.1102 ++ IOQ is a generic shared-memory-queue mechanism that happens to be 4.1103 ++ friendly to virtualization boundaries. It can be used in a variety 4.1104 ++ of ways, though its intended purpose is to become a low-level 4.1105 ++ communication path for paravirtualized drivers. 4.1106 ++ 4.1107 ++ If unsure, say N 4.1108 + 4.1109 + endmenu 4.1110 + 4.1111 +--- linux-2.6.30.6/lib/decompress_bunzip2.c 4.1112 ++++ linux-2.6.30.6/lib/decompress_bunzip2.c 4.1113 +@@ -45,12 +45,15 @@ 4.1114 + */ 4.1115 + 4.1116 + 4.1117 +-#ifndef STATIC 4.1118 ++#ifdef STATIC 4.1119 ++#define PREBOOT 4.1120 ++#else 4.1121 + #include <linux/decompress/bunzip2.h> 4.1122 +-#endif /* !STATIC */ 4.1123 ++#include <linux/slab.h> 4.1124 ++#endif /* STATIC */ 4.1125 + 4.1126 ++#include <linux/decompress/bunzip2_mm.h> 4.1127 + #include <linux/decompress/mm.h> 4.1128 +-#include <linux/slab.h> 4.1129 + 4.1130 + #ifndef INT_MAX 4.1131 + #define INT_MAX 0x7fffffff 4.1132 +@@ -297,7 +300,7 @@ 4.1133 + again when using them (during symbol decoding).*/ 4.1134 + base = hufGroup->base-1; 4.1135 + limit = hufGroup->limit-1; 4.1136 +- /* Calculate permute[]. Concurently, initialize 4.1137 ++ /* Calculate permute[]. Concurrently, initialize 4.1138 + * temp[] and limit[]. */ 4.1139 + pp = 0; 4.1140 + for (i = minLen; i <= maxLen; i++) { 4.1141 +@@ -635,6 +638,8 @@ 4.1142 + 4.1143 + /* Allocate bunzip_data. Most fields initialize to zero. */ 4.1144 + bd = *bdp = malloc(i); 4.1145 ++ if (!bd) 4.1146 ++ return RETVAL_OUT_OF_MEMORY; 4.1147 + memset(bd, 0, sizeof(struct bunzip_data)); 4.1148 + /* Setup input buffer */ 4.1149 + bd->inbuf = inbuf; 4.1150 +@@ -662,6 +667,8 @@ 4.1151 + bd->dbufSize = 100000*(i-BZh0); 4.1152 + 4.1153 + bd->dbuf = large_malloc(bd->dbufSize * sizeof(int)); 4.1154 ++ if (!bd->dbuf) 4.1155 ++ return RETVAL_OUT_OF_MEMORY; 4.1156 + return RETVAL_OK; 4.1157 + } 4.1158 + 4.1159 +@@ -681,12 +688,10 @@ 4.1160 + set_error_fn(error_fn); 4.1161 + if (flush) 4.1162 + outbuf = malloc(BZIP2_IOBUF_SIZE); 4.1163 +- else 4.1164 +- len -= 4; /* Uncompressed size hack active in pre-boot 4.1165 +- environment */ 4.1166 ++ 4.1167 + if (!outbuf) { 4.1168 + error("Could not allocate output bufer"); 4.1169 +- return -1; 4.1170 ++ return RETVAL_OUT_OF_MEMORY; 4.1171 + } 4.1172 + if (buf) 4.1173 + inbuf = buf; 4.1174 +@@ -694,6 +699,7 @@ 4.1175 + inbuf = malloc(BZIP2_IOBUF_SIZE); 4.1176 + if (!inbuf) { 4.1177 + error("Could not allocate input bufer"); 4.1178 ++ i = RETVAL_OUT_OF_MEMORY; 4.1179 + goto exit_0; 4.1180 + } 4.1181 + i = start_bunzip(&bd, inbuf, len, fill); 4.1182 +@@ -720,11 +726,14 @@ 4.1183 + } else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) { 4.1184 + error("Compressed file ends unexpectedly"); 4.1185 + } 4.1186 ++ if (!bd) 4.1187 ++ goto exit_1; 4.1188 + if (bd->dbuf) 4.1189 + large_free(bd->dbuf); 4.1190 + if (pos) 4.1191 + *pos = bd->inbufPos; 4.1192 + free(bd); 4.1193 ++exit_1: 4.1194 + if (!buf) 4.1195 + free(inbuf); 4.1196 + exit_0: 4.1197 +@@ -733,4 +742,14 @@ 4.1198 + return i; 4.1199 + } 4.1200 + 4.1201 +-#define decompress bunzip2 4.1202 ++#ifdef PREBOOT 4.1203 ++STATIC int INIT decompress(unsigned char *buf, int len, 4.1204 ++ int(*fill)(void*, unsigned int), 4.1205 ++ int(*flush)(void*, unsigned int), 4.1206 ++ unsigned char *outbuf, 4.1207 ++ int *pos, 4.1208 ++ void(*error_fn)(char *x)) 4.1209 ++{ 4.1210 ++ return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error_fn); 4.1211 ++} 4.1212 ++#endif 4.1213 + 4.1214 +--- linux-2.6.30.6/lib/decompress_inflate.c 4.1215 ++++ linux-2.6.30.6/lib/decompress_inflate.c 4.1216 +@@ -19,14 +19,20 @@ 4.1217 + #include "zlib_inflate/inflate.h" 4.1218 + 4.1219 + #include "zlib_inflate/infutil.h" 4.1220 ++#include <linux/slab.h> 4.1221 + 4.1222 + #endif /* STATIC */ 4.1223 + 4.1224 ++#include <linux/decompress/inflate_mm.h> 4.1225 + #include <linux/decompress/mm.h> 4.1226 +-#include <linux/slab.h> 4.1227 + 4.1228 +-#define INBUF_LEN (16*1024) 4.1229 ++#define GZIP_IOBUF_SIZE (16*1024) 4.1230 + 4.1231 ++static int nofill(void *buffer, unsigned int len) 4.1232 ++{ 4.1233 ++ return -1; 4.1234 ++} 4.1235 ++ 4.1236 + /* Included from initramfs et al code */ 4.1237 + STATIC int INIT gunzip(unsigned char *buf, int len, 4.1238 + int(*fill)(void*, unsigned int), 4.1239 +@@ -55,7 +61,7 @@ 4.1240 + if (buf) 4.1241 + zbuf = buf; 4.1242 + else { 4.1243 +- zbuf = malloc(INBUF_LEN); 4.1244 ++ zbuf = malloc(GZIP_IOBUF_SIZE); 4.1245 + len = 0; 4.1246 + } 4.1247 + if (!zbuf) { 4.1248 +@@ -76,8 +82,11 @@ 4.1249 + goto gunzip_nomem4; 4.1250 + } 4.1251 + 4.1252 ++ if (!fill) 4.1253 ++ fill = nofill; 4.1254 ++ 4.1255 + if (len == 0) 4.1256 +- len = fill(zbuf, INBUF_LEN); 4.1257 ++ len = fill(zbuf, GZIP_IOBUF_SIZE); 4.1258 + 4.1259 + /* verify the gzip header */ 4.1260 + if (len < 10 || 4.1261 +@@ -113,7 +122,7 @@ 4.1262 + while (rc == Z_OK) { 4.1263 + if (strm->avail_in == 0) { 4.1264 + /* TODO: handle case where both pos and fill are set */ 4.1265 +- len = fill(zbuf, INBUF_LEN); 4.1266 ++ len = fill(zbuf, GZIP_IOBUF_SIZE); 4.1267 + if (len < 0) { 4.1268 + rc = -1; 4.1269 + error("read error"); 4.1270 + 4.1271 +--- linux-2.6.30.6/lib/decompress_unlzma.c 4.1272 ++++ linux-2.6.30.6/lib/decompress_unlzma.c 4.1273 +@@ -29,12 +29,15 @@ 4.1274 + *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 4.1275 + */ 4.1276 + 4.1277 +-#ifndef STATIC 4.1278 ++#ifdef STATIC 4.1279 ++#define PREBOOT 4.1280 ++#else 4.1281 + #include <linux/decompress/unlzma.h> 4.1282 ++#include <linux/slab.h> 4.1283 + #endif /* STATIC */ 4.1284 + 4.1285 ++#include <linux/decompress/unlzma_mm.h> 4.1286 + #include <linux/decompress/mm.h> 4.1287 +-#include <linux/slab.h> 4.1288 + 4.1289 + #define MIN(a, b) (((a) < (b)) ? (a) : (b)) 4.1290 + 4.1291 +@@ -80,8 +83,13 @@ 4.1292 + #define RC_MODEL_TOTAL_BITS 11 4.1293 + 4.1294 + 4.1295 ++static int nofill(void *buffer, unsigned int len) 4.1296 ++{ 4.1297 ++ return -1; 4.1298 ++} 4.1299 ++ 4.1300 + /* Called twice: once at startup and once in rc_normalize() */ 4.1301 +-static void INIT rc_read(struct rc *rc) 4.1302 ++static void INIT rc_read(struct rc *rc, void(*error)(char *x)) 4.1303 + { 4.1304 + rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE); 4.1305 + if (rc->buffer_size <= 0) 4.1306 +@@ -95,7 +103,10 @@ 4.1307 + int (*fill)(void*, unsigned int), 4.1308 + char *buffer, int buffer_size) 4.1309 + { 4.1310 +- rc->fill = fill; 4.1311 ++ if (fill) 4.1312 ++ rc->fill = fill; 4.1313 ++ else 4.1314 ++ rc->fill = nofill; 4.1315 + rc->buffer = (uint8_t *)buffer; 4.1316 + rc->buffer_size = buffer_size; 4.1317 + rc->buffer_end = rc->buffer + rc->buffer_size; 4.1318 +@@ -105,13 +116,13 @@ 4.1319 + rc->range = 0xFFFFFFFF; 4.1320 + } 4.1321 + 4.1322 +-static inline void INIT rc_init_code(struct rc *rc) 4.1323 ++static inline void INIT rc_init_code(struct rc *rc, void(*error)(char *x)) 4.1324 + { 4.1325 + int i; 4.1326 + 4.1327 + for (i = 0; i < 5; i++) { 4.1328 + if (rc->ptr >= rc->buffer_end) 4.1329 +- rc_read(rc); 4.1330 ++ rc_read(rc, error); 4.1331 + rc->code = (rc->code << 8) | *rc->ptr++; 4.1332 + } 4.1333 + } 4.1334 +@@ -124,32 +135,33 @@ 4.1335 + } 4.1336 + 4.1337 + /* Called twice, but one callsite is in inline'd rc_is_bit_0_helper() */ 4.1338 +-static void INIT rc_do_normalize(struct rc *rc) 4.1339 ++static void INIT rc_do_normalize(struct rc *rc, void(*error)(char *x)) 4.1340 + { 4.1341 + if (rc->ptr >= rc->buffer_end) 4.1342 +- rc_read(rc); 4.1343 ++ rc_read(rc, error); 4.1344 + rc->range <<= 8; 4.1345 + rc->code = (rc->code << 8) | *rc->ptr++; 4.1346 + } 4.1347 +-static inline void INIT rc_normalize(struct rc *rc) 4.1348 ++static inline void INIT rc_normalize(struct rc *rc, void(*error)(char *x)) 4.1349 + { 4.1350 + if (rc->range < (1 << RC_TOP_BITS)) 4.1351 +- rc_do_normalize(rc); 4.1352 ++ rc_do_normalize(rc, error); 4.1353 + } 4.1354 + 4.1355 + /* Called 9 times */ 4.1356 + /* Why rc_is_bit_0_helper exists? 4.1357 + *Because we want to always expose (rc->code < rc->bound) to optimizer 4.1358 + */ 4.1359 +-static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p) 4.1360 ++static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p, 4.1361 ++ void (*error)(char *x)) 4.1362 + { 4.1363 +- rc_normalize(rc); 4.1364 ++ rc_normalize(rc, error); 4.1365 + rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS); 4.1366 + return rc->bound; 4.1367 + } 4.1368 +-static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p) 4.1369 ++static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p, void(*error)(char *x)) 4.1370 + { 4.1371 +- uint32_t t = rc_is_bit_0_helper(rc, p); 4.1372 ++ uint32_t t = rc_is_bit_0_helper(rc, p, error); 4.1373 + return rc->code < t; 4.1374 + } 4.1375 + 4.1376 +@@ -167,9 +179,9 @@ 4.1377 + } 4.1378 + 4.1379 + /* Called 4 times in unlzma loop */ 4.1380 +-static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol) 4.1381 ++static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol, void(*error)(char *x)) 4.1382 + { 4.1383 +- if (rc_is_bit_0(rc, p)) { 4.1384 ++ if (rc_is_bit_0(rc, p, error)) { 4.1385 + rc_update_bit_0(rc, p); 4.1386 + *symbol *= 2; 4.1387 + return 0; 4.1388 +@@ -181,9 +193,9 @@ 4.1389 + } 4.1390 + 4.1391 + /* Called once */ 4.1392 +-static inline int INIT rc_direct_bit(struct rc *rc) 4.1393 ++static inline int INIT rc_direct_bit(struct rc *rc , void(*error)(char *x)) 4.1394 + { 4.1395 +- rc_normalize(rc); 4.1396 ++ rc_normalize(rc, error); 4.1397 + rc->range >>= 1; 4.1398 + if (rc->code >= rc->range) { 4.1399 + rc->code -= rc->range; 4.1400 +@@ -194,13 +206,14 @@ 4.1401 + 4.1402 + /* Called twice */ 4.1403 + static inline void INIT 4.1404 +-rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol) 4.1405 ++rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol, 4.1406 ++ void(*error)(char *x)) 4.1407 + { 4.1408 + int i = num_levels; 4.1409 + 4.1410 + *symbol = 1; 4.1411 + while (i--) 4.1412 +- rc_get_bit(rc, p + *symbol, symbol); 4.1413 ++ rc_get_bit(rc, p + *symbol, symbol, error); 4.1414 + *symbol -= 1 << num_levels; 4.1415 + } 4.1416 + 4.1417 +@@ -278,10 +291,6 @@ 4.1418 + size_t global_pos; 4.1419 + int(*flush)(void*, unsigned int); 4.1420 + struct lzma_header *header; 4.1421 +- int is_cpio_flush; 4.1422 +- uint8_t **buffer_index; 4.1423 +- int next_index; 4.1424 +- int max_index; 4.1425 + }; 4.1426 + 4.1427 + struct cstate { 4.1428 +@@ -298,14 +307,6 @@ 4.1429 + static inline uint8_t INIT peek_old_byte(struct writer *wr, 4.1430 + uint32_t offs) 4.1431 + { 4.1432 +- if (wr->is_cpio_flush) { 4.1433 +- int32_t pos; 4.1434 +- while (offs > wr->header->dict_size) 4.1435 +- offs -= wr->header->dict_size; 4.1436 +- pos = wr->buffer_pos - offs; 4.1437 +- return wr->buffer_index[pos / LZMA_IOBUF_SIZE] 4.1438 +- [pos % LZMA_IOBUF_SIZE]; 4.1439 +- } 4.1440 + if (!wr->flush) { 4.1441 + int32_t pos; 4.1442 + while (offs > wr->header->dict_size) 4.1443 +@@ -321,41 +322,8 @@ 4.1444 + 4.1445 + } 4.1446 + 4.1447 +-static inline void INIT write_byte_if_cpio(struct writer *wr, uint8_t byte) 4.1448 +-{ 4.1449 +- if (wr->buffer_pos % LZMA_IOBUF_SIZE == 0) { 4.1450 +- // if the following large_malloc fails, the initramfs 4.1451 +- // whould not be load with is_cpio_flush forced 0 too. 4.1452 +- // Remember we do not allocate historic buffer. 4.1453 +- // Let's assume it will never fail ! 4.1454 +- if (wr->next_index >= wr->max_index) { 4.1455 +- // realloc wr->buffer_index 4.1456 +- uint8_t **p = wr->buffer_index; 4.1457 +- wr->buffer_index = (uint8_t **) 4.1458 +- large_malloc(LZMA_IOBUF_SIZE + 4.1459 +- sizeof(*p) * wr->max_index); 4.1460 +- if (wr->max_index) { 4.1461 +- memcpy(wr->buffer_index, p, 4.1462 +- sizeof(*p) * wr->max_index); 4.1463 +- free(p); 4.1464 +- } 4.1465 +- wr->max_index += LZMA_IOBUF_SIZE / sizeof(*p); 4.1466 +- } 4.1467 +- wr->buffer_index[wr->next_index++] = 4.1468 +- (uint8_t *) large_malloc(LZMA_IOBUF_SIZE); 4.1469 +- } 4.1470 +- wr->buffer_index[wr->buffer_pos / LZMA_IOBUF_SIZE] 4.1471 +- [wr->buffer_pos % LZMA_IOBUF_SIZE] = 4.1472 +- wr->previous_byte = byte; 4.1473 +- wr->buffer_pos++; 4.1474 +-} 4.1475 +- 4.1476 + static inline void INIT write_byte(struct writer *wr, uint8_t byte) 4.1477 + { 4.1478 +- if (wr->is_cpio_flush) { 4.1479 +- write_byte_if_cpio(wr, byte); 4.1480 +- return; 4.1481 +- } 4.1482 + wr->buffer[wr->buffer_pos++] = wr->previous_byte = byte; 4.1483 + if (wr->flush && wr->buffer_pos == wr->header->dict_size) { 4.1484 + wr->buffer_pos = 0; 4.1485 +@@ -373,21 +341,7 @@ 4.1486 + static inline void INIT copy_bytes(struct writer *wr, 4.1487 + uint32_t rep0, int len) 4.1488 + { 4.1489 +- if (wr->is_cpio_flush) { 4.1490 +- int32_t pos; 4.1491 +- uint32_t offs = rep0; 4.1492 +- while (offs > wr->header->dict_size) 4.1493 +- offs -= wr->header->dict_size; 4.1494 +- pos = wr->buffer_pos - offs; 4.1495 +- do { 4.1496 +- write_byte_if_cpio(wr, 4.1497 +- wr->buffer_index[pos / LZMA_IOBUF_SIZE] 4.1498 +- [pos % LZMA_IOBUF_SIZE]); 4.1499 +- pos++; 4.1500 +- len--; 4.1501 +- } while (len != 0 && wr->buffer_pos < wr->header->dst_size); 4.1502 +- } 4.1503 +- else do { 4.1504 ++ do { 4.1505 + copy_byte(wr, rep0); 4.1506 + len--; 4.1507 + } while (len != 0 && wr->buffer_pos < wr->header->dst_size); 4.1508 +@@ -396,11 +350,9 @@ 4.1509 + static inline void INIT process_bit0(struct writer *wr, struct rc *rc, 4.1510 + struct cstate *cst, uint16_t *p, 4.1511 + int pos_state, uint16_t *prob, 4.1512 +- int lc, uint32_t literal_pos_mask) { 4.1513 ++ int lc, uint32_t literal_pos_mask, 4.1514 ++ void(*error)(char *x)) { 4.1515 + int mi = 1; 4.1516 +- static const int state[LZMA_NUM_STATES] = 4.1517 +- { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 }; 4.1518 +- 4.1519 + rc_update_bit_0(rc, prob); 4.1520 + prob = (p + LZMA_LITERAL + 4.1521 + (LZMA_LIT_SIZE 4.1522 +@@ -417,7 +369,7 @@ 4.1523 + match_byte <<= 1; 4.1524 + bit = match_byte & 0x100; 4.1525 + prob_lit = prob + 0x100 + bit + mi; 4.1526 +- if (rc_get_bit(rc, prob_lit, &mi)) { 4.1527 ++ if (rc_get_bit(rc, prob_lit, &mi, error)) { 4.1528 + if (!bit) 4.1529 + break; 4.1530 + } else { 4.1531 +@@ -428,23 +380,29 @@ 4.1532 + } 4.1533 + while (mi < 0x100) { 4.1534 + uint16_t *prob_lit = prob + mi; 4.1535 +- rc_get_bit(rc, prob_lit, &mi); 4.1536 ++ rc_get_bit(rc, prob_lit, &mi, error); 4.1537 + } 4.1538 + write_byte(wr, mi); 4.1539 +- cst->state = state[cst->state]; 4.1540 ++ if (cst->state < 4) 4.1541 ++ cst->state = 0; 4.1542 ++ else if (cst->state < 10) 4.1543 ++ cst->state -= 3; 4.1544 ++ else 4.1545 ++ cst->state -= 6; 4.1546 + } 4.1547 + 4.1548 + static inline void INIT process_bit1(struct writer *wr, struct rc *rc, 4.1549 + struct cstate *cst, uint16_t *p, 4.1550 +- int pos_state, uint16_t *prob) { 4.1551 +- int offset; 4.1552 ++ int pos_state, uint16_t *prob, 4.1553 ++ void(*error)(char *x)) { 4.1554 ++ int offset; 4.1555 + uint16_t *prob_len; 4.1556 + int num_bits; 4.1557 + int len; 4.1558 + 4.1559 + rc_update_bit_1(rc, prob); 4.1560 + prob = p + LZMA_IS_REP + cst->state; 4.1561 +- if (rc_is_bit_0(rc, prob)) { 4.1562 ++ if (rc_is_bit_0(rc, prob, error)) { 4.1563 + rc_update_bit_0(rc, prob); 4.1564 + cst->rep3 = cst->rep2; 4.1565 + cst->rep2 = cst->rep1; 4.1566 +@@ -453,14 +411,14 @@ 4.1567 + prob = p + LZMA_LEN_CODER; 4.1568 + } else { 4.1569 + rc_update_bit_1(rc, prob); 4.1570 +- prob += LZMA_IS_REP_G0 - LZMA_IS_REP; 4.1571 +- if (rc_is_bit_0(rc, prob)) { 4.1572 ++ prob = p + LZMA_IS_REP_G0 + cst->state; 4.1573 ++ if (rc_is_bit_0(rc, prob, error)) { 4.1574 + rc_update_bit_0(rc, prob); 4.1575 + prob = (p + LZMA_IS_REP_0_LONG 4.1576 + + (cst->state << 4.1577 + LZMA_NUM_POS_BITS_MAX) + 4.1578 + pos_state); 4.1579 +- if (rc_is_bit_0(rc, prob)) { 4.1580 ++ if (rc_is_bit_0(rc, prob, error)) { 4.1581 + rc_update_bit_0(rc, prob); 4.1582 + 4.1583 + cst->state = cst->state < LZMA_NUM_LIT_STATES ? 4.1584 +@@ -474,14 +432,14 @@ 4.1585 + uint32_t distance; 4.1586 + 4.1587 + rc_update_bit_1(rc, prob); 4.1588 +- prob += LZMA_IS_REP_G1 - LZMA_IS_REP_G0; 4.1589 +- if (rc_is_bit_0(rc, prob)) { 4.1590 ++ prob = p + LZMA_IS_REP_G1 + cst->state; 4.1591 ++ if (rc_is_bit_0(rc, prob, error)) { 4.1592 + rc_update_bit_0(rc, prob); 4.1593 + distance = cst->rep1; 4.1594 + } else { 4.1595 + rc_update_bit_1(rc, prob); 4.1596 +- prob += LZMA_IS_REP_G2 - LZMA_IS_REP_G1; 4.1597 +- if (rc_is_bit_0(rc, prob)) { 4.1598 ++ prob = p + LZMA_IS_REP_G2 + cst->state; 4.1599 ++ if (rc_is_bit_0(rc, prob, error)) { 4.1600 + rc_update_bit_0(rc, prob); 4.1601 + distance = cst->rep2; 4.1602 + } else { 4.1603 +@@ -499,33 +457,33 @@ 4.1604 + } 4.1605 + 4.1606 + prob_len = prob + LZMA_LEN_CHOICE; 4.1607 +- if (rc_is_bit_0(rc, prob_len)) { 4.1608 ++ if (rc_is_bit_0(rc, prob_len, error)) { 4.1609 + rc_update_bit_0(rc, prob_len); 4.1610 +- prob_len += LZMA_LEN_LOW - LZMA_LEN_CHOICE 4.1611 ++ prob_len = (prob + LZMA_LEN_LOW 4.1612 + + (pos_state << 4.1613 +- LZMA_LEN_NUM_LOW_BITS); 4.1614 ++ LZMA_LEN_NUM_LOW_BITS)); 4.1615 + offset = 0; 4.1616 + num_bits = LZMA_LEN_NUM_LOW_BITS; 4.1617 + } else { 4.1618 + rc_update_bit_1(rc, prob_len); 4.1619 +- prob_len += LZMA_LEN_CHOICE_2 - LZMA_LEN_CHOICE; 4.1620 +- if (rc_is_bit_0(rc, prob_len)) { 4.1621 ++ prob_len = prob + LZMA_LEN_CHOICE_2; 4.1622 ++ if (rc_is_bit_0(rc, prob_len, error)) { 4.1623 + rc_update_bit_0(rc, prob_len); 4.1624 +- prob_len += LZMA_LEN_MID - LZMA_LEN_CHOICE_2 4.1625 ++ prob_len = (prob + LZMA_LEN_MID 4.1626 + + (pos_state << 4.1627 +- LZMA_LEN_NUM_MID_BITS); 4.1628 ++ LZMA_LEN_NUM_MID_BITS)); 4.1629 + offset = 1 << LZMA_LEN_NUM_LOW_BITS; 4.1630 + num_bits = LZMA_LEN_NUM_MID_BITS; 4.1631 + } else { 4.1632 + rc_update_bit_1(rc, prob_len); 4.1633 +- prob_len += LZMA_LEN_HIGH - LZMA_LEN_CHOICE_2; 4.1634 ++ prob_len = prob + LZMA_LEN_HIGH; 4.1635 + offset = ((1 << LZMA_LEN_NUM_LOW_BITS) 4.1636 + + (1 << LZMA_LEN_NUM_MID_BITS)); 4.1637 + num_bits = LZMA_LEN_NUM_HIGH_BITS; 4.1638 + } 4.1639 + } 4.1640 + 4.1641 +- rc_bit_tree_decode(rc, prob_len, num_bits, &len); 4.1642 ++ rc_bit_tree_decode(rc, prob_len, num_bits, &len, error); 4.1643 + len += offset; 4.1644 + 4.1645 + if (cst->state < 4) { 4.1646 +@@ -540,7 +498,7 @@ 4.1647 + << LZMA_NUM_POS_SLOT_BITS); 4.1648 + rc_bit_tree_decode(rc, prob, 4.1649 + LZMA_NUM_POS_SLOT_BITS, 4.1650 +- &pos_slot); 4.1651 ++ &pos_slot, error); 4.1652 + if (pos_slot >= LZMA_START_POS_MODEL_INDEX) { 4.1653 + int i, mi; 4.1654 + num_bits = (pos_slot >> 1) - 1; 4.1655 +@@ -553,7 +511,7 @@ 4.1656 + num_bits -= LZMA_NUM_ALIGN_BITS; 4.1657 + while (num_bits--) 4.1658 + cst->rep0 = (cst->rep0 << 1) | 4.1659 +- rc_direct_bit(rc); 4.1660 ++ rc_direct_bit(rc, error); 4.1661 + prob = p + LZMA_ALIGN; 4.1662 + cst->rep0 <<= LZMA_NUM_ALIGN_BITS; 4.1663 + num_bits = LZMA_NUM_ALIGN_BITS; 4.1664 +@@ -561,7 +519,7 @@ 4.1665 + i = 1; 4.1666 + mi = 1; 4.1667 + while (num_bits--) { 4.1668 +- if (rc_get_bit(rc, prob + mi, &mi)) 4.1669 ++ if (rc_get_bit(rc, prob + mi, &mi, error)) 4.1670 + cst->rep0 |= i; 4.1671 + i <<= 1; 4.1672 + } 4.1673 +@@ -578,15 +536,14 @@ 4.1674 + 4.1675 + 4.1676 + 4.1677 +-STATIC inline int INIT unlzma(unsigned char *buf, int in_len, 4.1678 ++STATIC int INIT unlzma(unsigned char *buf, int in_len, 4.1679 + int(*fill)(void*, unsigned int), 4.1680 + int(*flush)(void*, unsigned int), 4.1681 + unsigned char *output, 4.1682 + int *posp, 4.1683 +- void(*error_fn)(char *x) 4.1684 ++ void(*error)(char *x) 4.1685 + ) 4.1686 + { 4.1687 +- extern int cpio_flush_buffer(void*, unsigned int); 4.1688 + struct lzma_header header; 4.1689 + int lc, pb, lp; 4.1690 + uint32_t pos_state_mask; 4.1691 +@@ -600,10 +557,6 @@ 4.1692 + unsigned char *inbuf; 4.1693 + int ret = -1; 4.1694 + 4.1695 +- set_error_fn(error_fn); 4.1696 +- if (!flush) 4.1697 +- in_len -= 4; /* Uncompressed size hack active in pre-boot 4.1698 +- environment */ 4.1699 + if (buf) 4.1700 + inbuf = buf; 4.1701 + else 4.1702 +@@ -621,16 +574,12 @@ 4.1703 + wr.global_pos = 0; 4.1704 + wr.previous_byte = 0; 4.1705 + wr.buffer_pos = 0; 4.1706 +- wr.is_cpio_flush = 0; 4.1707 +- if (flush == cpio_flush_buffer) 4.1708 +- wr.is_cpio_flush = 1; 4.1709 +- wr.buffer_index = NULL; 4.1710 + 4.1711 + rc_init(&rc, fill, inbuf, in_len); 4.1712 + 4.1713 + for (i = 0; i < sizeof(header); i++) { 4.1714 + if (rc.ptr >= rc.buffer_end) 4.1715 +- rc_read(&rc); 4.1716 ++ rc_read(&rc, error); 4.1717 + ((unsigned char *)&header)[i] = *rc.ptr++; 4.1718 + } 4.1719 + 4.1720 +@@ -658,34 +607,34 @@ 4.1721 + if (header.dict_size == 0) 4.1722 + header.dict_size = 1; 4.1723 + 4.1724 +- if (output || wr.is_cpio_flush) 4.1725 ++ if (output) 4.1726 + wr.buffer = output; 4.1727 + else { 4.1728 + wr.bufsize = MIN(header.dst_size, header.dict_size); 4.1729 + wr.buffer = large_malloc(wr.bufsize); 4.1730 + } 4.1731 +- if (wr.buffer == NULL && !wr.is_cpio_flush) 4.1732 ++ if (wr.buffer == NULL) 4.1733 + goto exit_1; 4.1734 + 4.1735 + num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp)); 4.1736 + p = (uint16_t *) large_malloc(num_probs * sizeof(*p)); 4.1737 + if (p == 0) 4.1738 + goto exit_2; 4.1739 +- num_probs += LZMA_LITERAL - LZMA_BASE_SIZE; 4.1740 ++ num_probs = LZMA_LITERAL + (LZMA_LIT_SIZE << (lc + lp)); 4.1741 + for (i = 0; i < num_probs; i++) 4.1742 + p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1; 4.1743 +- wr.max_index = wr.next_index = 0; 4.1744 +- rc_init_code(&rc); 4.1745 + 4.1746 ++ rc_init_code(&rc, error); 4.1747 ++ 4.1748 + while (get_pos(&wr) < header.dst_size) { 4.1749 + int pos_state = get_pos(&wr) & pos_state_mask; 4.1750 + uint16_t *prob = p + LZMA_IS_MATCH + 4.1751 + (cst.state << LZMA_NUM_POS_BITS_MAX) + pos_state; 4.1752 +- if (rc_is_bit_0(&rc, prob)) 4.1753 ++ if (rc_is_bit_0(&rc, prob, error)) 4.1754 + process_bit0(&wr, &rc, &cst, p, pos_state, prob, 4.1755 +- lc, literal_pos_mask); 4.1756 ++ lc, literal_pos_mask, error); 4.1757 + else { 4.1758 +- process_bit1(&wr, &rc, &cst, p, pos_state, prob); 4.1759 ++ process_bit1(&wr, &rc, &cst, p, pos_state, prob, error); 4.1760 + if (cst.rep0 == 0) 4.1761 + break; 4.1762 + } 4.1763 +@@ -693,25 +642,12 @@ 4.1764 + 4.1765 + if (posp) 4.1766 + *posp = rc.ptr-rc.buffer; 4.1767 +- if (wr.is_cpio_flush) { 4.1768 +- int i; 4.1769 +- for (i = 0; i < wr.next_index -1; i++) { 4.1770 +- wr.flush(wr.buffer_index[i], LZMA_IOBUF_SIZE); 4.1771 +- large_free(wr.buffer_index[i]); 4.1772 +- } 4.1773 +- if (i < wr.next_index) { 4.1774 +- wr.flush(wr.buffer_index[i], 4.1775 +- wr.buffer_pos % LZMA_IOBUF_SIZE); 4.1776 +- large_free(wr.buffer_index[i]); 4.1777 +- } 4.1778 +- large_free(wr.buffer_index); 4.1779 +- } 4.1780 +- else if (wr.flush) 4.1781 ++ if (wr.flush) 4.1782 + wr.flush(wr.buffer, wr.buffer_pos); 4.1783 + ret = 0; 4.1784 + large_free(p); 4.1785 + exit_2: 4.1786 +- if (!output && !wr.is_cpio_flush) 4.1787 ++ if (!output) 4.1788 + large_free(wr.buffer); 4.1789 + exit_1: 4.1790 + if (!buf) 4.1791 +@@ -719,5 +655,19 @@ 4.1792 + exit_0: 4.1793 + return ret; 4.1794 + } 4.1795 ++#if defined(CONFIG_DECOMPRESS_LZMA_NEEDED) && !defined(PREBOOT) 4.1796 ++EXPORT_SYMBOL(unlzma); 4.1797 ++#endif 4.1798 + 4.1799 +-#define decompress unlzma 4.1800 ++#ifdef PREBOOT 4.1801 ++STATIC int INIT decompress(unsigned char *buf, int in_len, 4.1802 ++ int(*fill)(void*, unsigned int), 4.1803 ++ int(*flush)(void*, unsigned int), 4.1804 ++ unsigned char *output, 4.1805 ++ int *posp, 4.1806 ++ void(*error_fn)(char *x) 4.1807 ++ ) 4.1808 ++{ 4.1809 ++ return unlzma(buf, in_len - 4, fill, flush, output, posp, error_fn); 4.1810 ++} 4.1811 ++#endif
5.1 --- a/tazndis/receipt Sat Jan 02 14:50:04 2010 +0100 5.2 +++ b/tazndis/receipt Sun Jan 03 17:41:36 2010 +0100 5.3 @@ -6,7 +6,6 @@ 5.4 SHORT_DESC="ndiswrapper replacement for SliTaz with a GUI" 5.5 MAINTAINER="erjo@slitaz.org" 5.6 DEPENDS="perl-core wireless_tools ndiswrapper-driver" 5.7 -TARBALL="$PACKAGE-$VERSION.tar.gz" 5.8 WEB_SITE="http://www.slitaz.org" 5.9 5.10 # Rules to gen a SliTaz package suitable for Tazpkg.
6.1 --- a/xfce4/receipt Sat Jan 02 14:50:04 2010 +0100 6.2 +++ b/xfce4/receipt Sun Jan 03 17:41:36 2010 +0100 6.3 @@ -8,7 +8,6 @@ 6.4 DEPENDS="libxfce4util xfconf libxfcegui4 libxfce4menu libexo 6.5 xfce4-panel thunar xfce4-settings xfce4-session xfwm4 xfdesktop thunar-volman 6.6 thunar-archive-plugin xfce-utils xfce4-slitaz-config" 6.7 -TARBALL="$PACKAGE-$VERSION.tar.gz" 6.8 WEB_SITE="http://www.xfce.org" 6.9 6.10 # Rules to gen a SliTaz package suitable for Tazpkg.