summaryrefslogtreecommitdiff
path: root/lib/sqfs/comp/lz4.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-25 09:13:39 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-02-27 01:05:42 +0100
commit3c1a4c2548cbbae96f44469278b53046c8b48868 (patch)
treecf528c5338f850012744e3376eae502767bfdc21 /lib/sqfs/comp/lz4.c
parentc9429aeece3b8642de637f7a21e68046bd690658 (diff)
Add a function to the compressor interface to get the configuration
This allows getting the compressor configuration back after creating it, for various purposes. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/comp/lz4.c')
-rw-r--r--lib/sqfs/comp/lz4.c19
1 files changed, 19 insertions, 0 deletions
diff --git a/lib/sqfs/comp/lz4.c b/lib/sqfs/comp/lz4.c
index 7656d67..f298c67 100644
--- a/lib/sqfs/comp/lz4.c
+++ b/lib/sqfs/comp/lz4.c
@@ -18,6 +18,7 @@
typedef struct {
sqfs_compressor_t base;
+ size_t block_size;
bool high_compression;
} lz4_compressor_t;
@@ -99,6 +100,22 @@ static sqfs_s32 lz4_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
return ret;
}
+static void lz4_get_configuration(const sqfs_compressor_t *base,
+ sqfs_compressor_config_t *cfg)
+{
+ const lz4_compressor_t *lz4 = (const lz4_compressor_t *)base;
+
+ memset(cfg, 0, sizeof(*cfg));
+ cfg->id = SQFS_COMP_LZ4;
+ cfg->block_size = lz4->block_size;
+
+ if (lz4->high_compression)
+ cfg->flags |= SQFS_COMP_FLAG_LZ4_HC;
+
+ if (base->do_block == lz4_uncomp_block)
+ cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS;
+}
+
static sqfs_compressor_t *lz4_create_copy(sqfs_compressor_t *cmp)
{
lz4_compressor_t *lz4 = malloc(sizeof(*lz4));
@@ -131,7 +148,9 @@ sqfs_compressor_t *lz4_compressor_create(const sqfs_compressor_config_t *cfg)
return NULL;
lz4->high_compression = (cfg->flags & SQFS_COMP_FLAG_LZ4_HC) != 0;
+ lz4->block_size = cfg->block_size;
+ base->get_configuration = lz4_get_configuration;
base->do_block = (cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS) ?
lz4_uncomp_block : lz4_comp_block;
base->write_options = lz4_write_options;