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"
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
15 +config SQUASHFS_SUPPORT_ZLIB
17 + prompt "Support ZLIB compression" if SQUASHFS_SUPPORT_LZMA
22 + ZLIB is the default compression used in squashfs. If you are
23 + using LZMA compression instead, you can remove support for ZLIB
26 +config SQUASHFS_SUPPORT_LZMA
27 + bool "Support LZMA compression"
31 + By default SquashFS uses ZLIB compression, however (if your tools
32 + support it, you can use LZMA instead, which saves space.
35 config SQUASHFS_FRAGMENT_CACHE_SIZE
36 int "Number of fragments cached" if SQUASHFS_EMBEDDED
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
43 #define ZLIB_COMPRESSION 1
44 +#define LZMA_COMPRESSION 2
46 struct squashfs_super_block {
48 --- a/fs/squashfs/super.c
49 +++ b/fs/squashfs/super.c
54 -#define SQUASHFS_CRYPTO_ALG "zlib"
55 +static int squashfs_setup_zlib(struct squashfs_sb_info *msblk)
57 + int err = -EOPNOTSUPP;
59 +#ifdef CONFIG_SQUASHFS_SUPPORT_ZLIB
65 + .nla_len = nla_attr_size(sizeof(int)),
66 + .nla_type = ZLIB_DECOMP_WINDOWBITS,
71 + msblk->tfm = crypto_alloc_pcomp("zlib", 0,
73 + if (IS_ERR(msblk->tfm)) {
74 + ERROR("Failed to load zlib crypto module\n");
75 + return PTR_ERR(msblk->tfm);
78 + err = crypto_decompress_setup(msblk->tfm, ¶ms, sizeof(params));
80 + ERROR("Failed to set up decompression parameters\n");
81 + crypto_free_pcomp(msblk->tfm);
88 +static int squashfs_setup_lzma(struct squashfs_sb_info *msblk)
90 + int err = -EOPNOTSUPP;
92 +#ifdef CONFIG_SQUASHFS_SUPPORT_LZMA
93 + msblk->tfm = crypto_alloc_pcomp("lzma", 0,
95 + if (IS_ERR(msblk->tfm)) {
96 + ERROR("Failed to load lzma crypto module\n");
97 + return PTR_ERR(msblk->tfm);
100 + err = crypto_decompress_setup(msblk->tfm, NULL, 0);
102 + ERROR("Failed to set up decompression parameters\n");
103 + crypto_free_pcomp(msblk->tfm);
110 static struct file_system_type squashfs_fs_type;
111 static struct super_operations squashfs_super_ops;
113 -static int supported_squashfs_filesystem(short major, short minor, short comp)
114 +static int supported_squashfs_filesystem(short major, short minor)
116 if (major < SQUASHFS_MAJOR) {
117 ERROR("Major/Minor mismatch, older Squashfs %d.%d "
118 @@ -66,9 +118,6 @@ static int supported_squashfs_filesystem
122 - if (comp != ZLIB_COMPRESSION)
128 @@ -83,16 +132,6 @@ static int squashfs_fill_super(struct su
129 unsigned short flags;
130 unsigned int fragments;
131 u64 lookup_table_start;
137 - .nla_len = nla_attr_size(sizeof(int)),
138 - .nla_type = ZLIB_DECOMP_WINDOWBITS,
144 TRACE("Entered squashfs_fill_superblock\n");
145 @@ -104,21 +143,6 @@ static int squashfs_fill_super(struct su
147 msblk = sb->s_fs_info;
149 - msblk->tfm = crypto_alloc_pcomp(SQUASHFS_CRYPTO_ALG, 0,
151 - if (IS_ERR(msblk->tfm)) {
152 - ERROR("Failed to load %s crypto module\n",
153 - SQUASHFS_CRYPTO_ALG);
154 - err = PTR_ERR(msblk->tfm);
158 - err = crypto_decompress_setup(msblk->tfm, ¶ms, sizeof(params));
160 - ERROR("Failed to set up decompression parameters\n");
164 sblk = kzalloc(sizeof(*sblk), GFP_KERNEL);
166 ERROR("Failed to allocate squashfs_super_block\n");
167 @@ -158,8 +182,21 @@ static int squashfs_fill_super(struct su
169 /* Check the MAJOR & MINOR versions and compression type */
170 err = supported_squashfs_filesystem(le16_to_cpu(sblk->s_major),
171 - le16_to_cpu(sblk->s_minor),
172 - le16_to_cpu(sblk->compression));
173 + le16_to_cpu(sblk->s_minor));
177 + switch(le16_to_cpu(sblk->compression)) {
178 + case ZLIB_COMPRESSION:
179 + err = squashfs_setup_zlib(msblk);
181 + case LZMA_COMPRESSION:
182 + err = squashfs_setup_lzma(msblk);
191 @@ -315,21 +352,16 @@ allocate_root:
196 + crypto_free_pcomp(msblk->tfm);
197 squashfs_cache_delete(msblk->block_cache);
198 squashfs_cache_delete(msblk->fragment_cache);
199 squashfs_cache_delete(msblk->read_page);
200 kfree(msblk->inode_lookup_table);
201 kfree(msblk->fragment_index);
202 kfree(msblk->id_table);
203 - crypto_free_pcomp(msblk->tfm);
204 - kfree(sb->s_fs_info);
205 - sb->s_fs_info = NULL;
210 - crypto_free_pcomp(msblk->tfm);
212 kfree(sb->s_fs_info);
213 sb->s_fs_info = NULL;