1 --- a/fs/squashfs/inode.c
2 +++ b/fs/squashfs/inode.c
4 * Copyright (c) 2002, 2003, 2004, 2005, 2006
5 * Phillip Lougher <phillip@lougher.org.uk>
7 + * LZMA decompressor support added by Oleg I. Vdovikin
8 + * Copyright (c) 2005 Oleg I.Vdovikin <oleg@cs.msu.su>
10 * This program is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU General Public License
12 * as published by the Free Software Foundation; either version 2,
17 +#define SQUASHFS_LZMA
18 #include <linux/types.h>
19 #include <linux/squashfs_fs.h>
20 #include <linux/module.h>
26 +#include <linux/LzmaDecode.h>
28 +/* default LZMA settings, should be in sync with mksquashfs */
33 +#define LZMA_WORKSPACE_SIZE ((LZMA_BASE_SIZE + \
34 + (LZMA_LIT_SIZE << (LZMA_LC + LZMA_LP))) * sizeof(CProb))
38 static void squashfs_put_super(struct super_block *);
39 static int squashfs_statfs(struct dentry *, struct kstatfs *);
40 static int squashfs_symlink_readpage(struct file *file, struct page *page);
42 const char *, void *, struct vfsmount *);
46 +static unsigned char lzma_workspace[LZMA_WORKSPACE_SIZE];
48 static z_stream stream;
51 static struct file_system_type squashfs_fs_type = {
58 + if ((zlib_err = LzmaDecode(lzma_workspace,
59 + LZMA_WORKSPACE_SIZE, LZMA_LC, LZMA_LP, LZMA_PB,
60 + c_buffer, c_byte, buffer, msblk->read_size, &bytes)) != LZMA_RESULT_OK)
62 + ERROR("lzma returned unexpected result 0x%x\n", zlib_err);
66 stream.next_in = c_buffer;
67 stream.avail_in = c_byte;
68 stream.next_out = buffer;
72 bytes = stream.total_out;
75 up(&msblk->read_data_mutex);
78 @@ -2045,15 +2075,19 @@
79 printk(KERN_INFO "squashfs: version 3.0 (2006/03/15) "
82 +#ifndef SQUASHFS_LZMA
83 if (!(stream.workspace = vmalloc(zlib_inflate_workspacesize()))) {
84 ERROR("Failed to allocate zlib workspace\n");
91 if ((err = register_filesystem(&squashfs_fs_type))) {
92 +#ifndef SQUASHFS_LZMA
93 vfree(stream.workspace);
100 static void __exit exit_squashfs_fs(void)
102 +#ifndef SQUASHFS_LZMA
103 vfree(stream.workspace);
105 unregister_filesystem(&squashfs_fs_type);
106 destroy_inodecache();