diff options
author | Phillip Lougher <phillip@lougher.demon.co.uk> | 2011-02-28 01:45:42 +0000 |
---|---|---|
committer | Phillip Lougher <phillip@lougher.demon.co.uk> | 2011-02-28 18:21:59 +0000 |
commit | b7fc0ff09d24b372dc04b0c02b80659c0a66fdfe (patch) | |
tree | 9cd9a94c3b07ef8064e1952a376d964776aa4571 /fs/squashfs/decompressor.c | |
parent | 100b33c8bd8a3235fd0b7948338d6cbb3db3c63d (diff) | |
download | kernel_samsung_smdk4412-b7fc0ff09d24b372dc04b0c02b80659c0a66fdfe.tar.gz kernel_samsung_smdk4412-b7fc0ff09d24b372dc04b0c02b80659c0a66fdfe.tar.bz2 kernel_samsung_smdk4412-b7fc0ff09d24b372dc04b0c02b80659c0a66fdfe.zip |
Squashfs: extend decompressor framework to handle compression options
Extend decompressor framework to handle compression options stored in
the filesystem. These options can be used by the relevant decompressor
at initialisation time to over-ride defaults.
The presence of compression options in the filesystem is indicated by
the COMP_OPT filesystem flag. If present the data is read from the
filesystem and passed to the decompressor init function. The decompressor
init function signature has been extended to take this data.
Also update the init function signature in the glib, lzo and xz
decompressor wrappers.
Signed-off-by: Phillip Lougher <phillip@lougher.demon.co.uk>
Diffstat (limited to 'fs/squashfs/decompressor.c')
-rw-r--r-- | fs/squashfs/decompressor.c | 34 |
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; +} |