wok annotate linux/stuff/linux-squashfs-lzma-2.6.30.6.u @ rev 5056

libgphoto2, scanner: reconfigure udev after addition of new rule
author Rohit Joshi <jozee@slitaz.org>
date Sat Mar 06 19:04:53 2010 +0000 (2010-03-06)
parents
children 6359032279ef
rev   line source
pascal@4701 1 --- linux-2.6.30.6/fs/squashfs/Kconfig
pascal@4701 2 +++ linux-2.6.30.6/fs/squashfs/Kconfig
pascal@4701 3 @@ -26,6 +26,12 @@
pascal@4701 4
pascal@4701 5 If unsure, say N.
pascal@4701 6
pascal@4701 7 +config SQUASHFS_LZMA
pascal@4701 8 + bool "Include support for LZMA compressed file systems"
pascal@4701 9 + depends on SQUASHFS
pascal@4701 10 + select DECOMPRESS_LZMA
pascal@4701 11 + select DECOMPRESS_LZMA_NEEDED
pascal@4701 12 +
pascal@4701 13 config SQUASHFS_EMBEDDED
pascal@4701 14
pascal@4701 15 bool "Additional option for memory-constrained systems"
pascal@4701 16
pascal@4701 17 --- linux-2.6.30.6/fs/squashfs/Makefile
pascal@4701 18 +++ linux-2.6.30.6/fs/squashfs/Makefile
pascal@4701 19 @@ -4,4 +4,5 @@
pascal@4701 20
pascal@4701 21 obj-$(CONFIG_SQUASHFS) += squashfs.o
pascal@4701 22 squashfs-y += block.o cache.o dir.o export.o file.o fragment.o id.o inode.o
pascal@4701 23 -squashfs-y += namei.o super.o symlink.o
pascal@4701 24 +squashfs-y += namei.o super.o symlink.o zlib_wrapper.o decompressor.o
pascal@4701 25 +squashfs-$(CONFIG_SQUASHFS_LZMA) += lzma_wrapper.o
pascal@4701 26
pascal@4701 27 --- linux-2.6.30.6/fs/squashfs/block.c
pascal@4701 28 +++ linux-2.6.30.6/fs/squashfs/block.c
pascal@4701 29 @@ -29,15 +29,14 @@
pascal@4701 30 #include <linux/fs.h>
pascal@4701 31 #include <linux/vfs.h>
pascal@4701 32 #include <linux/slab.h>
pascal@4701 33 -#include <linux/mutex.h>
pascal@4701 34 #include <linux/string.h>
pascal@4701 35 #include <linux/buffer_head.h>
pascal@4701 36 -#include <linux/zlib.h>
pascal@4701 37
pascal@4701 38 #include "squashfs_fs.h"
pascal@4701 39 #include "squashfs_fs_sb.h"
pascal@4701 40 #include "squashfs_fs_i.h"
pascal@4701 41 #include "squashfs.h"
pascal@4701 42 +#include "decompressor.h"
pascal@4701 43
pascal@4701 44 /*
pascal@4701 45 * Read the metadata block length, this is stored in the first two
pascal@4701 46 @@ -153,72 +152,10 @@
pascal@4701 47 }
pascal@4701 48
pascal@4701 49 if (compressed) {
pascal@4701 50 - int zlib_err = 0, zlib_init = 0;
pascal@4701 51 -
pascal@4701 52 - /*
pascal@4701 53 - * Uncompress block.
pascal@4701 54 - */
pascal@4701 55 -
pascal@4701 56 - mutex_lock(&msblk->read_data_mutex);
pascal@4701 57 -
pascal@4701 58 - msblk->stream.avail_out = 0;
pascal@4701 59 - msblk->stream.avail_in = 0;
pascal@4701 60 -
pascal@4701 61 - bytes = length;
pascal@4701 62 - do {
pascal@4701 63 - if (msblk->stream.avail_in == 0 && k < b) {
pascal@4701 64 - avail = min(bytes, msblk->devblksize - offset);
pascal@4701 65 - bytes -= avail;
pascal@4701 66 - wait_on_buffer(bh[k]);
pascal@4701 67 - if (!buffer_uptodate(bh[k]))
pascal@4701 68 - goto release_mutex;
pascal@4701 69 -
pascal@4701 70 - if (avail == 0) {
pascal@4701 71 - offset = 0;
pascal@4701 72 - put_bh(bh[k++]);
pascal@4701 73 - continue;
pascal@4701 74 - }
pascal@4701 75 -
pascal@4701 76 - msblk->stream.next_in = bh[k]->b_data + offset;
pascal@4701 77 - msblk->stream.avail_in = avail;
pascal@4701 78 - offset = 0;
pascal@4701 79 - }
pascal@4701 80 -
pascal@4701 81 - if (msblk->stream.avail_out == 0 && page < pages) {
pascal@4701 82 - msblk->stream.next_out = buffer[page++];
pascal@4701 83 - msblk->stream.avail_out = PAGE_CACHE_SIZE;
pascal@4701 84 - }
pascal@4701 85 -
pascal@4701 86 - if (!zlib_init) {
pascal@4701 87 - zlib_err = zlib_inflateInit(&msblk->stream);
pascal@4701 88 - if (zlib_err != Z_OK) {
pascal@4701 89 - ERROR("zlib_inflateInit returned"
pascal@4701 90 - " unexpected result 0x%x,"
pascal@4701 91 - " srclength %d\n", zlib_err,
pascal@4701 92 - srclength);
pascal@4701 93 - goto release_mutex;
pascal@4701 94 - }
pascal@4701 95 - zlib_init = 1;
pascal@4701 96 - }
pascal@4701 97 -
pascal@4701 98 - zlib_err = zlib_inflate(&msblk->stream, Z_SYNC_FLUSH);
pascal@4701 99 -
pascal@4701 100 - if (msblk->stream.avail_in == 0 && k < b)
pascal@4701 101 - put_bh(bh[k++]);
pascal@4701 102 - } while (zlib_err == Z_OK);
pascal@4701 103 -
pascal@4701 104 - if (zlib_err != Z_STREAM_END) {
pascal@4701 105 - ERROR("zlib_inflate error, data probably corrupt\n");
pascal@4701 106 - goto release_mutex;
pascal@4701 107 - }
pascal@4701 108 -
pascal@4701 109 - zlib_err = zlib_inflateEnd(&msblk->stream);
pascal@4701 110 - if (zlib_err != Z_OK) {
pascal@4701 111 - ERROR("zlib_inflate error, data probably corrupt\n");
pascal@4701 112 - goto release_mutex;
pascal@4701 113 - }
pascal@4701 114 - length = msblk->stream.total_out;
pascal@4701 115 - mutex_unlock(&msblk->read_data_mutex);
pascal@4701 116 + length = squashfs_decompress(msblk, buffer, bh, b, offset,
pascal@4701 117 + length, srclength, pages);
pascal@4701 118 + if (length < 0)
pascal@4701 119 + goto read_failure;
pascal@4701 120 } else {
pascal@4701 121 /*
pascal@4701 122 * Block is uncompressed.
pascal@4701 123 @@ -254,9 +191,6 @@
pascal@4701 124
pascal@4701 125 kfree(bh);
pascal@4701 126 return length;
pascal@4701 127 -
pascal@4701 128 -release_mutex:
pascal@4701 129 - mutex_unlock(&msblk->read_data_mutex);
pascal@4701 130
pascal@4701 131 block_release:
pascal@4701 132 for (; k < b; k++)
pascal@4701 133
pascal@4701 134 --- linux-2.6.30.6/fs/squashfs/cache.c
pascal@4701 135 +++ linux-2.6.30.6/fs/squashfs/cache.c
pascal@4701 136 @@ -51,7 +51,6 @@
pascal@4701 137 #include <linux/sched.h>
pascal@4701 138 #include <linux/spinlock.h>
pascal@4701 139 #include <linux/wait.h>
pascal@4701 140 -#include <linux/zlib.h>
pascal@4701 141 #include <linux/pagemap.h>
pascal@4701 142
pascal@4701 143 #include "squashfs_fs.h"
pascal@4701 144
pascal@4701 145 --- linux-2.6.30.6/fs/squashfs/decompressor.c
pascal@4701 146 +++ linux-2.6.30.6/fs/squashfs/decompressor.c
pascal@4701 147 @@ -0,0 +1,72 @@
pascal@4701 148 +/*
pascal@4701 149 + * Squashfs - a compressed read only filesystem for Linux
pascal@4701 150 + *
pascal@4701 151 + * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
pascal@4701 152 + * Phillip Lougher <phillip@lougher.demon.co.uk>
pascal@4701 153 + *
pascal@4701 154 + * This program is free software; you can redistribute it and/or
pascal@4701 155 + * modify it under the terms of the GNU General Public License
pascal@4701 156 + * as published by the Free Software Foundation; either version 2,
pascal@4701 157 + * or (at your option) any later version.
pascal@4701 158 + *
pascal@4701 159 + * This program is distributed in the hope that it will be useful,
pascal@4701 160 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
pascal@4701 161 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
pascal@4701 162 + * GNU General Public License for more details.
pascal@4701 163 + *
pascal@4701 164 + * You should have received a copy of the GNU General Public License
pascal@4701 165 + * along with this program; if not, write to the Free Software
pascal@4701 166 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
pascal@4701 167 + *
pascal@4701 168 + * decompressor.c
pascal@4701 169 + */
pascal@4701 170 +
pascal@4701 171 +#include <linux/types.h>
pascal@4701 172 +#include <linux/mutex.h>
pascal@4701 173 +#include <linux/buffer_head.h>
pascal@4701 174 +
pascal@4701 175 +#include "squashfs_fs.h"
pascal@4701 176 +#include "squashfs_fs_sb.h"
pascal@4701 177 +#include "squashfs_fs_i.h"
pascal@4701 178 +#include "decompressor.h"
pascal@4701 179 +#include "squashfs.h"
pascal@4701 180 +
pascal@4701 181 +/*
pascal@4701 182 + * This file (and decompressor.h) implements a decompressor framework for
pascal@4701 183 + * Squashfs, allowing multiple decompressors to be easily supported
pascal@4701 184 + */
pascal@4701 185 +
pascal@4701 186 +static const struct squashfs_decompressor squashfs_lzma_unsupported_comp_ops = {
pascal@4701 187 + NULL, NULL, NULL, LZMA_COMPRESSION, "lzma", 0
pascal@4701 188 +};
pascal@4701 189 +
pascal@4701 190 +static const struct squashfs_decompressor squashfs_lzo_unsupported_comp_ops = {
pascal@4701 191 + NULL, NULL, NULL, LZO_COMPRESSION, "lzo", 0
pascal@4701 192 +};
pascal@4701 193 +
pascal@4701 194 +static const struct squashfs_decompressor squashfs_unknown_comp_ops = {
pascal@4701 195 + NULL, NULL, NULL, 0, "unknown", 0
pascal@4701 196 +};
pascal@4701 197 +
pascal@4701 198 +static const struct squashfs_decompressor *decompressor[] = {
pascal@4701 199 + &squashfs_zlib_comp_ops,
pascal@4701 200 +#ifdef CONFIG_SQUASHFS_LZMA
pascal@4701 201 + &squashfs_lzma_comp_ops,
pascal@4701 202 +#else
pascal@4701 203 + &squashfs_lzma_unsupported_comp_ops,
pascal@4701 204 +#endif
pascal@4701 205 + &squashfs_lzo_unsupported_comp_ops,
pascal@4701 206 + &squashfs_unknown_comp_ops
pascal@4701 207 +};
pascal@4701 208 +
pascal@4701 209 +
pascal@4701 210 +const struct squashfs_decompressor *squashfs_lookup_decompressor(int id)
pascal@4701 211 +{
pascal@4701 212 + int i;
pascal@4701 213 +
pascal@4701 214 + for (i = 0; decompressor[i]->id; i++)
pascal@4701 215 + if (id == decompressor[i]->id)
pascal@4701 216 + break;
pascal@4701 217 +
pascal@4701 218 + return decompressor[i];
pascal@4701 219 +}
pascal@4701 220
pascal@4701 221 --- linux-2.6.30.6/fs/squashfs/decompressor.h
pascal@4701 222 +++ linux-2.6.30.6/fs/squashfs/decompressor.h
pascal@4701 223 @@ -0,0 +1,55 @@
pascal@4701 224 +#ifndef DECOMPRESSOR_H
pascal@4701 225 +#define DECOMPRESSOR_H
pascal@4701 226 +/*
pascal@4701 227 + * Squashfs - a compressed read only filesystem for Linux
pascal@4701 228 + *
pascal@4701 229 + * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
pascal@4701 230 + * Phillip Lougher <phillip@lougher.demon.co.uk>
pascal@4701 231 + *
pascal@4701 232 + * This program is free software; you can redistribute it and/or
pascal@4701 233 + * modify it under the terms of the GNU General Public License
pascal@4701 234 + * as published by the Free Software Foundation; either version 2,
pascal@4701 235 + * or (at your option) any later version.
pascal@4701 236 + *
pascal@4701 237 + * This program is distributed in the hope that it will be useful,
pascal@4701 238 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
pascal@4701 239 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
pascal@4701 240 + * GNU General Public License for more details.
pascal@4701 241 + *
pascal@4701 242 + * You should have received a copy of the GNU General Public License
pascal@4701 243 + * along with this program; if not, write to the Free Software
pascal@4701 244 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
pascal@4701 245 + *
pascal@4701 246 + * decompressor.h
pascal@4701 247 + */
pascal@4701 248 +
pascal@4701 249 +struct squashfs_decompressor {
pascal@4701 250 + void *(*init)(struct squashfs_sb_info *);
pascal@4701 251 + void (*free)(void *);
pascal@4701 252 + int (*decompress)(struct squashfs_sb_info *, void **,
pascal@4701 253 + struct buffer_head **, int, int, int, int, int);
pascal@4701 254 + int id;
pascal@4701 255 + char *name;
pascal@4701 256 + int supported;
pascal@4701 257 +};
pascal@4701 258 +
pascal@4701 259 +static inline void *squashfs_decompressor_init(struct squashfs_sb_info *msblk)
pascal@4701 260 +{
pascal@4701 261 + return msblk->decompressor->init(msblk);
pascal@4701 262 +}
pascal@4701 263 +
pascal@4701 264 +static inline void squashfs_decompressor_free(struct squashfs_sb_info *msblk,
pascal@4701 265 + void *s)
pascal@4701 266 +{
pascal@4701 267 + if (msblk->decompressor)
pascal@4701 268 + msblk->decompressor->free(s);
pascal@4701 269 +}
pascal@4701 270 +
pascal@4701 271 +static inline int squashfs_decompress(struct squashfs_sb_info *msblk,
pascal@4701 272 + void **buffer, struct buffer_head **bh, int b, int offset, int length,
pascal@4701 273 + int srclength, int pages)
pascal@4701 274 +{
pascal@4701 275 + return msblk->decompressor->decompress(msblk, buffer, bh, b, offset,
pascal@4701 276 + length, srclength, pages);
pascal@4701 277 +}
pascal@4701 278 +#endif
pascal@4701 279
pascal@4701 280 --- linux-2.6.30.6/fs/squashfs/dir.c
pascal@4701 281 +++ linux-2.6.30.6/fs/squashfs/dir.c
pascal@4701 282 @@ -30,7 +30,6 @@
pascal@4701 283 #include <linux/fs.h>
pascal@4701 284 #include <linux/vfs.h>
pascal@4701 285 #include <linux/slab.h>
pascal@4701 286 -#include <linux/zlib.h>
pascal@4701 287
pascal@4701 288 #include "squashfs_fs.h"
pascal@4701 289 #include "squashfs_fs_sb.h"
pascal@4701 290
pascal@4701 291 --- linux-2.6.30.6/fs/squashfs/export.c
pascal@4701 292 +++ linux-2.6.30.6/fs/squashfs/export.c
pascal@4701 293 @@ -39,7 +39,6 @@
pascal@4701 294 #include <linux/vfs.h>
pascal@4701 295 #include <linux/dcache.h>
pascal@4701 296 #include <linux/exportfs.h>
pascal@4701 297 -#include <linux/zlib.h>
pascal@4701 298 #include <linux/slab.h>
pascal@4701 299
pascal@4701 300 #include "squashfs_fs.h"
pascal@4701 301
pascal@4701 302 --- linux-2.6.30.6/fs/squashfs/file.c
pascal@4701 303 +++ linux-2.6.30.6/fs/squashfs/file.c
pascal@4701 304 @@ -47,7 +47,6 @@
pascal@4701 305 #include <linux/string.h>
pascal@4701 306 #include <linux/pagemap.h>
pascal@4701 307 #include <linux/mutex.h>
pascal@4701 308 -#include <linux/zlib.h>
pascal@4701 309
pascal@4701 310 #include "squashfs_fs.h"
pascal@4701 311 #include "squashfs_fs_sb.h"
pascal@4701 312
pascal@4701 313 --- linux-2.6.30.6/fs/squashfs/fragment.c
pascal@4701 314 +++ linux-2.6.30.6/fs/squashfs/fragment.c
pascal@4701 315 @@ -36,7 +36,6 @@
pascal@4701 316 #include <linux/fs.h>
pascal@4701 317 #include <linux/vfs.h>
pascal@4701 318 #include <linux/slab.h>
pascal@4701 319 -#include <linux/zlib.h>
pascal@4701 320
pascal@4701 321 #include "squashfs_fs.h"
pascal@4701 322 #include "squashfs_fs_sb.h"
pascal@4701 323
pascal@4701 324 --- linux-2.6.30.6/fs/squashfs/id.c
pascal@4701 325 +++ linux-2.6.30.6/fs/squashfs/id.c
pascal@4701 326 @@ -34,7 +34,6 @@
pascal@4701 327 #include <linux/fs.h>
pascal@4701 328 #include <linux/vfs.h>
pascal@4701 329 #include <linux/slab.h>
pascal@4701 330 -#include <linux/zlib.h>
pascal@4701 331
pascal@4701 332 #include "squashfs_fs.h"
pascal@4701 333 #include "squashfs_fs_sb.h"
pascal@4701 334
pascal@4701 335 --- linux-2.6.30.6/fs/squashfs/inode.c
pascal@4701 336 +++ linux-2.6.30.6/fs/squashfs/inode.c
pascal@4701 337 @@ -40,7 +40,6 @@
pascal@4701 338
pascal@4701 339 #include <linux/fs.h>
pascal@4701 340 #include <linux/vfs.h>
pascal@4701 341 -#include <linux/zlib.h>
pascal@4701 342
pascal@4701 343 #include "squashfs_fs.h"
pascal@4701 344 #include "squashfs_fs_sb.h"
pascal@4701 345
pascal@4701 346 --- linux-2.6.30.6/fs/squashfs/lzma_wrapper.c
pascal@4701 347 +++ linux-2.6.30.6/fs/squashfs/lzma_wrapper.c
pascal@4701 348 @@ -0,0 +1,151 @@
pascal@4701 349 +/*
pascal@4701 350 + * Squashfs - a compressed read only filesystem for Linux
pascal@4701 351 + *
pascal@4701 352 + * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
pascal@4701 353 + * Phillip Lougher <phillip@lougher.demon.co.uk>
pascal@4701 354 + *
pascal@4701 355 + * This program is free software; you can redistribute it and/or
pascal@4701 356 + * modify it under the terms of the GNU General Public License
pascal@4701 357 + * as published by the Free Software Foundation; either version 2,
pascal@4701 358 + * or (at your option) any later version.
pascal@4701 359 + *
pascal@4701 360 + * This program is distributed in the hope that it will be useful,
pascal@4701 361 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
pascal@4701 362 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
pascal@4701 363 + * GNU General Public License for more details.
pascal@4701 364 + *
pascal@4701 365 + * You should have received a copy of the GNU General Public License
pascal@4701 366 + * along with this program; if not, write to the Free Software
pascal@4701 367 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
pascal@4701 368 + *
pascal@4701 369 + * lzma_wrapper.c
pascal@4701 370 + */
pascal@4701 371 +
pascal@4701 372 +#include <asm/unaligned.h>
pascal@4701 373 +#include <linux/buffer_head.h>
pascal@4701 374 +#include <linux/mutex.h>
pascal@4701 375 +#include <linux/vmalloc.h>
pascal@4701 376 +#include <linux/decompress/unlzma.h>
pascal@4701 377 +
pascal@4701 378 +#include "squashfs_fs.h"
pascal@4701 379 +#include "squashfs_fs_sb.h"
pascal@4701 380 +#include "squashfs_fs_i.h"
pascal@4701 381 +#include "squashfs.h"
pascal@4701 382 +#include "decompressor.h"
pascal@4701 383 +
pascal@4701 384 +struct squashfs_lzma {
pascal@4701 385 + void *input;
pascal@4701 386 + void *output;
pascal@4701 387 +};
pascal@4701 388 +
pascal@4701 389 +/* decompress_unlzma.c is currently non re-entrant... */
pascal@4701 390 +DEFINE_MUTEX(lzma_mutex);
pascal@4701 391 +
pascal@4701 392 +/* decompress_unlzma.c doesn't provide any context in its callbacks... */
pascal@4701 393 +static int lzma_error;
pascal@4701 394 +
pascal@4701 395 +static void error(char *m)
pascal@4701 396 +{
pascal@4701 397 + ERROR("unlzma error: %s\n", m);
pascal@4701 398 + lzma_error = 1;
pascal@4701 399 +}
pascal@4701 400 +
pascal@4701 401 +
pascal@4701 402 +static void *lzma_init(struct squashfs_sb_info *msblk)
pascal@4701 403 +{
pascal@4701 404 + struct squashfs_lzma *stream = kzalloc(sizeof(*stream), GFP_KERNEL);
pascal@4701 405 + if (stream == NULL)
pascal@4701 406 + goto failed;
pascal@4701 407 + stream->input = vmalloc(msblk->block_size);
pascal@4701 408 + if (stream->input == NULL)
pascal@4701 409 + goto failed;
pascal@4701 410 + stream->output = vmalloc(msblk->block_size);
pascal@4701 411 + if (stream->output == NULL)
pascal@4701 412 + goto failed2;
pascal@4701 413 +
pascal@4701 414 + return stream;
pascal@4701 415 +
pascal@4701 416 +failed2:
pascal@4701 417 + vfree(stream->input);
pascal@4701 418 +failed:
pascal@4701 419 + ERROR("failed to allocate lzma workspace\n");
pascal@4701 420 + kfree(stream);
pascal@4701 421 + return NULL;
pascal@4701 422 +}
pascal@4701 423 +
pascal@4701 424 +
pascal@4701 425 +static void lzma_free(void *strm)
pascal@4701 426 +{
pascal@4701 427 + struct squashfs_lzma *stream = strm;
pascal@4701 428 +
pascal@4701 429 + if (stream) {
pascal@4701 430 + vfree(stream->input);
pascal@4701 431 + vfree(stream->output);
pascal@4701 432 + }
pascal@4701 433 + kfree(stream);
pascal@4701 434 +}
pascal@4701 435 +
pascal@4701 436 +
pascal@4701 437 +static int lzma_uncompress(struct squashfs_sb_info *msblk, void **buffer,
pascal@4701 438 + struct buffer_head **bh, int b, int offset, int length, int srclength,
pascal@4701 439 + int pages)
pascal@4701 440 +{
pascal@4701 441 + struct squashfs_lzma *stream = msblk->stream;
pascal@4701 442 + void *buff = stream->input;
pascal@4701 443 + int avail, i, bytes = length, res;
pascal@4701 444 +
pascal@4701 445 + mutex_lock(&lzma_mutex);
pascal@4701 446 +
pascal@4701 447 + for (i = 0; i < b; i++) {
pascal@4701 448 + wait_on_buffer(bh[i]);
pascal@4701 449 + if (!buffer_uptodate(bh[i]))
pascal@4701 450 + goto block_release;
pascal@4701 451 +
pascal@4701 452 + avail = min(bytes, msblk->devblksize - offset);
pascal@4701 453 + memcpy(buff, bh[i]->b_data + offset, avail);
pascal@4701 454 + buff += avail;
pascal@4701 455 + bytes -= avail;
pascal@4701 456 + offset = 0;
pascal@4701 457 + put_bh(bh[i]);
pascal@4701 458 + }
pascal@4701 459 +
pascal@4701 460 + lzma_error = 0;
pascal@4701 461 + res = unlzma(stream->input, length, NULL, NULL, stream->output, NULL,
pascal@4701 462 + error);
pascal@4701 463 + if (res || lzma_error)
pascal@4701 464 + goto failed;
pascal@4701 465 +
pascal@4701 466 + /* uncompressed size is stored in the LZMA header (5 byte offset) */
pascal@4701 467 + res = bytes = get_unaligned_le32(stream->input + 5);
pascal@4701 468 + for (i = 0, buff = stream->output; bytes && i < pages; i++) {
pascal@4701 469 + avail = min_t(int, bytes, PAGE_CACHE_SIZE);
pascal@4701 470 + memcpy(buffer[i], buff, avail);
pascal@4701 471 + buff += avail;
pascal@4701 472 + bytes -= avail;
pascal@4701 473 + }
pascal@4701 474 + if (bytes)
pascal@4701 475 + goto failed;
pascal@4701 476 +
pascal@4701 477 + mutex_unlock(&lzma_mutex);
pascal@4701 478 + return res;
pascal@4701 479 +
pascal@4701 480 +block_release:
pascal@4701 481 + for (; i < b; i++)
pascal@4701 482 + put_bh(bh[i]);
pascal@4701 483 +
pascal@4701 484 +failed:
pascal@4701 485 + mutex_unlock(&lzma_mutex);
pascal@4701 486 +
pascal@4701 487 + ERROR("lzma decompression failed, data probably corrupt\n");
pascal@4701 488 + return -EIO;
pascal@4701 489 +}
pascal@4701 490 +
pascal@4701 491 +const struct squashfs_decompressor squashfs_lzma_comp_ops = {
pascal@4701 492 + .init = lzma_init,
pascal@4701 493 + .free = lzma_free,
pascal@4701 494 + .decompress = lzma_uncompress,
pascal@4701 495 + .id = LZMA_COMPRESSION,
pascal@4701 496 + .name = "lzma",
pascal@4701 497 + .supported = 1
pascal@4701 498 +};
pascal@4701 499 +
pascal@4701 500
pascal@4701 501 --- linux-2.6.30.6/fs/squashfs/namei.c
pascal@4701 502 +++ linux-2.6.30.6/fs/squashfs/namei.c
pascal@4701 503 @@ -57,7 +57,6 @@
pascal@4701 504 #include <linux/slab.h>
pascal@4701 505 #include <linux/string.h>
pascal@4701 506 #include <linux/dcache.h>
pascal@4701 507 -#include <linux/zlib.h>
pascal@4701 508
pascal@4701 509 #include "squashfs_fs.h"
pascal@4701 510 #include "squashfs_fs_sb.h"
pascal@4701 511
pascal@4701 512 --- linux-2.6.30.6/fs/squashfs/squashfs.h
pascal@4701 513 +++ linux-2.6.30.6/fs/squashfs/squashfs.h
pascal@4701 514 @@ -51,6 +51,9 @@
pascal@4701 515 u64, int);
pascal@4701 516 extern int squashfs_read_table(struct super_block *, void *, u64, int);
pascal@4701 517
pascal@4701 518 +/* decompressor.c */
pascal@4701 519 +extern const struct squashfs_decompressor *squashfs_lookup_decompressor(int);
pascal@4701 520 +
pascal@4701 521 /* export.c */
pascal@4701 522 extern __le64 *squashfs_read_inode_lookup_table(struct super_block *, u64,
pascal@4701 523 unsigned int);
pascal@4701 524 @@ -71,7 +74,7 @@
pascal@4701 525 extern int squashfs_read_inode(struct inode *, long long);
pascal@4701 526
pascal@4701 527 /*
pascal@4701 528 - * Inodes and files operations
pascal@4701 529 + * Inodes, files and decompressor operations
pascal@4701 530 */
pascal@4701 531
pascal@4701 532 /* dir.c */
pascal@4701 533 @@ -88,3 +91,9 @@
pascal@4701 534
pascal@4701 535 /* symlink.c */
pascal@4701 536 extern const struct address_space_operations squashfs_symlink_aops;
pascal@4701 537 +
pascal@4701 538 +/* zlib_wrapper.c */
pascal@4701 539 +extern const struct squashfs_decompressor squashfs_zlib_comp_ops;
pascal@4701 540 +
pascal@4701 541 +/* lzma wrapper.c */
pascal@4701 542 +extern const struct squashfs_decompressor squashfs_lzma_comp_ops;
pascal@4701 543
pascal@4701 544 --- linux-2.6.30.6/fs/squashfs/squashfs_fs.h
pascal@4701 545 +++ linux-2.6.30.6/fs/squashfs/squashfs_fs.h
pascal@4701 546 @@ -211,7 +211,9 @@
pascal@4701 547 /*
pascal@4701 548 * definitions for structures on disk
pascal@4701 549 */
pascal@4701 550 -#define ZLIB_COMPRESSION 1
pascal@4701 551 +#define ZLIB_COMPRESSION 1
pascal@4701 552 +#define LZMA_COMPRESSION 2
pascal@4701 553 +#define LZO_COMPRESSION 3
pascal@4701 554
pascal@4701 555 struct squashfs_super_block {
pascal@4701 556 __le32 s_magic;
pascal@4701 557
pascal@4701 558 --- linux-2.6.30.6/fs/squashfs/squashfs_fs_sb.h
pascal@4701 559 +++ linux-2.6.30.6/fs/squashfs/squashfs_fs_sb.h
pascal@4701 560 @@ -52,25 +52,26 @@
pascal@4701 561 };
pascal@4701 562
pascal@4701 563 struct squashfs_sb_info {
pascal@4701 564 - int devblksize;
pascal@4701 565 - int devblksize_log2;
pascal@4701 566 - struct squashfs_cache *block_cache;
pascal@4701 567 - struct squashfs_cache *fragment_cache;
pascal@4701 568 - struct squashfs_cache *read_page;
pascal@4701 569 - int next_meta_index;
pascal@4701 570 - __le64 *id_table;
pascal@4701 571 - __le64 *fragment_index;
pascal@4701 572 - unsigned int *fragment_index_2;
pascal@4701 573 - struct mutex read_data_mutex;
pascal@4701 574 - struct mutex meta_index_mutex;
pascal@4701 575 - struct meta_index *meta_index;
pascal@4701 576 - z_stream stream;
pascal@4701 577 - __le64 *inode_lookup_table;
pascal@4701 578 - u64 inode_table;
pascal@4701 579 - u64 directory_table;
pascal@4701 580 - unsigned int block_size;
pascal@4701 581 - unsigned short block_log;
pascal@4701 582 - long long bytes_used;
pascal@4701 583 - unsigned int inodes;
pascal@4701 584 + const struct squashfs_decompressor *decompressor;
pascal@4701 585 + int devblksize;
pascal@4701 586 + int devblksize_log2;
pascal@4701 587 + struct squashfs_cache *block_cache;
pascal@4701 588 + struct squashfs_cache *fragment_cache;
pascal@4701 589 + struct squashfs_cache *read_page;
pascal@4701 590 + int next_meta_index;
pascal@4701 591 + __le64 *id_table;
pascal@4701 592 + __le64 *fragment_index;
pascal@4701 593 + unsigned int *fragment_index_2;
pascal@4701 594 + struct mutex read_data_mutex;
pascal@4701 595 + struct mutex meta_index_mutex;
pascal@4701 596 + struct meta_index *meta_index;
pascal@4701 597 + void *stream;
pascal@4701 598 + __le64 *inode_lookup_table;
pascal@4701 599 + u64 inode_table;
pascal@4701 600 + u64 directory_table;
pascal@4701 601 + unsigned int block_size;
pascal@4701 602 + unsigned short block_log;
pascal@4701 603 + long long bytes_used;
pascal@4701 604 + unsigned int inodes;
pascal@4701 605 };
pascal@4701 606 #endif
pascal@4701 607
pascal@4701 608 --- linux-2.6.30.6/fs/squashfs/super.c
pascal@4701 609 +++ linux-2.6.30.6/fs/squashfs/super.c
pascal@4701 610 @@ -30,38 +30,46 @@
pascal@4701 611 #include <linux/fs.h>
pascal@4701 612 #include <linux/vfs.h>
pascal@4701 613 #include <linux/slab.h>
pascal@4701 614 +#include <linux/smp_lock.h>
pascal@4701 615 #include <linux/mutex.h>
pascal@4701 616 #include <linux/pagemap.h>
pascal@4701 617 #include <linux/init.h>
pascal@4701 618 #include <linux/module.h>
pascal@4701 619 -#include <linux/zlib.h>
pascal@4701 620 #include <linux/magic.h>
pascal@4701 621
pascal@4701 622 #include "squashfs_fs.h"
pascal@4701 623 #include "squashfs_fs_sb.h"
pascal@4701 624 #include "squashfs_fs_i.h"
pascal@4701 625 #include "squashfs.h"
pascal@4701 626 +#include "decompressor.h"
pascal@4701 627
pascal@4701 628 static struct file_system_type squashfs_fs_type;
pascal@4701 629 -static struct super_operations squashfs_super_ops;
pascal@4701 630 +static const struct super_operations squashfs_super_ops;
pascal@4701 631
pascal@4701 632 -static int supported_squashfs_filesystem(short major, short minor, short comp)
pascal@4701 633 +static const struct squashfs_decompressor *supported_squashfs_filesystem(short
pascal@4701 634 + major, short minor, short id)
pascal@4701 635 {
pascal@4701 636 + const struct squashfs_decompressor *decompressor;
pascal@4701 637 +
pascal@4701 638 if (major < SQUASHFS_MAJOR) {
pascal@4701 639 ERROR("Major/Minor mismatch, older Squashfs %d.%d "
pascal@4701 640 "filesystems are unsupported\n", major, minor);
pascal@4701 641 - return -EINVAL;
pascal@4701 642 + return NULL;
pascal@4701 643 } else if (major > SQUASHFS_MAJOR || minor > SQUASHFS_MINOR) {
pascal@4701 644 ERROR("Major/Minor mismatch, trying to mount newer "
pascal@4701 645 "%d.%d filesystem\n", major, minor);
pascal@4701 646 ERROR("Please update your kernel\n");
pascal@4701 647 - return -EINVAL;
pascal@4701 648 + return NULL;
pascal@4701 649 }
pascal@4701 650
pascal@4701 651 - if (comp != ZLIB_COMPRESSION)
pascal@4701 652 - return -EINVAL;
pascal@4701 653 + decompressor = squashfs_lookup_decompressor(id);
pascal@4701 654 + if (!decompressor->supported) {
pascal@4701 655 + ERROR("Filesystem uses \"%s\" compression. This is not "
pascal@4701 656 + "supported\n", decompressor->name);
pascal@4701 657 + return NULL;
pascal@4701 658 + }
pascal@4701 659
pascal@4701 660 - return 0;
pascal@4701 661 + return decompressor;
pascal@4701 662 }
pascal@4701 663
pascal@4701 664
pascal@4701 665 @@ -86,13 +94,6 @@
pascal@4701 666 }
pascal@4701 667 msblk = sb->s_fs_info;
pascal@4701 668
pascal@4701 669 - msblk->stream.workspace = kmalloc(zlib_inflate_workspacesize(),
pascal@4701 670 - GFP_KERNEL);
pascal@4701 671 - if (msblk->stream.workspace == NULL) {
pascal@4701 672 - ERROR("Failed to allocate zlib workspace\n");
pascal@4701 673 - goto failure;
pascal@4701 674 - }
pascal@4701 675 -
pascal@4701 676 sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
pascal@4701 677 if (sblk == NULL) {
pascal@4701 678 ERROR("Failed to allocate squashfs_super_block\n");
pascal@4701 679 @@ -119,25 +120,25 @@
pascal@4701 680 goto failed_mount;
pascal@4701 681 }
pascal@4701 682
pascal@4701 683 + err = -EINVAL;
pascal@4701 684 +
pascal@4701 685 /* Check it is a SQUASHFS superblock */
pascal@4701 686 sb->s_magic = le32_to_cpu(sblk->s_magic);
pascal@4701 687 if (sb->s_magic != SQUASHFS_MAGIC) {
pascal@4701 688 if (!silent)
pascal@4701 689 ERROR("Can't find a SQUASHFS superblock on %s\n",
pascal@4701 690 bdevname(sb->s_bdev, b));
pascal@4701 691 - err = -EINVAL;
pascal@4701 692 goto failed_mount;
pascal@4701 693 }
pascal@4701 694
pascal@4701 695 - /* Check the MAJOR & MINOR versions and compression type */
pascal@4701 696 - err = supported_squashfs_filesystem(le16_to_cpu(sblk->s_major),
pascal@4701 697 + /* Check the MAJOR & MINOR versions and lookup compression type */
pascal@4701 698 + msblk->decompressor = supported_squashfs_filesystem(
pascal@4701 699 + le16_to_cpu(sblk->s_major),
pascal@4701 700 le16_to_cpu(sblk->s_minor),
pascal@4701 701 le16_to_cpu(sblk->compression));
pascal@4701 702 - if (err < 0)
pascal@4701 703 + if (msblk->decompressor == NULL)
pascal@4701 704 goto failed_mount;
pascal@4701 705
pascal@4701 706 - err = -EINVAL;
pascal@4701 707 -
pascal@4701 708 /*
pascal@4701 709 * Check if there's xattrs in the filesystem. These are not
pascal@4701 710 * supported in this version, so warn that they will be ignored.
pascal@4701 711 @@ -204,6 +205,10 @@
pascal@4701 712
pascal@4701 713 err = -ENOMEM;
pascal@4701 714
pascal@4701 715 + msblk->stream = squashfs_decompressor_init(msblk);
pascal@4701 716 + if (msblk->stream == NULL)
pascal@4701 717 + goto failed_mount;
pascal@4701 718 +
pascal@4701 719 msblk->block_cache = squashfs_cache_init("metadata",
pascal@4701 720 SQUASHFS_CACHED_BLKS, SQUASHFS_METADATA_SIZE);
pascal@4701 721 if (msblk->block_cache == NULL)
pascal@4701 722 @@ -291,17 +296,16 @@
pascal@4701 723 squashfs_cache_delete(msblk->block_cache);
pascal@4701 724 squashfs_cache_delete(msblk->fragment_cache);
pascal@4701 725 squashfs_cache_delete(msblk->read_page);
pascal@4701 726 + squashfs_decompressor_free(msblk, msblk->stream);
pascal@4701 727 kfree(msblk->inode_lookup_table);
pascal@4701 728 kfree(msblk->fragment_index);
pascal@4701 729 kfree(msblk->id_table);
pascal@4701 730 - kfree(msblk->stream.workspace);
pascal@4701 731 kfree(sb->s_fs_info);
pascal@4701 732 sb->s_fs_info = NULL;
pascal@4701 733 kfree(sblk);
pascal@4701 734 return err;
pascal@4701 735
pascal@4701 736 failure:
pascal@4701 737 - kfree(msblk->stream.workspace);
pascal@4701 738 kfree(sb->s_fs_info);
pascal@4701 739 sb->s_fs_info = NULL;
pascal@4701 740 return -ENOMEM;
pascal@4701 741 @@ -338,18 +342,22 @@
pascal@4701 742
pascal@4701 743 static void squashfs_put_super(struct super_block *sb)
pascal@4701 744 {
pascal@4701 745 + lock_kernel();
pascal@4701 746 +
pascal@4701 747 if (sb->s_fs_info) {
pascal@4701 748 struct squashfs_sb_info *sbi = sb->s_fs_info;
pascal@4701 749 squashfs_cache_delete(sbi->block_cache);
pascal@4701 750 squashfs_cache_delete(sbi->fragment_cache);
pascal@4701 751 squashfs_cache_delete(sbi->read_page);
pascal@4701 752 + squashfs_decompressor_free(sbi, sbi->stream);
pascal@4701 753 kfree(sbi->id_table);
pascal@4701 754 kfree(sbi->fragment_index);
pascal@4701 755 kfree(sbi->meta_index);
pascal@4701 756 - kfree(sbi->stream.workspace);
pascal@4701 757 kfree(sb->s_fs_info);
pascal@4701 758 sb->s_fs_info = NULL;
pascal@4701 759 }
pascal@4701 760 +
pascal@4701 761 + unlock_kernel();
pascal@4701 762 }
pascal@4701 763
pascal@4701 764
pascal@4701 765 @@ -439,7 +447,7 @@
pascal@4701 766 .fs_flags = FS_REQUIRES_DEV
pascal@4701 767 };
pascal@4701 768
pascal@4701 769 -static struct super_operations squashfs_super_ops = {
pascal@4701 770 +static const struct super_operations squashfs_super_ops = {
pascal@4701 771 .alloc_inode = squashfs_alloc_inode,
pascal@4701 772 .destroy_inode = squashfs_destroy_inode,
pascal@4701 773 .statfs = squashfs_statfs,
pascal@4701 774
pascal@4701 775 --- linux-2.6.30.6/fs/squashfs/symlink.c
pascal@4701 776 +++ linux-2.6.30.6/fs/squashfs/symlink.c
pascal@4701 777 @@ -36,7 +36,6 @@
pascal@4701 778 #include <linux/slab.h>
pascal@4701 779 #include <linux/string.h>
pascal@4701 780 #include <linux/pagemap.h>
pascal@4701 781 -#include <linux/zlib.h>
pascal@4701 782
pascal@4701 783 #include "squashfs_fs.h"
pascal@4701 784 #include "squashfs_fs_sb.h"
pascal@4701 785
pascal@4701 786 --- linux-2.6.30.6/fs/squashfs/zlib_wrapper.c
pascal@4701 787 +++ linux-2.6.30.6/fs/squashfs/zlib_wrapper.c
pascal@4701 788 @@ -0,0 +1,150 @@
pascal@4701 789 +/*
pascal@4701 790 + * Squashfs - a compressed read only filesystem for Linux
pascal@4701 791 + *
pascal@4701 792 + * Copyright (c) 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009
pascal@4701 793 + * Phillip Lougher <phillip@lougher.demon.co.uk>
pascal@4701 794 + *
pascal@4701 795 + * This program is free software; you can redistribute it and/or
pascal@4701 796 + * modify it under the terms of the GNU General Public License
pascal@4701 797 + * as published by the Free Software Foundation; either version 2,
pascal@4701 798 + * or (at your option) any later version.
pascal@4701 799 + *
pascal@4701 800 + * This program is distributed in the hope that it will be useful,
pascal@4701 801 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
pascal@4701 802 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
pascal@4701 803 + * GNU General Public License for more details.
pascal@4701 804 + *
pascal@4701 805 + * You should have received a copy of the GNU General Public License
pascal@4701 806 + * along with this program; if not, write to the Free Software
pascal@4701 807 + * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
pascal@4701 808 + *
pascal@4701 809 + * zlib_wrapper.c
pascal@4701 810 + */
pascal@4701 811 +
pascal@4701 812 +
pascal@4701 813 +#include <linux/mutex.h>
pascal@4701 814 +#include <linux/buffer_head.h>
pascal@4701 815 +#include <linux/zlib.h>
pascal@4701 816 +
pascal@4701 817 +#include "squashfs_fs.h"
pascal@4701 818 +#include "squashfs_fs_sb.h"
pascal@4701 819 +#include "squashfs_fs_i.h"
pascal@4701 820 +#include "squashfs.h"
pascal@4701 821 +#include "decompressor.h"
pascal@4701 822 +
pascal@4701 823 +static void *zlib_init(struct squashfs_sb_info *dummy)
pascal@4701 824 +{
pascal@4701 825 + z_stream *stream = kmalloc(sizeof(z_stream), GFP_KERNEL);
pascal@4701 826 + if (stream == NULL)
pascal@4701 827 + goto failed;
pascal@4701 828 + stream->workspace = kmalloc(zlib_inflate_workspacesize(),
pascal@4701 829 + GFP_KERNEL);
pascal@4701 830 + if (stream->workspace == NULL)
pascal@4701 831 + goto failed;
pascal@4701 832 +
pascal@4701 833 + return stream;
pascal@4701 834 +
pascal@4701 835 +failed:
pascal@4701 836 + ERROR("Failed to allocate zlib workspace\n");
pascal@4701 837 + kfree(stream);
pascal@4701 838 + return NULL;
pascal@4701 839 +}
pascal@4701 840 +
pascal@4701 841 +
pascal@4701 842 +static void zlib_free(void *strm)
pascal@4701 843 +{
pascal@4701 844 + z_stream *stream = strm;
pascal@4701 845 +
pascal@4701 846 + if (stream)
pascal@4701 847 + kfree(stream->workspace);
pascal@4701 848 + kfree(stream);
pascal@4701 849 +}
pascal@4701 850 +
pascal@4701 851 +
pascal@4701 852 +static int zlib_uncompress(struct squashfs_sb_info *msblk, void **buffer,
pascal@4701 853 + struct buffer_head **bh, int b, int offset, int length, int srclength,
pascal@4701 854 + int pages)
pascal@4701 855 +{
pascal@4701 856 + int zlib_err = 0, zlib_init = 0;
pascal@4701 857 + int avail, bytes, k = 0, page = 0;
pascal@4701 858 + z_stream *stream = msblk->stream;
pascal@4701 859 +
pascal@4701 860 + mutex_lock(&msblk->read_data_mutex);
pascal@4701 861 +
pascal@4701 862 + stream->avail_out = 0;
pascal@4701 863 + stream->avail_in = 0;
pascal@4701 864 +
pascal@4701 865 + bytes = length;
pascal@4701 866 + do {
pascal@4701 867 + if (stream->avail_in == 0 && k < b) {
pascal@4701 868 + avail = min(bytes, msblk->devblksize - offset);
pascal@4701 869 + bytes -= avail;
pascal@4701 870 + wait_on_buffer(bh[k]);
pascal@4701 871 + if (!buffer_uptodate(bh[k]))
pascal@4701 872 + goto release_mutex;
pascal@4701 873 +
pascal@4701 874 + if (avail == 0) {
pascal@4701 875 + offset = 0;
pascal@4701 876 + put_bh(bh[k++]);
pascal@4701 877 + continue;
pascal@4701 878 + }
pascal@4701 879 +
pascal@4701 880 + stream->next_in = bh[k]->b_data + offset;
pascal@4701 881 + stream->avail_in = avail;
pascal@4701 882 + offset = 0;
pascal@4701 883 + }
pascal@4701 884 +
pascal@4701 885 + if (stream->avail_out == 0 && page < pages) {
pascal@4701 886 + stream->next_out = buffer[page++];
pascal@4701 887 + stream->avail_out = PAGE_CACHE_SIZE;
pascal@4701 888 + }
pascal@4701 889 +
pascal@4701 890 + if (!zlib_init) {
pascal@4701 891 + zlib_err = zlib_inflateInit(stream);
pascal@4701 892 + if (zlib_err != Z_OK) {
pascal@4701 893 + ERROR("zlib_inflateInit returned unexpected "
pascal@4701 894 + "result 0x%x, srclength %d\n",
pascal@4701 895 + zlib_err, srclength);
pascal@4701 896 + goto release_mutex;
pascal@4701 897 + }
pascal@4701 898 + zlib_init = 1;
pascal@4701 899 + }
pascal@4701 900 +
pascal@4701 901 + zlib_err = zlib_inflate(stream, Z_SYNC_FLUSH);
pascal@4701 902 +
pascal@4701 903 + if (stream->avail_in == 0 && k < b)
pascal@4701 904 + put_bh(bh[k++]);
pascal@4701 905 + } while (zlib_err == Z_OK);
pascal@4701 906 +
pascal@4701 907 + if (zlib_err != Z_STREAM_END) {
pascal@4701 908 + ERROR("zlib_inflate error, data probably corrupt\n");
pascal@4701 909 + goto release_mutex;
pascal@4701 910 + }
pascal@4701 911 +
pascal@4701 912 + zlib_err = zlib_inflateEnd(stream);
pascal@4701 913 + if (zlib_err != Z_OK) {
pascal@4701 914 + ERROR("zlib_inflate error, data probably corrupt\n");
pascal@4701 915 + goto release_mutex;
pascal@4701 916 + }
pascal@4701 917 +
pascal@4701 918 + mutex_unlock(&msblk->read_data_mutex);
pascal@4701 919 + return stream->total_out;
pascal@4701 920 +
pascal@4701 921 +release_mutex:
pascal@4701 922 + mutex_unlock(&msblk->read_data_mutex);
pascal@4701 923 +
pascal@4701 924 + for (; k < b; k++)
pascal@4701 925 + put_bh(bh[k]);
pascal@4701 926 +
pascal@4701 927 + return -EIO;
pascal@4701 928 +}
pascal@4701 929 +
pascal@4701 930 +const struct squashfs_decompressor squashfs_zlib_comp_ops = {
pascal@4701 931 + .init = zlib_init,
pascal@4701 932 + .free = zlib_free,
pascal@4701 933 + .decompress = zlib_uncompress,
pascal@4701 934 + .id = ZLIB_COMPRESSION,
pascal@4701 935 + .name = "zlib",
pascal@4701 936 + .supported = 1
pascal@4701 937 +};
pascal@4701 938 +
pascal@4701 939
pascal@4701 940 --- linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h
pascal@4701 941 +++ linux-2.6.30.6/include/linux/decompress/bunzip2_mm.h
pascal@4701 942 @@ -0,0 +1,13 @@
pascal@4701 943 +#ifndef BUNZIP2_MM_H
pascal@4701 944 +#define BUNZIP2_MM_H
pascal@4701 945 +
pascal@4701 946 +#ifdef STATIC
pascal@4701 947 +/* Code active when included from pre-boot environment: */
pascal@4701 948 +#define INIT
pascal@4701 949 +#else
pascal@4701 950 +/* Compile for initramfs/initrd code only */
pascal@4701 951 +#define INIT __init
pascal@4701 952 +static void(*error)(char *m);
pascal@4701 953 +#endif
pascal@4701 954 +
pascal@4701 955 +#endif
pascal@4701 956
pascal@4701 957 --- linux-2.6.30.6/include/linux/decompress/inflate_mm.h
pascal@4701 958 +++ linux-2.6.30.6/include/linux/decompress/inflate_mm.h
pascal@4701 959 @@ -0,0 +1,13 @@
pascal@4701 960 +#ifndef INFLATE_MM_H
pascal@4701 961 +#define INFLATE_MM_H
pascal@4701 962 +
pascal@4701 963 +#ifdef STATIC
pascal@4701 964 +/* Code active when included from pre-boot environment: */
pascal@4701 965 +#define INIT
pascal@4701 966 +#else
pascal@4701 967 +/* Compile for initramfs/initrd code only */
pascal@4701 968 +#define INIT __init
pascal@4701 969 +static void(*error)(char *m);
pascal@4701 970 +#endif
pascal@4701 971 +
pascal@4701 972 +#endif
pascal@4701 973
pascal@4701 974 --- linux-2.6.30.6/include/linux/decompress/mm.h
pascal@4701 975 +++ linux-2.6.30.6/include/linux/decompress/mm.h
pascal@4701 976 @@ -25,7 +25,7 @@
pascal@4701 977 void *p;
pascal@4701 978
pascal@4701 979 if (size < 0)
pascal@4701 980 - error("Malloc error");
pascal@4701 981 + return NULL;
pascal@4701 982 if (!malloc_ptr)
pascal@4701 983 malloc_ptr = free_mem_ptr;
pascal@4701 984
pascal@4701 985 @@ -35,7 +35,7 @@
pascal@4701 986 malloc_ptr += size;
pascal@4701 987
pascal@4701 988 if (free_mem_end_ptr && malloc_ptr >= free_mem_end_ptr)
pascal@4701 989 - error("Out of memory");
pascal@4701 990 + return NULL;
pascal@4701 991
pascal@4701 992 malloc_count++;
pascal@4701 993 return p;
pascal@4701 994 @@ -53,8 +53,6 @@
pascal@4701 995
pascal@4701 996 #define set_error_fn(x)
pascal@4701 997
pascal@4701 998 -#define INIT
pascal@4701 999 -
pascal@4701 1000 #else /* STATIC */
pascal@4701 1001
pascal@4701 1002 /* Code active when compiled standalone for use when loading ramdisk: */
pascal@4701 1003 @@ -74,10 +72,8 @@
pascal@4701 1004 #define large_malloc(a) vmalloc(a)
pascal@4701 1005 #define large_free(a) vfree(a)
pascal@4701 1006
pascal@4701 1007 -static void(*error)(char *m);
pascal@4701 1008 #define set_error_fn(x) error = x;
pascal@4701 1009
pascal@4701 1010 -#define INIT __init
pascal@4701 1011 #define STATIC
pascal@4701 1012
pascal@4701 1013 #include <linux/init.h>
pascal@4701 1014
pascal@4701 1015 --- linux-2.6.30.6/include/linux/decompress/unlzma_mm.h
pascal@4701 1016 +++ linux-2.6.30.6/include/linux/decompress/unlzma_mm.h
pascal@4701 1017 @@ -0,0 +1,20 @@
pascal@4701 1018 +#ifndef UNLZMA_MM_H
pascal@4701 1019 +#define UNLZMA_MM_H
pascal@4701 1020 +
pascal@4701 1021 +#ifdef STATIC
pascal@4701 1022 +
pascal@4701 1023 +/* Code active when included from pre-boot environment: */
pascal@4701 1024 +#define INIT
pascal@4701 1025 +
pascal@4701 1026 +#elif defined(CONFIG_DECOMPRESS_LZMA_NEEDED)
pascal@4701 1027 +
pascal@4701 1028 +/* Make it available to non initramfs/initrd code */
pascal@4701 1029 +#define INIT
pascal@4701 1030 +#include <linux/module.h>
pascal@4701 1031 +#else
pascal@4701 1032 +
pascal@4701 1033 +/* Compile for initramfs/initrd code only */
pascal@4701 1034 +#define INIT __init
pascal@4701 1035 +#endif
pascal@4701 1036 +
pascal@4701 1037 +#endif
pascal@4701 1038
pascal@4701 1039 --- linux-2.6.30.6/lib/Kconfig
pascal@4701 1040 +++ linux-2.6.30.6/lib/Kconfig
pascal@4701 1041 @@ -10,6 +10,9 @@
pascal@4701 1042 config BITREVERSE
pascal@4701 1043 tristate
pascal@4701 1044
pascal@4701 1045 +config RATIONAL
pascal@4701 1046 + boolean
pascal@4701 1047 +
pascal@4701 1048 config GENERIC_FIND_FIRST_BIT
pascal@4701 1049 bool
pascal@4701 1050
pascal@4701 1051 @@ -114,6 +117,9 @@
pascal@4701 1052 config DECOMPRESS_LZMA
pascal@4701 1053 tristate
pascal@4701 1054
pascal@4701 1055 +config DECOMPRESS_LZMA_NEEDED
pascal@4701 1056 + boolean
pascal@4701 1057 +
pascal@4701 1058 #
pascal@4701 1059 # Generic allocator support is selected if needed
pascal@4701 1060 #
pascal@4701 1061 @@ -153,6 +159,9 @@
pascal@4701 1062 config TEXTSEARCH_FSM
pascal@4701 1063 tristate
pascal@4701 1064
pascal@4701 1065 +config BTREE
pascal@4701 1066 + boolean
pascal@4701 1067 +
pascal@4701 1068 config HAS_IOMEM
pascal@4701 1069 boolean
pascal@4701 1070 depends on !NO_IOMEM
pascal@4701 1071 @@ -190,5 +199,35 @@
pascal@4701 1072 #
pascal@4701 1073 config NLATTR
pascal@4701 1074 bool
pascal@4701 1075 +
pascal@4701 1076 +#
pascal@4701 1077 +# Generic 64-bit atomic support is selected if needed
pascal@4701 1078 +#
pascal@4701 1079 +config GENERIC_ATOMIC64
pascal@4701 1080 + bool
pascal@4701 1081 +
pascal@4701 1082 +config LRU_CACHE
pascal@4701 1083 + tristate
pascal@4701 1084 +
pascal@4701 1085 +config SHM_SIGNAL
pascal@4701 1086 + tristate "SHM Signal - Generic shared-memory signaling mechanism"
pascal@4701 1087 + default n
pascal@4701 1088 + help
pascal@4701 1089 + Provides a shared-memory based signaling mechanism to indicate
pascal@4701 1090 + memory-dirty notifications between two end-points.
pascal@4701 1091 +
pascal@4701 1092 + If unsure, say N
pascal@4701 1093 +
pascal@4701 1094 +config IOQ
pascal@4701 1095 + tristate "IO-Queue library - Generic shared-memory queue"
pascal@4701 1096 + select SHM_SIGNAL
pascal@4701 1097 + default n
pascal@4701 1098 + help
pascal@4701 1099 + IOQ is a generic shared-memory-queue mechanism that happens to be
pascal@4701 1100 + friendly to virtualization boundaries. It can be used in a variety
pascal@4701 1101 + of ways, though its intended purpose is to become a low-level
pascal@4701 1102 + communication path for paravirtualized drivers.
pascal@4701 1103 +
pascal@4701 1104 + If unsure, say N
pascal@4701 1105
pascal@4701 1106 endmenu
pascal@4701 1107
pascal@4701 1108 --- linux-2.6.30.6/lib/decompress_bunzip2.c
pascal@4701 1109 +++ linux-2.6.30.6/lib/decompress_bunzip2.c
pascal@4701 1110 @@ -45,12 +45,15 @@
pascal@4701 1111 */
pascal@4701 1112
pascal@4701 1113
pascal@4701 1114 -#ifndef STATIC
pascal@4701 1115 +#ifdef STATIC
pascal@4701 1116 +#define PREBOOT
pascal@4701 1117 +#else
pascal@4701 1118 #include <linux/decompress/bunzip2.h>
pascal@4701 1119 -#endif /* !STATIC */
pascal@4701 1120 +#include <linux/slab.h>
pascal@4701 1121 +#endif /* STATIC */
pascal@4701 1122
pascal@4701 1123 +#include <linux/decompress/bunzip2_mm.h>
pascal@4701 1124 #include <linux/decompress/mm.h>
pascal@4701 1125 -#include <linux/slab.h>
pascal@4701 1126
pascal@4701 1127 #ifndef INT_MAX
pascal@4701 1128 #define INT_MAX 0x7fffffff
pascal@4701 1129 @@ -297,7 +300,7 @@
pascal@4701 1130 again when using them (during symbol decoding).*/
pascal@4701 1131 base = hufGroup->base-1;
pascal@4701 1132 limit = hufGroup->limit-1;
pascal@4701 1133 - /* Calculate permute[]. Concurently, initialize
pascal@4701 1134 + /* Calculate permute[]. Concurrently, initialize
pascal@4701 1135 * temp[] and limit[]. */
pascal@4701 1136 pp = 0;
pascal@4701 1137 for (i = minLen; i <= maxLen; i++) {
pascal@4701 1138 @@ -635,6 +638,8 @@
pascal@4701 1139
pascal@4701 1140 /* Allocate bunzip_data. Most fields initialize to zero. */
pascal@4701 1141 bd = *bdp = malloc(i);
pascal@4701 1142 + if (!bd)
pascal@4701 1143 + return RETVAL_OUT_OF_MEMORY;
pascal@4701 1144 memset(bd, 0, sizeof(struct bunzip_data));
pascal@4701 1145 /* Setup input buffer */
pascal@4701 1146 bd->inbuf = inbuf;
pascal@4701 1147 @@ -662,6 +667,8 @@
pascal@4701 1148 bd->dbufSize = 100000*(i-BZh0);
pascal@4701 1149
pascal@4701 1150 bd->dbuf = large_malloc(bd->dbufSize * sizeof(int));
pascal@4701 1151 + if (!bd->dbuf)
pascal@4701 1152 + return RETVAL_OUT_OF_MEMORY;
pascal@4701 1153 return RETVAL_OK;
pascal@4701 1154 }
pascal@4701 1155
pascal@4701 1156 @@ -681,12 +688,10 @@
pascal@4701 1157 set_error_fn(error_fn);
pascal@4701 1158 if (flush)
pascal@4701 1159 outbuf = malloc(BZIP2_IOBUF_SIZE);
pascal@4701 1160 - else
pascal@4701 1161 - len -= 4; /* Uncompressed size hack active in pre-boot
pascal@4701 1162 - environment */
pascal@4701 1163 +
pascal@4701 1164 if (!outbuf) {
pascal@4701 1165 error("Could not allocate output bufer");
pascal@4701 1166 - return -1;
pascal@4701 1167 + return RETVAL_OUT_OF_MEMORY;
pascal@4701 1168 }
pascal@4701 1169 if (buf)
pascal@4701 1170 inbuf = buf;
pascal@4701 1171 @@ -694,6 +699,7 @@
pascal@4701 1172 inbuf = malloc(BZIP2_IOBUF_SIZE);
pascal@4701 1173 if (!inbuf) {
pascal@4701 1174 error("Could not allocate input bufer");
pascal@4701 1175 + i = RETVAL_OUT_OF_MEMORY;
pascal@4701 1176 goto exit_0;
pascal@4701 1177 }
pascal@4701 1178 i = start_bunzip(&bd, inbuf, len, fill);
pascal@4701 1179 @@ -720,11 +726,14 @@
pascal@4701 1180 } else if (i == RETVAL_UNEXPECTED_OUTPUT_EOF) {
pascal@4701 1181 error("Compressed file ends unexpectedly");
pascal@4701 1182 }
pascal@4701 1183 + if (!bd)
pascal@4701 1184 + goto exit_1;
pascal@4701 1185 if (bd->dbuf)
pascal@4701 1186 large_free(bd->dbuf);
pascal@4701 1187 if (pos)
pascal@4701 1188 *pos = bd->inbufPos;
pascal@4701 1189 free(bd);
pascal@4701 1190 +exit_1:
pascal@4701 1191 if (!buf)
pascal@4701 1192 free(inbuf);
pascal@4701 1193 exit_0:
pascal@4701 1194 @@ -733,4 +742,14 @@
pascal@4701 1195 return i;
pascal@4701 1196 }
pascal@4701 1197
pascal@4701 1198 -#define decompress bunzip2
pascal@4701 1199 +#ifdef PREBOOT
pascal@4701 1200 +STATIC int INIT decompress(unsigned char *buf, int len,
pascal@4701 1201 + int(*fill)(void*, unsigned int),
pascal@4701 1202 + int(*flush)(void*, unsigned int),
pascal@4701 1203 + unsigned char *outbuf,
pascal@4701 1204 + int *pos,
pascal@4701 1205 + void(*error_fn)(char *x))
pascal@4701 1206 +{
pascal@4701 1207 + return bunzip2(buf, len - 4, fill, flush, outbuf, pos, error_fn);
pascal@4701 1208 +}
pascal@4701 1209 +#endif
pascal@4701 1210
pascal@4701 1211 --- linux-2.6.30.6/lib/decompress_inflate.c
pascal@4701 1212 +++ linux-2.6.30.6/lib/decompress_inflate.c
pascal@4701 1213 @@ -19,14 +19,20 @@
pascal@4701 1214 #include "zlib_inflate/inflate.h"
pascal@4701 1215
pascal@4701 1216 #include "zlib_inflate/infutil.h"
pascal@4701 1217 +#include <linux/slab.h>
pascal@4701 1218
pascal@4701 1219 #endif /* STATIC */
pascal@4701 1220
pascal@4701 1221 +#include <linux/decompress/inflate_mm.h>
pascal@4701 1222 #include <linux/decompress/mm.h>
pascal@4701 1223 -#include <linux/slab.h>
pascal@4701 1224
pascal@4701 1225 -#define INBUF_LEN (16*1024)
pascal@4701 1226 +#define GZIP_IOBUF_SIZE (16*1024)
pascal@4701 1227
pascal@4701 1228 +static int nofill(void *buffer, unsigned int len)
pascal@4701 1229 +{
pascal@4701 1230 + return -1;
pascal@4701 1231 +}
pascal@4701 1232 +
pascal@4701 1233 /* Included from initramfs et al code */
pascal@4701 1234 STATIC int INIT gunzip(unsigned char *buf, int len,
pascal@4701 1235 int(*fill)(void*, unsigned int),
pascal@4701 1236 @@ -55,7 +61,7 @@
pascal@4701 1237 if (buf)
pascal@4701 1238 zbuf = buf;
pascal@4701 1239 else {
pascal@4701 1240 - zbuf = malloc(INBUF_LEN);
pascal@4701 1241 + zbuf = malloc(GZIP_IOBUF_SIZE);
pascal@4701 1242 len = 0;
pascal@4701 1243 }
pascal@4701 1244 if (!zbuf) {
pascal@4701 1245 @@ -76,8 +82,11 @@
pascal@4701 1246 goto gunzip_nomem4;
pascal@4701 1247 }
pascal@4701 1248
pascal@4701 1249 + if (!fill)
pascal@4701 1250 + fill = nofill;
pascal@4701 1251 +
pascal@4701 1252 if (len == 0)
pascal@4701 1253 - len = fill(zbuf, INBUF_LEN);
pascal@4701 1254 + len = fill(zbuf, GZIP_IOBUF_SIZE);
pascal@4701 1255
pascal@4701 1256 /* verify the gzip header */
pascal@4701 1257 if (len < 10 ||
pascal@4701 1258 @@ -113,7 +122,7 @@
pascal@4701 1259 while (rc == Z_OK) {
pascal@4701 1260 if (strm->avail_in == 0) {
pascal@4701 1261 /* TODO: handle case where both pos and fill are set */
pascal@4701 1262 - len = fill(zbuf, INBUF_LEN);
pascal@4701 1263 + len = fill(zbuf, GZIP_IOBUF_SIZE);
pascal@4701 1264 if (len < 0) {
pascal@4701 1265 rc = -1;
pascal@4701 1266 error("read error");
pascal@4701 1267
pascal@4701 1268 --- linux-2.6.30.6/lib/decompress_unlzma.c
pascal@4701 1269 +++ linux-2.6.30.6/lib/decompress_unlzma.c
pascal@4701 1270 @@ -29,12 +29,15 @@
pascal@4701 1271 *Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
pascal@4701 1272 */
pascal@4701 1273
pascal@4701 1274 -#ifndef STATIC
pascal@4701 1275 +#ifdef STATIC
pascal@4701 1276 +#define PREBOOT
pascal@4701 1277 +#else
pascal@4701 1278 #include <linux/decompress/unlzma.h>
pascal@4701 1279 +#include <linux/slab.h>
pascal@4701 1280 #endif /* STATIC */
pascal@4701 1281
pascal@4701 1282 +#include <linux/decompress/unlzma_mm.h>
pascal@4701 1283 #include <linux/decompress/mm.h>
pascal@4701 1284 -#include <linux/slab.h>
pascal@4701 1285
pascal@4701 1286 #define MIN(a, b) (((a) < (b)) ? (a) : (b))
pascal@4701 1287
pascal@4701 1288 @@ -80,8 +83,13 @@
pascal@4701 1289 #define RC_MODEL_TOTAL_BITS 11
pascal@4701 1290
pascal@4701 1291
pascal@4701 1292 +static int nofill(void *buffer, unsigned int len)
pascal@4701 1293 +{
pascal@4701 1294 + return -1;
pascal@4701 1295 +}
pascal@4701 1296 +
pascal@4701 1297 /* Called twice: once at startup and once in rc_normalize() */
pascal@4701 1298 -static void INIT rc_read(struct rc *rc)
pascal@4701 1299 +static void INIT rc_read(struct rc *rc, void(*error)(char *x))
pascal@4701 1300 {
pascal@4701 1301 rc->buffer_size = rc->fill((char *)rc->buffer, LZMA_IOBUF_SIZE);
pascal@4701 1302 if (rc->buffer_size <= 0)
pascal@4701 1303 @@ -95,7 +103,10 @@
pascal@4701 1304 int (*fill)(void*, unsigned int),
pascal@4701 1305 char *buffer, int buffer_size)
pascal@4701 1306 {
pascal@4701 1307 - rc->fill = fill;
pascal@4701 1308 + if (fill)
pascal@4701 1309 + rc->fill = fill;
pascal@4701 1310 + else
pascal@4701 1311 + rc->fill = nofill;
pascal@4701 1312 rc->buffer = (uint8_t *)buffer;
pascal@4701 1313 rc->buffer_size = buffer_size;
pascal@4701 1314 rc->buffer_end = rc->buffer + rc->buffer_size;
pascal@4701 1315 @@ -105,13 +116,13 @@
pascal@4701 1316 rc->range = 0xFFFFFFFF;
pascal@4701 1317 }
pascal@4701 1318
pascal@4701 1319 -static inline void INIT rc_init_code(struct rc *rc)
pascal@4701 1320 +static inline void INIT rc_init_code(struct rc *rc, void(*error)(char *x))
pascal@4701 1321 {
pascal@4701 1322 int i;
pascal@4701 1323
pascal@4701 1324 for (i = 0; i < 5; i++) {
pascal@4701 1325 if (rc->ptr >= rc->buffer_end)
pascal@4701 1326 - rc_read(rc);
pascal@4701 1327 + rc_read(rc, error);
pascal@4701 1328 rc->code = (rc->code << 8) | *rc->ptr++;
pascal@4701 1329 }
pascal@4701 1330 }
pascal@4701 1331 @@ -124,32 +135,33 @@
pascal@4701 1332 }
pascal@4701 1333
pascal@4701 1334 /* Called twice, but one callsite is in inline'd rc_is_bit_0_helper() */
pascal@4701 1335 -static void INIT rc_do_normalize(struct rc *rc)
pascal@4701 1336 +static void INIT rc_do_normalize(struct rc *rc, void(*error)(char *x))
pascal@4701 1337 {
pascal@4701 1338 if (rc->ptr >= rc->buffer_end)
pascal@4701 1339 - rc_read(rc);
pascal@4701 1340 + rc_read(rc, error);
pascal@4701 1341 rc->range <<= 8;
pascal@4701 1342 rc->code = (rc->code << 8) | *rc->ptr++;
pascal@4701 1343 }
pascal@4701 1344 -static inline void INIT rc_normalize(struct rc *rc)
pascal@4701 1345 +static inline void INIT rc_normalize(struct rc *rc, void(*error)(char *x))
pascal@4701 1346 {
pascal@4701 1347 if (rc->range < (1 << RC_TOP_BITS))
pascal@4701 1348 - rc_do_normalize(rc);
pascal@4701 1349 + rc_do_normalize(rc, error);
pascal@4701 1350 }
pascal@4701 1351
pascal@4701 1352 /* Called 9 times */
pascal@4701 1353 /* Why rc_is_bit_0_helper exists?
pascal@4701 1354 *Because we want to always expose (rc->code < rc->bound) to optimizer
pascal@4701 1355 */
pascal@4701 1356 -static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p)
pascal@4701 1357 +static inline uint32_t INIT rc_is_bit_0_helper(struct rc *rc, uint16_t *p,
pascal@4701 1358 + void (*error)(char *x))
pascal@4701 1359 {
pascal@4701 1360 - rc_normalize(rc);
pascal@4701 1361 + rc_normalize(rc, error);
pascal@4701 1362 rc->bound = *p * (rc->range >> RC_MODEL_TOTAL_BITS);
pascal@4701 1363 return rc->bound;
pascal@4701 1364 }
pascal@4701 1365 -static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p)
pascal@4701 1366 +static inline int INIT rc_is_bit_0(struct rc *rc, uint16_t *p, void(*error)(char *x))
pascal@4701 1367 {
pascal@4701 1368 - uint32_t t = rc_is_bit_0_helper(rc, p);
pascal@4701 1369 + uint32_t t = rc_is_bit_0_helper(rc, p, error);
pascal@4701 1370 return rc->code < t;
pascal@4701 1371 }
pascal@4701 1372
pascal@4701 1373 @@ -167,9 +179,9 @@
pascal@4701 1374 }
pascal@4701 1375
pascal@4701 1376 /* Called 4 times in unlzma loop */
pascal@4701 1377 -static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol)
pascal@4701 1378 +static int INIT rc_get_bit(struct rc *rc, uint16_t *p, int *symbol, void(*error)(char *x))
pascal@4701 1379 {
pascal@4701 1380 - if (rc_is_bit_0(rc, p)) {
pascal@4701 1381 + if (rc_is_bit_0(rc, p, error)) {
pascal@4701 1382 rc_update_bit_0(rc, p);
pascal@4701 1383 *symbol *= 2;
pascal@4701 1384 return 0;
pascal@4701 1385 @@ -181,9 +193,9 @@
pascal@4701 1386 }
pascal@4701 1387
pascal@4701 1388 /* Called once */
pascal@4701 1389 -static inline int INIT rc_direct_bit(struct rc *rc)
pascal@4701 1390 +static inline int INIT rc_direct_bit(struct rc *rc , void(*error)(char *x))
pascal@4701 1391 {
pascal@4701 1392 - rc_normalize(rc);
pascal@4701 1393 + rc_normalize(rc, error);
pascal@4701 1394 rc->range >>= 1;
pascal@4701 1395 if (rc->code >= rc->range) {
pascal@4701 1396 rc->code -= rc->range;
pascal@4701 1397 @@ -194,13 +206,14 @@
pascal@4701 1398
pascal@4701 1399 /* Called twice */
pascal@4701 1400 static inline void INIT
pascal@4701 1401 -rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol)
pascal@4701 1402 +rc_bit_tree_decode(struct rc *rc, uint16_t *p, int num_levels, int *symbol,
pascal@4701 1403 + void(*error)(char *x))
pascal@4701 1404 {
pascal@4701 1405 int i = num_levels;
pascal@4701 1406
pascal@4701 1407 *symbol = 1;
pascal@4701 1408 while (i--)
pascal@4701 1409 - rc_get_bit(rc, p + *symbol, symbol);
pascal@4701 1410 + rc_get_bit(rc, p + *symbol, symbol, error);
pascal@4701 1411 *symbol -= 1 << num_levels;
pascal@4701 1412 }
pascal@4701 1413
pascal@4701 1414 @@ -278,10 +291,6 @@
pascal@4701 1415 size_t global_pos;
pascal@4701 1416 int(*flush)(void*, unsigned int);
pascal@4701 1417 struct lzma_header *header;
pascal@4701 1418 - int is_cpio_flush;
pascal@4701 1419 - uint8_t **buffer_index;
pascal@4701 1420 - int next_index;
pascal@4701 1421 - int max_index;
pascal@4701 1422 };
pascal@4701 1423
pascal@4701 1424 struct cstate {
pascal@4701 1425 @@ -298,14 +307,6 @@
pascal@4701 1426 static inline uint8_t INIT peek_old_byte(struct writer *wr,
pascal@4701 1427 uint32_t offs)
pascal@4701 1428 {
pascal@4701 1429 - if (wr->is_cpio_flush) {
pascal@4701 1430 - int32_t pos;
pascal@4701 1431 - while (offs > wr->header->dict_size)
pascal@4701 1432 - offs -= wr->header->dict_size;
pascal@4701 1433 - pos = wr->buffer_pos - offs;
pascal@4701 1434 - return wr->buffer_index[pos / LZMA_IOBUF_SIZE]
pascal@4701 1435 - [pos % LZMA_IOBUF_SIZE];
pascal@4701 1436 - }
pascal@4701 1437 if (!wr->flush) {
pascal@4701 1438 int32_t pos;
pascal@4701 1439 while (offs > wr->header->dict_size)
pascal@4701 1440 @@ -321,41 +322,8 @@
pascal@4701 1441
pascal@4701 1442 }
pascal@4701 1443
pascal@4701 1444 -static inline void INIT write_byte_if_cpio(struct writer *wr, uint8_t byte)
pascal@4701 1445 -{
pascal@4701 1446 - if (wr->buffer_pos % LZMA_IOBUF_SIZE == 0) {
pascal@4701 1447 - // if the following large_malloc fails, the initramfs
pascal@4701 1448 - // whould not be load with is_cpio_flush forced 0 too.
pascal@4701 1449 - // Remember we do not allocate historic buffer.
pascal@4701 1450 - // Let's assume it will never fail !
pascal@4701 1451 - if (wr->next_index >= wr->max_index) {
pascal@4701 1452 - // realloc wr->buffer_index
pascal@4701 1453 - uint8_t **p = wr->buffer_index;
pascal@4701 1454 - wr->buffer_index = (uint8_t **)
pascal@4701 1455 - large_malloc(LZMA_IOBUF_SIZE +
pascal@4701 1456 - sizeof(*p) * wr->max_index);
pascal@4701 1457 - if (wr->max_index) {
pascal@4701 1458 - memcpy(wr->buffer_index, p,
pascal@4701 1459 - sizeof(*p) * wr->max_index);
pascal@4701 1460 - free(p);
pascal@4701 1461 - }
pascal@4701 1462 - wr->max_index += LZMA_IOBUF_SIZE / sizeof(*p);
pascal@4701 1463 - }
pascal@4701 1464 - wr->buffer_index[wr->next_index++] =
pascal@4701 1465 - (uint8_t *) large_malloc(LZMA_IOBUF_SIZE);
pascal@4701 1466 - }
pascal@4701 1467 - wr->buffer_index[wr->buffer_pos / LZMA_IOBUF_SIZE]
pascal@4701 1468 - [wr->buffer_pos % LZMA_IOBUF_SIZE] =
pascal@4701 1469 - wr->previous_byte = byte;
pascal@4701 1470 - wr->buffer_pos++;
pascal@4701 1471 -}
pascal@4701 1472 -
pascal@4701 1473 static inline void INIT write_byte(struct writer *wr, uint8_t byte)
pascal@4701 1474 {
pascal@4701 1475 - if (wr->is_cpio_flush) {
pascal@4701 1476 - write_byte_if_cpio(wr, byte);
pascal@4701 1477 - return;
pascal@4701 1478 - }
pascal@4701 1479 wr->buffer[wr->buffer_pos++] = wr->previous_byte = byte;
pascal@4701 1480 if (wr->flush && wr->buffer_pos == wr->header->dict_size) {
pascal@4701 1481 wr->buffer_pos = 0;
pascal@4701 1482 @@ -373,21 +341,7 @@
pascal@4701 1483 static inline void INIT copy_bytes(struct writer *wr,
pascal@4701 1484 uint32_t rep0, int len)
pascal@4701 1485 {
pascal@4701 1486 - if (wr->is_cpio_flush) {
pascal@4701 1487 - int32_t pos;
pascal@4701 1488 - uint32_t offs = rep0;
pascal@4701 1489 - while (offs > wr->header->dict_size)
pascal@4701 1490 - offs -= wr->header->dict_size;
pascal@4701 1491 - pos = wr->buffer_pos - offs;
pascal@4701 1492 - do {
pascal@4701 1493 - write_byte_if_cpio(wr,
pascal@4701 1494 - wr->buffer_index[pos / LZMA_IOBUF_SIZE]
pascal@4701 1495 - [pos % LZMA_IOBUF_SIZE]);
pascal@4701 1496 - pos++;
pascal@4701 1497 - len--;
pascal@4701 1498 - } while (len != 0 && wr->buffer_pos < wr->header->dst_size);
pascal@4701 1499 - }
pascal@4701 1500 - else do {
pascal@4701 1501 + do {
pascal@4701 1502 copy_byte(wr, rep0);
pascal@4701 1503 len--;
pascal@4701 1504 } while (len != 0 && wr->buffer_pos < wr->header->dst_size);
pascal@4701 1505 @@ -396,11 +350,9 @@
pascal@4701 1506 static inline void INIT process_bit0(struct writer *wr, struct rc *rc,
pascal@4701 1507 struct cstate *cst, uint16_t *p,
pascal@4701 1508 int pos_state, uint16_t *prob,
pascal@4701 1509 - int lc, uint32_t literal_pos_mask) {
pascal@4701 1510 + int lc, uint32_t literal_pos_mask,
pascal@4701 1511 + void(*error)(char *x)) {
pascal@4701 1512 int mi = 1;
pascal@4701 1513 - static const int state[LZMA_NUM_STATES] =
pascal@4701 1514 - { 0, 0, 0, 0, 1, 2, 3, 4, 5, 6, 4, 5 };
pascal@4701 1515 -
pascal@4701 1516 rc_update_bit_0(rc, prob);
pascal@4701 1517 prob = (p + LZMA_LITERAL +
pascal@4701 1518 (LZMA_LIT_SIZE
pascal@4701 1519 @@ -417,7 +369,7 @@
pascal@4701 1520 match_byte <<= 1;
pascal@4701 1521 bit = match_byte & 0x100;
pascal@4701 1522 prob_lit = prob + 0x100 + bit + mi;
pascal@4701 1523 - if (rc_get_bit(rc, prob_lit, &mi)) {
pascal@4701 1524 + if (rc_get_bit(rc, prob_lit, &mi, error)) {
pascal@4701 1525 if (!bit)
pascal@4701 1526 break;
pascal@4701 1527 } else {
pascal@4701 1528 @@ -428,23 +380,29 @@
pascal@4701 1529 }
pascal@4701 1530 while (mi < 0x100) {
pascal@4701 1531 uint16_t *prob_lit = prob + mi;
pascal@4701 1532 - rc_get_bit(rc, prob_lit, &mi);
pascal@4701 1533 + rc_get_bit(rc, prob_lit, &mi, error);
pascal@4701 1534 }
pascal@4701 1535 write_byte(wr, mi);
pascal@4701 1536 - cst->state = state[cst->state];
pascal@4701 1537 + if (cst->state < 4)
pascal@4701 1538 + cst->state = 0;
pascal@4701 1539 + else if (cst->state < 10)
pascal@4701 1540 + cst->state -= 3;
pascal@4701 1541 + else
pascal@4701 1542 + cst->state -= 6;
pascal@4701 1543 }
pascal@4701 1544
pascal@4701 1545 static inline void INIT process_bit1(struct writer *wr, struct rc *rc,
pascal@4701 1546 struct cstate *cst, uint16_t *p,
pascal@4701 1547 - int pos_state, uint16_t *prob) {
pascal@4701 1548 - int offset;
pascal@4701 1549 + int pos_state, uint16_t *prob,
pascal@4701 1550 + void(*error)(char *x)) {
pascal@4701 1551 + int offset;
pascal@4701 1552 uint16_t *prob_len;
pascal@4701 1553 int num_bits;
pascal@4701 1554 int len;
pascal@4701 1555
pascal@4701 1556 rc_update_bit_1(rc, prob);
pascal@4701 1557 prob = p + LZMA_IS_REP + cst->state;
pascal@4701 1558 - if (rc_is_bit_0(rc, prob)) {
pascal@4701 1559 + if (rc_is_bit_0(rc, prob, error)) {
pascal@4701 1560 rc_update_bit_0(rc, prob);
pascal@4701 1561 cst->rep3 = cst->rep2;
pascal@4701 1562 cst->rep2 = cst->rep1;
pascal@4701 1563 @@ -453,14 +411,14 @@
pascal@4701 1564 prob = p + LZMA_LEN_CODER;
pascal@4701 1565 } else {
pascal@4701 1566 rc_update_bit_1(rc, prob);
pascal@4701 1567 - prob += LZMA_IS_REP_G0 - LZMA_IS_REP;
pascal@4701 1568 - if (rc_is_bit_0(rc, prob)) {
pascal@4701 1569 + prob = p + LZMA_IS_REP_G0 + cst->state;
pascal@4701 1570 + if (rc_is_bit_0(rc, prob, error)) {
pascal@4701 1571 rc_update_bit_0(rc, prob);
pascal@4701 1572 prob = (p + LZMA_IS_REP_0_LONG
pascal@4701 1573 + (cst->state <<
pascal@4701 1574 LZMA_NUM_POS_BITS_MAX) +
pascal@4701 1575 pos_state);
pascal@4701 1576 - if (rc_is_bit_0(rc, prob)) {
pascal@4701 1577 + if (rc_is_bit_0(rc, prob, error)) {
pascal@4701 1578 rc_update_bit_0(rc, prob);
pascal@4701 1579
pascal@4701 1580 cst->state = cst->state < LZMA_NUM_LIT_STATES ?
pascal@4701 1581 @@ -474,14 +432,14 @@
pascal@4701 1582 uint32_t distance;
pascal@4701 1583
pascal@4701 1584 rc_update_bit_1(rc, prob);
pascal@4701 1585 - prob += LZMA_IS_REP_G1 - LZMA_IS_REP_G0;
pascal@4701 1586 - if (rc_is_bit_0(rc, prob)) {
pascal@4701 1587 + prob = p + LZMA_IS_REP_G1 + cst->state;
pascal@4701 1588 + if (rc_is_bit_0(rc, prob, error)) {
pascal@4701 1589 rc_update_bit_0(rc, prob);
pascal@4701 1590 distance = cst->rep1;
pascal@4701 1591 } else {
pascal@4701 1592 rc_update_bit_1(rc, prob);
pascal@4701 1593 - prob += LZMA_IS_REP_G2 - LZMA_IS_REP_G1;
pascal@4701 1594 - if (rc_is_bit_0(rc, prob)) {
pascal@4701 1595 + prob = p + LZMA_IS_REP_G2 + cst->state;
pascal@4701 1596 + if (rc_is_bit_0(rc, prob, error)) {
pascal@4701 1597 rc_update_bit_0(rc, prob);
pascal@4701 1598 distance = cst->rep2;
pascal@4701 1599 } else {
pascal@4701 1600 @@ -499,33 +457,33 @@
pascal@4701 1601 }
pascal@4701 1602
pascal@4701 1603 prob_len = prob + LZMA_LEN_CHOICE;
pascal@4701 1604 - if (rc_is_bit_0(rc, prob_len)) {
pascal@4701 1605 + if (rc_is_bit_0(rc, prob_len, error)) {
pascal@4701 1606 rc_update_bit_0(rc, prob_len);
pascal@4701 1607 - prob_len += LZMA_LEN_LOW - LZMA_LEN_CHOICE
pascal@4701 1608 + prob_len = (prob + LZMA_LEN_LOW
pascal@4701 1609 + (pos_state <<
pascal@4701 1610 - LZMA_LEN_NUM_LOW_BITS);
pascal@4701 1611 + LZMA_LEN_NUM_LOW_BITS));
pascal@4701 1612 offset = 0;
pascal@4701 1613 num_bits = LZMA_LEN_NUM_LOW_BITS;
pascal@4701 1614 } else {
pascal@4701 1615 rc_update_bit_1(rc, prob_len);
pascal@4701 1616 - prob_len += LZMA_LEN_CHOICE_2 - LZMA_LEN_CHOICE;
pascal@4701 1617 - if (rc_is_bit_0(rc, prob_len)) {
pascal@4701 1618 + prob_len = prob + LZMA_LEN_CHOICE_2;
pascal@4701 1619 + if (rc_is_bit_0(rc, prob_len, error)) {
pascal@4701 1620 rc_update_bit_0(rc, prob_len);
pascal@4701 1621 - prob_len += LZMA_LEN_MID - LZMA_LEN_CHOICE_2
pascal@4701 1622 + prob_len = (prob + LZMA_LEN_MID
pascal@4701 1623 + (pos_state <<
pascal@4701 1624 - LZMA_LEN_NUM_MID_BITS);
pascal@4701 1625 + LZMA_LEN_NUM_MID_BITS));
pascal@4701 1626 offset = 1 << LZMA_LEN_NUM_LOW_BITS;
pascal@4701 1627 num_bits = LZMA_LEN_NUM_MID_BITS;
pascal@4701 1628 } else {
pascal@4701 1629 rc_update_bit_1(rc, prob_len);
pascal@4701 1630 - prob_len += LZMA_LEN_HIGH - LZMA_LEN_CHOICE_2;
pascal@4701 1631 + prob_len = prob + LZMA_LEN_HIGH;
pascal@4701 1632 offset = ((1 << LZMA_LEN_NUM_LOW_BITS)
pascal@4701 1633 + (1 << LZMA_LEN_NUM_MID_BITS));
pascal@4701 1634 num_bits = LZMA_LEN_NUM_HIGH_BITS;
pascal@4701 1635 }
pascal@4701 1636 }
pascal@4701 1637
pascal@4701 1638 - rc_bit_tree_decode(rc, prob_len, num_bits, &len);
pascal@4701 1639 + rc_bit_tree_decode(rc, prob_len, num_bits, &len, error);
pascal@4701 1640 len += offset;
pascal@4701 1641
pascal@4701 1642 if (cst->state < 4) {
pascal@4701 1643 @@ -540,7 +498,7 @@
pascal@4701 1644 << LZMA_NUM_POS_SLOT_BITS);
pascal@4701 1645 rc_bit_tree_decode(rc, prob,
pascal@4701 1646 LZMA_NUM_POS_SLOT_BITS,
pascal@4701 1647 - &pos_slot);
pascal@4701 1648 + &pos_slot, error);
pascal@4701 1649 if (pos_slot >= LZMA_START_POS_MODEL_INDEX) {
pascal@4701 1650 int i, mi;
pascal@4701 1651 num_bits = (pos_slot >> 1) - 1;
pascal@4701 1652 @@ -553,7 +511,7 @@
pascal@4701 1653 num_bits -= LZMA_NUM_ALIGN_BITS;
pascal@4701 1654 while (num_bits--)
pascal@4701 1655 cst->rep0 = (cst->rep0 << 1) |
pascal@4701 1656 - rc_direct_bit(rc);
pascal@4701 1657 + rc_direct_bit(rc, error);
pascal@4701 1658 prob = p + LZMA_ALIGN;
pascal@4701 1659 cst->rep0 <<= LZMA_NUM_ALIGN_BITS;
pascal@4701 1660 num_bits = LZMA_NUM_ALIGN_BITS;
pascal@4701 1661 @@ -561,7 +519,7 @@
pascal@4701 1662 i = 1;
pascal@4701 1663 mi = 1;
pascal@4701 1664 while (num_bits--) {
pascal@4701 1665 - if (rc_get_bit(rc, prob + mi, &mi))
pascal@4701 1666 + if (rc_get_bit(rc, prob + mi, &mi, error))
pascal@4701 1667 cst->rep0 |= i;
pascal@4701 1668 i <<= 1;
pascal@4701 1669 }
pascal@4701 1670 @@ -578,15 +536,14 @@
pascal@4701 1671
pascal@4701 1672
pascal@4701 1673
pascal@4701 1674 -STATIC inline int INIT unlzma(unsigned char *buf, int in_len,
pascal@4701 1675 +STATIC int INIT unlzma(unsigned char *buf, int in_len,
pascal@4701 1676 int(*fill)(void*, unsigned int),
pascal@4701 1677 int(*flush)(void*, unsigned int),
pascal@4701 1678 unsigned char *output,
pascal@4701 1679 int *posp,
pascal@4701 1680 - void(*error_fn)(char *x)
pascal@4701 1681 + void(*error)(char *x)
pascal@4701 1682 )
pascal@4701 1683 {
pascal@4701 1684 - extern int cpio_flush_buffer(void*, unsigned int);
pascal@4701 1685 struct lzma_header header;
pascal@4701 1686 int lc, pb, lp;
pascal@4701 1687 uint32_t pos_state_mask;
pascal@4701 1688 @@ -600,10 +557,6 @@
pascal@4701 1689 unsigned char *inbuf;
pascal@4701 1690 int ret = -1;
pascal@4701 1691
pascal@4701 1692 - set_error_fn(error_fn);
pascal@4701 1693 - if (!flush)
pascal@4701 1694 - in_len -= 4; /* Uncompressed size hack active in pre-boot
pascal@4701 1695 - environment */
pascal@4701 1696 if (buf)
pascal@4701 1697 inbuf = buf;
pascal@4701 1698 else
pascal@4701 1699 @@ -621,16 +574,12 @@
pascal@4701 1700 wr.global_pos = 0;
pascal@4701 1701 wr.previous_byte = 0;
pascal@4701 1702 wr.buffer_pos = 0;
pascal@4701 1703 - wr.is_cpio_flush = 0;
pascal@4701 1704 - if (flush == cpio_flush_buffer)
pascal@4701 1705 - wr.is_cpio_flush = 1;
pascal@4701 1706 - wr.buffer_index = NULL;
pascal@4701 1707
pascal@4701 1708 rc_init(&rc, fill, inbuf, in_len);
pascal@4701 1709
pascal@4701 1710 for (i = 0; i < sizeof(header); i++) {
pascal@4701 1711 if (rc.ptr >= rc.buffer_end)
pascal@4701 1712 - rc_read(&rc);
pascal@4701 1713 + rc_read(&rc, error);
pascal@4701 1714 ((unsigned char *)&header)[i] = *rc.ptr++;
pascal@4701 1715 }
pascal@4701 1716
pascal@4701 1717 @@ -658,34 +607,34 @@
pascal@4701 1718 if (header.dict_size == 0)
pascal@4701 1719 header.dict_size = 1;
pascal@4701 1720
pascal@4701 1721 - if (output || wr.is_cpio_flush)
pascal@4701 1722 + if (output)
pascal@4701 1723 wr.buffer = output;
pascal@4701 1724 else {
pascal@4701 1725 wr.bufsize = MIN(header.dst_size, header.dict_size);
pascal@4701 1726 wr.buffer = large_malloc(wr.bufsize);
pascal@4701 1727 }
pascal@4701 1728 - if (wr.buffer == NULL && !wr.is_cpio_flush)
pascal@4701 1729 + if (wr.buffer == NULL)
pascal@4701 1730 goto exit_1;
pascal@4701 1731
pascal@4701 1732 num_probs = LZMA_BASE_SIZE + (LZMA_LIT_SIZE << (lc + lp));
pascal@4701 1733 p = (uint16_t *) large_malloc(num_probs * sizeof(*p));
pascal@4701 1734 if (p == 0)
pascal@4701 1735 goto exit_2;
pascal@4701 1736 - num_probs += LZMA_LITERAL - LZMA_BASE_SIZE;
pascal@4701 1737 + num_probs = LZMA_LITERAL + (LZMA_LIT_SIZE << (lc + lp));
pascal@4701 1738 for (i = 0; i < num_probs; i++)
pascal@4701 1739 p[i] = (1 << RC_MODEL_TOTAL_BITS) >> 1;
pascal@4701 1740 - wr.max_index = wr.next_index = 0;
pascal@4701 1741 - rc_init_code(&rc);
pascal@4701 1742
pascal@4701 1743 + rc_init_code(&rc, error);
pascal@4701 1744 +
pascal@4701 1745 while (get_pos(&wr) < header.dst_size) {
pascal@4701 1746 int pos_state = get_pos(&wr) & pos_state_mask;
pascal@4701 1747 uint16_t *prob = p + LZMA_IS_MATCH +
pascal@4701 1748 (cst.state << LZMA_NUM_POS_BITS_MAX) + pos_state;
pascal@4701 1749 - if (rc_is_bit_0(&rc, prob))
pascal@4701 1750 + if (rc_is_bit_0(&rc, prob, error))
pascal@4701 1751 process_bit0(&wr, &rc, &cst, p, pos_state, prob,
pascal@4701 1752 - lc, literal_pos_mask);
pascal@4701 1753 + lc, literal_pos_mask, error);
pascal@4701 1754 else {
pascal@4701 1755 - process_bit1(&wr, &rc, &cst, p, pos_state, prob);
pascal@4701 1756 + process_bit1(&wr, &rc, &cst, p, pos_state, prob, error);
pascal@4701 1757 if (cst.rep0 == 0)
pascal@4701 1758 break;
pascal@4701 1759 }
pascal@4701 1760 @@ -693,25 +642,12 @@
pascal@4701 1761
pascal@4701 1762 if (posp)
pascal@4701 1763 *posp = rc.ptr-rc.buffer;
pascal@4701 1764 - if (wr.is_cpio_flush) {
pascal@4701 1765 - int i;
pascal@4701 1766 - for (i = 0; i < wr.next_index -1; i++) {
pascal@4701 1767 - wr.flush(wr.buffer_index[i], LZMA_IOBUF_SIZE);
pascal@4701 1768 - large_free(wr.buffer_index[i]);
pascal@4701 1769 - }
pascal@4701 1770 - if (i < wr.next_index) {
pascal@4701 1771 - wr.flush(wr.buffer_index[i],
pascal@4701 1772 - wr.buffer_pos % LZMA_IOBUF_SIZE);
pascal@4701 1773 - large_free(wr.buffer_index[i]);
pascal@4701 1774 - }
pascal@4701 1775 - large_free(wr.buffer_index);
pascal@4701 1776 - }
pascal@4701 1777 - else if (wr.flush)
pascal@4701 1778 + if (wr.flush)
pascal@4701 1779 wr.flush(wr.buffer, wr.buffer_pos);
pascal@4701 1780 ret = 0;
pascal@4701 1781 large_free(p);
pascal@4701 1782 exit_2:
pascal@4701 1783 - if (!output && !wr.is_cpio_flush)
pascal@4701 1784 + if (!output)
pascal@4701 1785 large_free(wr.buffer);
pascal@4701 1786 exit_1:
pascal@4701 1787 if (!buf)
pascal@4701 1788 @@ -719,5 +655,19 @@
pascal@4701 1789 exit_0:
pascal@4701 1790 return ret;
pascal@4701 1791 }
pascal@4701 1792 +#if defined(CONFIG_DECOMPRESS_LZMA_NEEDED) && !defined(PREBOOT)
pascal@4701 1793 +EXPORT_SYMBOL(unlzma);
pascal@4701 1794 +#endif
pascal@4701 1795
pascal@4701 1796 -#define decompress unlzma
pascal@4701 1797 +#ifdef PREBOOT
pascal@4701 1798 +STATIC int INIT decompress(unsigned char *buf, int in_len,
pascal@4701 1799 + int(*fill)(void*, unsigned int),
pascal@4701 1800 + int(*flush)(void*, unsigned int),
pascal@4701 1801 + unsigned char *output,
pascal@4701 1802 + int *posp,
pascal@4701 1803 + void(*error_fn)(char *x)
pascal@4701 1804 + )
pascal@4701 1805 +{
pascal@4701 1806 + return unlzma(buf, in_len - 4, fill, flush, output, posp, error_fn);
pascal@4701 1807 +}
pascal@4701 1808 +#endif