3 * Phillip Lougher <phillip@squashfs.org.uk>
5 * This work is licensed under the terms of the GNU GPL, version 2. See
6 * the COPYING file in the top-level directory.
9 #include <linux/types.h>
10 #include <linux/mutex.h>
11 #include <linux/slab.h>
12 #include <linux/buffer_head.h>
14 #include "squashfs_fs.h"
15 #include "squashfs_fs_sb.h"
16 #include "decompressor.h"
20 * This file implements single-threaded decompression in the
21 * decompressor framework
24 struct squashfs_stream {
29 void *squashfs_decompressor_create(struct squashfs_sb_info *msblk,
32 struct squashfs_stream *stream;
35 stream = kmalloc(sizeof(*stream), GFP_KERNEL);
39 stream->stream = msblk->decompressor->init(msblk, comp_opts);
40 if (IS_ERR(stream->stream)) {
41 err = PTR_ERR(stream->stream);
46 mutex_init(&stream->mutex);
54 void squashfs_decompressor_destroy(struct squashfs_sb_info *msblk)
56 struct squashfs_stream *stream = msblk->stream;
59 msblk->decompressor->free(stream->stream);
64 int squashfs_decompress(struct squashfs_sb_info *msblk, struct buffer_head **bh,
65 int b, int offset, int length, struct squashfs_page_actor *output)
68 struct squashfs_stream *stream = msblk->stream;
70 mutex_lock(&stream->mutex);
71 res = msblk->decompressor->decompress(msblk, stream->stream, bh, b,
72 offset, length, output);
73 mutex_unlock(&stream->mutex);
76 ERROR("%s decompression failed, data probably corrupt\n",
77 msblk->decompressor->name);
82 int squashfs_max_decompressors(void)