summaryrefslogtreecommitdiff
path: root/fs/squashfs/decompressor.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@linux-foundation.org>2011-03-24 08:02:21 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2011-03-24 08:02:21 -0700
commit5818fcc8bd1b27af4d40b8357b91a56cc3fae6a4 (patch)
treec2f266e82306fa98c78130b0dc79ef9716d3c9c7 /fs/squashfs/decompressor.c
parent0625bef6060fab4aab0e484130b59af5e9ac81bc (diff)
parent117a91e0f25fd7698e20ac3dfa62086be3dc82a3 (diff)
Merge git://git.kernel.org/pub/scm/linux/kernel/git/pkl/squashfs-linus
* git://git.kernel.org/pub/scm/linux/kernel/git/pkl/squashfs-linus: Squashfs: Use vmalloc rather than kmalloc for zlib workspace Squashfs: handle corruption of directory structure Squashfs: wrap squashfs_mount() definition Squashfs: xz_wrapper doesn't need to include squashfs_fs_i.h anymore Squashfs: Update documentation to include compression options Squashfs: Update Kconfig help text to include xz compression Squashfs: add compression options support to xz decompressor Squashfs: extend decompressor framework to handle compression options
Diffstat (limited to 'fs/squashfs/decompressor.c')
-rw-r--r--fs/squashfs/decompressor.c34
1 files changed, 34 insertions, 0 deletions
diff --git a/fs/squashfs/decompressor.c b/fs/squashfs/decompressor.c
index a5940e54c4d..e921bd21373 100644
--- a/fs/squashfs/decompressor.c
+++ b/fs/squashfs/decompressor.c
@@ -23,6 +23,7 @@
#include <linux/types.h>
#include <linux/mutex.h>
+#include <linux/slab.h>
#include <linux/buffer_head.h>
#include "squashfs_fs.h"
@@ -74,3 +75,36 @@ const struct squashfs_decompressor *squashfs_lookup_decompressor(int id)
return decompressor[i];
}
+
+
+void *squashfs_decompressor_init(struct super_block *sb, unsigned short flags)
+{
+ struct squashfs_sb_info *msblk = sb->s_fs_info;
+ void *strm, *buffer = NULL;
+ int length = 0;
+
+ /*
+ * Read decompressor specific options from file system if present
+ */
+ if (SQUASHFS_COMP_OPTS(flags)) {
+ buffer = kmalloc(PAGE_CACHE_SIZE, GFP_KERNEL);
+ if (buffer == NULL)
+ return ERR_PTR(-ENOMEM);
+
+ length = squashfs_read_data(sb, &buffer,
+ sizeof(struct squashfs_super_block), 0, NULL,
+ PAGE_CACHE_SIZE, 1);
+
+ if (length < 0) {
+ strm = ERR_PTR(length);
+ goto finished;
+ }
+ }
+
+ strm = msblk->decompressor->init(msblk, buffer, length);
+
+finished:
+ kfree(buffer);
+
+ return strm;
+}