remove empty directory
[openwrt.git] / target / linux / generic-2.6 / patches / 003-squashfs_lzma.patch
1 Index: linux-2.6.21.7/fs/squashfs/inode.c
2 ===================================================================
3 --- linux-2.6.21.7.orig/fs/squashfs/inode.c
4 +++ linux-2.6.21.7/fs/squashfs/inode.c
5 @@ -4,6 +4,9 @@
6 * Copyright (c) 2002, 2003, 2004, 2005, 2006
7 * Phillip Lougher <phillip@lougher.org.uk>
8 *
9 + * LZMA decompressor support added by Oleg I. Vdovikin
10 + * Copyright (c) 2005 Oleg I.Vdovikin <oleg@cs.msu.su>
11 + *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2,
15 @@ -21,6 +24,7 @@
16 * inode.c
17 */
18
19 +#define SQUASHFS_LZMA
20 #include <linux/types.h>
21 #include <linux/squashfs_fs.h>
22 #include <linux/module.h>
23 @@ -44,6 +48,19 @@
24
25 #include "squashfs.h"
26
27 +#ifdef SQUASHFS_LZMA
28 +#include <linux/LzmaDecode.h>
29 +
30 +/* default LZMA settings, should be in sync with mksquashfs */
31 +#define LZMA_LC 3
32 +#define LZMA_LP 0
33 +#define LZMA_PB 2
34 +
35 +#define LZMA_WORKSPACE_SIZE ((LZMA_BASE_SIZE + \
36 + (LZMA_LIT_SIZE << (LZMA_LC + LZMA_LP))) * sizeof(CProb))
37 +
38 +#endif
39 +
40 static void squashfs_put_super(struct super_block *);
41 static int squashfs_statfs(struct dentry *, struct kstatfs *);
42 static int squashfs_symlink_readpage(struct file *file, struct page *page);
43 @@ -64,7 +81,11 @@ static int squashfs_get_sb(struct file_s
44 const char *, void *, struct vfsmount *);
45
46
47 +#ifdef SQUASHFS_LZMA
48 +static unsigned char lzma_workspace[LZMA_WORKSPACE_SIZE];
49 +#else
50 static z_stream stream;
51 +#endif
52
53 static struct file_system_type squashfs_fs_type = {
54 .owner = THIS_MODULE,
55 @@ -249,6 +270,15 @@ SQSH_EXTERN unsigned int squashfs_read_d
56 if (compressed) {
57 int zlib_err;
58
59 +#ifdef SQUASHFS_LZMA
60 + if ((zlib_err = LzmaDecode(lzma_workspace,
61 + LZMA_WORKSPACE_SIZE, LZMA_LC, LZMA_LP, LZMA_PB,
62 + c_buffer, c_byte, buffer, msblk->read_size, &bytes)) != LZMA_RESULT_OK)
63 + {
64 + ERROR("lzma returned unexpected result 0x%x\n", zlib_err);
65 + bytes = 0;
66 + }
67 +#else
68 stream.next_in = c_buffer;
69 stream.avail_in = c_byte;
70 stream.next_out = buffer;
71 @@ -263,7 +293,7 @@ SQSH_EXTERN unsigned int squashfs_read_d
72 bytes = 0;
73 } else
74 bytes = stream.total_out;
75 -
76 +#endif
77 up(&msblk->read_data_mutex);
78 }
79
80 @@ -2045,15 +2075,19 @@ static int __init init_squashfs_fs(void)
81 printk(KERN_INFO "squashfs: version 3.0 (2006/03/15) "
82 "Phillip Lougher\n");
83
84 +#ifndef SQUASHFS_LZMA
85 if (!(stream.workspace = vmalloc(zlib_inflate_workspacesize()))) {
86 ERROR("Failed to allocate zlib workspace\n");
87 destroy_inodecache();
88 err = -ENOMEM;
89 goto out;
90 }
91 +#endif
92
93 if ((err = register_filesystem(&squashfs_fs_type))) {
94 +#ifndef SQUASHFS_LZMA
95 vfree(stream.workspace);
96 +#endif
97 destroy_inodecache();
98 }
99
100 @@ -2064,7 +2098,9 @@ out:
101
102 static void __exit exit_squashfs_fs(void)
103 {
104 +#ifndef SQUASHFS_LZMA
105 vfree(stream.workspace);
106 +#endif
107 unregister_filesystem(&squashfs_fs_type);
108 destroy_inodecache();
109 }
This page took 0.044605 seconds and 5 git commands to generate.