Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7fc0ff0 authored by Phillip Lougher's avatar Phillip Lougher
Browse files

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: default avatarPhillip Lougher <phillip@lougher.demon.co.uk>
parent 100b33c8
Loading
Loading
Loading
Loading
+34 −0
Original line number Diff line number Diff line
@@ -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;
}
+1 −6
Original line number Diff line number Diff line
@@ -24,7 +24,7 @@
 */

struct squashfs_decompressor {
	void	*(*init)(struct squashfs_sb_info *);
	void	*(*init)(struct squashfs_sb_info *, void *, int);
	void	(*free)(void *);
	int	(*decompress)(struct squashfs_sb_info *, void **,
		struct buffer_head **, int, int, int, int, int);
@@ -33,11 +33,6 @@ struct squashfs_decompressor {
	int	supported;
};

static inline void *squashfs_decompressor_init(struct squashfs_sb_info *msblk)
{
	return msblk->decompressor->init(msblk);
}

static inline void squashfs_decompressor_free(struct squashfs_sb_info *msblk,
	void *s)
{
+2 −2
Original line number Diff line number Diff line
@@ -37,7 +37,7 @@ struct squashfs_lzo {
	void	*output;
};

static void *lzo_init(struct squashfs_sb_info *msblk)
static void *lzo_init(struct squashfs_sb_info *msblk, void *buff, int len)
{
	int block_size = max_t(int, msblk->block_size, SQUASHFS_METADATA_SIZE);

@@ -58,7 +58,7 @@ static void *lzo_init(struct squashfs_sb_info *msblk)
failed:
	ERROR("Failed to allocate lzo workspace\n");
	kfree(stream);
	return NULL;
	return ERR_PTR(-ENOMEM);
}


+1 −0
Original line number Diff line number Diff line
@@ -48,6 +48,7 @@ extern int squashfs_read_table(struct super_block *, void *, u64, int);

/* decompressor.c */
extern const struct squashfs_decompressor *squashfs_lookup_decompressor(int);
extern void *squashfs_decompressor_init(struct super_block *, unsigned short);

/* export.c */
extern __le64 *squashfs_read_inode_lookup_table(struct super_block *, u64,
+4 −0
Original line number Diff line number Diff line
@@ -57,6 +57,7 @@
#define SQUASHFS_ALWAYS_FRAG		5
#define SQUASHFS_DUPLICATE		6
#define SQUASHFS_EXPORT			7
#define SQUASHFS_COMP_OPT		10

#define SQUASHFS_BIT(flag, bit)		((flag >> bit) & 1)

@@ -81,6 +82,9 @@
#define SQUASHFS_EXPORTABLE(flags)		SQUASHFS_BIT(flags, \
						SQUASHFS_EXPORT)

#define SQUASHFS_COMP_OPTS(flags)		SQUASHFS_BIT(flags, \
						SQUASHFS_COMP_OPT)

/* Max number of types and file types */
#define SQUASHFS_DIR_TYPE		1
#define SQUASHFS_REG_TYPE		2
Loading