[kernel] add kexec fixes for mips from M. Syrchin
[openwrt.git] / target / linux / generic-2.6 / patches-2.6.30 / 053-squashfs_lzma.patch
1 --- a/fs/squashfs/Kconfig
2 +++ b/fs/squashfs/Kconfig
3 @@ -2,7 +2,6 @@ config SQUASHFS
4 tristate "SquashFS 4.0 - Squashed file system support"
5 depends on BLOCK
6 select CRYPTO
7 - select CRYPTO_ZLIB
8 help
9 Saying Y here includes support for SquashFS 4.0 (a Compressed
10 Read-Only File System). Squashfs is a highly compressed read-only
11 @@ -37,6 +36,26 @@ config SQUASHFS_EMBEDDED
12
13 If unsure, say N.
14
15 +config SQUASHFS_SUPPORT_ZLIB
16 + bool
17 + prompt "Support ZLIB compression" if SQUASHFS_SUPPORT_LZMA
18 + depends on SQUASHFS
19 + select CRYPTO_ZLIB
20 + default y
21 + help
22 + ZLIB is the default compression used in squashfs. If you are
23 + using LZMA compression instead, you can remove support for ZLIB
24 + entirely.
25 +
26 +config SQUASHFS_SUPPORT_LZMA
27 + bool "Support LZMA compression"
28 + depends on SQUASHFS
29 + select CRYPTO_UNLZMA
30 + help
31 + By default SquashFS uses ZLIB compression, however (if your tools
32 + support it, you can use LZMA instead, which saves space.
33 +
34 +
35 config SQUASHFS_FRAGMENT_CACHE_SIZE
36 int "Number of fragments cached" if SQUASHFS_EMBEDDED
37 depends on SQUASHFS
38 --- a/fs/squashfs/squashfs_fs.h
39 +++ b/fs/squashfs/squashfs_fs.h
40 @@ -212,6 +212,7 @@ struct meta_index {
41 * definitions for structures on disk
42 */
43 #define ZLIB_COMPRESSION 1
44 +#define LZMA_COMPRESSION 2
45
46 struct squashfs_super_block {
47 __le32 s_magic;
48 --- a/fs/squashfs/super.c
49 +++ b/fs/squashfs/super.c
50 @@ -47,13 +47,76 @@
51 #include "squashfs.h"
52
53
54 -#define SQUASHFS_CRYPTO_ALG "zlib"
55 +static int squashfs_setup_zlib(struct squashfs_sb_info *msblk)
56 +{
57 + int err = -EOPNOTSUPP;
58 +
59 +#ifdef CONFIG_SQUASHFS_SUPPORT_ZLIB
60 + struct {
61 + struct nlattr nla;
62 + int val;
63 + } params = {
64 + .nla = {
65 + .nla_len = nla_attr_size(sizeof(int)),
66 + .nla_type = ZLIB_DECOMP_WINDOWBITS,
67 + },
68 + .val = DEF_WBITS,
69 + };
70 +
71 + msblk->tfm = crypto_alloc_pcomp("zlib", 0,
72 + CRYPTO_ALG_ASYNC);
73 + if (IS_ERR(msblk->tfm)) {
74 + ERROR("Failed to load zlib crypto module\n");
75 + return PTR_ERR(msblk->tfm);
76 + }
77 +
78 + err = crypto_decompress_setup(msblk->tfm, &params, sizeof(params));
79 + if (err) {
80 + ERROR("Failed to set up decompression parameters\n");
81 + crypto_free_pcomp(msblk->tfm);
82 + }
83 +#endif
84 +
85 + return err;
86 +}
87 +
88 +static int squashfs_setup_lzma(struct squashfs_sb_info *msblk)
89 +{
90 + int err = -EOPNOTSUPP;
91 +
92 +#ifdef CONFIG_SQUASHFS_SUPPORT_LZMA
93 + struct {
94 + struct nlattr nla;
95 + int val;
96 + } params = {
97 + .nla = {
98 + .nla_len = nla_attr_size(sizeof(int)),
99 + .nla_type = UNLZMA_DECOMP_OUT_BUFFERS,
100 + },
101 + .val = (msblk->block_size / PAGE_CACHE_SIZE) + 1
102 + };
103
104 + msblk->tfm = crypto_alloc_pcomp("lzma", 0,
105 + CRYPTO_ALG_ASYNC);
106 + if (IS_ERR(msblk->tfm)) {
107 + ERROR("Failed to load lzma crypto module\n");
108 + return PTR_ERR(msblk->tfm);
109 + }
110 +
111 + err = crypto_decompress_setup(msblk->tfm, &params, sizeof(params));
112 + if (err) {
113 + ERROR("Failed to set up decompression parameters\n");
114 + crypto_free_pcomp(msblk->tfm);
115 + }
116 +#endif
117 +
118 + return err;
119 +}
120
121 static struct file_system_type squashfs_fs_type;
122 static struct super_operations squashfs_super_ops;
123
124 -static int supported_squashfs_filesystem(short major, short minor, short comp)
125 +static int supported_squashfs_filesystem(short major, short minor)
126 {
127 if (major < SQUASHFS_MAJOR) {
128 ERROR("Major/Minor mismatch, older Squashfs %d.%d "
129 @@ -66,9 +129,6 @@ static int supported_squashfs_filesystem
130 return -EINVAL;
131 }
132
133 - if (comp != ZLIB_COMPRESSION)
134 - return -EINVAL;
135 -
136 return 0;
137 }
138
139 @@ -83,16 +143,6 @@ static int squashfs_fill_super(struct su
140 unsigned short flags;
141 unsigned int fragments;
142 u64 lookup_table_start;
143 - struct {
144 - struct nlattr nla;
145 - int val;
146 - } params = {
147 - .nla = {
148 - .nla_len = nla_attr_size(sizeof(int)),
149 - .nla_type = ZLIB_DECOMP_WINDOWBITS,
150 - },
151 - .val = DEF_WBITS,
152 - };
153 int err;
154
155 TRACE("Entered squashfs_fill_superblock\n");
156 @@ -104,21 +154,6 @@ static int squashfs_fill_super(struct su
157 }
158 msblk = sb->s_fs_info;
159
160 - msblk->tfm = crypto_alloc_pcomp(SQUASHFS_CRYPTO_ALG, 0,
161 - CRYPTO_ALG_ASYNC);
162 - if (IS_ERR(msblk->tfm)) {
163 - ERROR("Failed to load %s crypto module\n",
164 - SQUASHFS_CRYPTO_ALG);
165 - err = PTR_ERR(msblk->tfm);
166 - goto failed_pcomp;
167 - }
168 -
169 - err = crypto_decompress_setup(msblk->tfm, &params, sizeof(params));
170 - if (err) {
171 - ERROR("Failed to set up decompression parameters\n");
172 - goto failure;
173 - }
174 -
175 sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
176 if (sblk == NULL) {
177 ERROR("Failed to allocate squashfs_super_block\n");
178 @@ -156,10 +191,28 @@ static int squashfs_fill_super(struct su
179 goto failed_mount;
180 }
181
182 + /* Check block size for sanity */
183 + msblk->block_size = le32_to_cpu(sblk->block_size);
184 + if (msblk->block_size > SQUASHFS_FILE_MAX_SIZE)
185 + goto failed_mount;
186 +
187 /* Check the MAJOR & MINOR versions and compression type */
188 err = supported_squashfs_filesystem(le16_to_cpu(sblk->s_major),
189 - le16_to_cpu(sblk->s_minor),
190 - le16_to_cpu(sblk->compression));
191 + le16_to_cpu(sblk->s_minor));
192 + if (err < 0)
193 + goto failed_mount;
194 +
195 + switch(le16_to_cpu(sblk->compression)) {
196 + case ZLIB_COMPRESSION:
197 + err = squashfs_setup_zlib(msblk);
198 + break;
199 + case LZMA_COMPRESSION:
200 + err = squashfs_setup_lzma(msblk);
201 + break;
202 + default:
203 + err = -EINVAL;
204 + break;
205 + }
206 if (err < 0)
207 goto failed_mount;
208
209 @@ -179,11 +232,6 @@ static int squashfs_fill_super(struct su
210 i_size_read(sb->s_bdev->bd_inode))
211 goto failed_mount;
212
213 - /* Check block size for sanity */
214 - msblk->block_size = le32_to_cpu(sblk->block_size);
215 - if (msblk->block_size > SQUASHFS_FILE_MAX_SIZE)
216 - goto failed_mount;
217 -
218 /*
219 * Check the system page size is not larger than the filesystem
220 * block size (by default 128K). This is currently not supported.
221 @@ -315,21 +363,16 @@ allocate_root:
222 return 0;
223
224 failed_mount:
225 + if (msblk->tfm)
226 + crypto_free_pcomp(msblk->tfm);
227 squashfs_cache_delete(msblk->block_cache);
228 squashfs_cache_delete(msblk->fragment_cache);
229 squashfs_cache_delete(msblk->read_page);
230 kfree(msblk->inode_lookup_table);
231 kfree(msblk->fragment_index);
232 kfree(msblk->id_table);
233 - crypto_free_pcomp(msblk->tfm);
234 - kfree(sb->s_fs_info);
235 - sb->s_fs_info = NULL;
236 kfree(sblk);
237 - return err;
238 -
239 failure:
240 - crypto_free_pcomp(msblk->tfm);
241 -failed_pcomp:
242 kfree(sb->s_fs_info);
243 sb->s_fs_info = NULL;
244 return err;
This page took 0.060658 seconds and 5 git commands to generate.