26
26
#include <linux/buffer_head.h>
27
27
#include <linux/slab.h>
28
28
#include <linux/xz.h>
29
#include <linux/bitops.h>
30
31
#include "squashfs_fs.h"
31
32
#include "squashfs_fs_sb.h"
32
#include "squashfs_fs_i.h"
33
33
#include "squashfs.h"
34
34
#include "decompressor.h"
41
static void *squashfs_xz_init(struct squashfs_sb_info *msblk)
42
__le32 dictionary_size;
46
static void *squashfs_xz_init(struct squashfs_sb_info *msblk, void *buff,
43
int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE);
45
struct squashfs_xz *stream = kmalloc(sizeof(*stream), GFP_KERNEL);
49
stream->state = xz_dec_init(XZ_PREALLOC, block_size);
50
if (stream->state == NULL)
49
struct comp_opts *comp_opts = buff;
50
struct squashfs_xz *stream;
51
int dict_size = msblk->block_size;
55
/* check compressor options are the expected length */
56
if (len < sizeof(*comp_opts)) {
61
dict_size = le32_to_cpu(comp_opts->dictionary_size);
63
/* the dictionary size should be 2^n or 2^n+2^(n+1) */
64
n = ffs(dict_size) - 1;
65
if (dict_size != (1 << n) && dict_size != (1 << n) +
72
dict_size = max_t(int, dict_size, SQUASHFS_METADATA_SIZE);
74
stream = kmalloc(sizeof(*stream), GFP_KERNEL);
80
stream->state = xz_dec_init(XZ_PREALLOC, dict_size);
81
if (stream->state == NULL) {
56
ERROR("Failed to allocate xz workspace\n");
90
ERROR("Failed to initialise xz decompressor\n");