aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/common/comp_lzo.c19
-rw-r--r--lib/sqfs/comp/gzip.c17
-rw-r--r--lib/sqfs/comp/lz4.c19
-rw-r--r--lib/sqfs/comp/lzma.c14
-rw-r--r--lib/sqfs/comp/xz.c16
-rw-r--r--lib/sqfs/comp/zstd.c18
6 files changed, 103 insertions, 0 deletions
diff --git a/lib/common/comp_lzo.c b/lib/common/comp_lzo.c
index a0c838a..8d0335e 100644
--- a/lib/common/comp_lzo.c
+++ b/lib/common/comp_lzo.c
@@ -48,6 +48,7 @@ static const struct {
typedef struct {
sqfs_compressor_t base;
+ size_t block_size;
int algorithm;
int level;
@@ -182,6 +183,22 @@ static sqfs_s32 lzo_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
return len;
}
+static void lzo_get_configuration(const sqfs_compressor_t *base,
+ sqfs_compressor_config_t *cfg)
+{
+ const lzo_compressor_t *lzo = (const lzo_compressor_t *)base;
+
+ memset(cfg, 0, sizeof(*cfg));
+ cfg->id = SQFS_COMP_LZO;
+ cfg->block_size = lzo->block_size;
+
+ cfg->opt.lzo.algorithm = lzo->algorithm;
+ cfg->opt.lzo.level = lzo->level;
+
+ if (base->do_block == lzo_uncomp_block)
+ cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS;
+}
+
static sqfs_compressor_t *lzo_create_copy(sqfs_compressor_t *cmp)
{
lzo_compressor_t *other = (lzo_compressor_t *)cmp;
@@ -242,11 +259,13 @@ sqfs_compressor_t *lzo_compressor_create(const sqfs_compressor_config_t *cfg)
if (lzo == NULL)
return NULL;
+ lzo->block_size = cfg->block_size;
lzo->algorithm = cfg->opt.lzo.algorithm;
lzo->level = cfg->opt.lzo.level;
lzo->buf_size = scratch_size;
lzo->work_size = lzo_algs[cfg->opt.lzo.algorithm].bufsize;
+ base->get_configuration = lzo_get_configuration;
base->do_block = (cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS) ?
lzo_uncomp_block : lzo_comp_block;
base->write_options = lzo_write_options;
diff --git a/lib/sqfs/comp/gzip.c b/lib/sqfs/comp/gzip.c
index 37491bb..34164a6 100644
--- a/lib/sqfs/comp/gzip.c
+++ b/lib/sqfs/comp/gzip.c
@@ -44,6 +44,22 @@ static void gzip_destroy(sqfs_object_t *base)
free(gzip);
}
+static void gzip_get_configuration(const sqfs_compressor_t *base,
+ sqfs_compressor_config_t *cfg)
+{
+ const gzip_compressor_t *gzip = (const gzip_compressor_t *)base;
+
+ memset(cfg, 0, sizeof(*cfg));
+ cfg->id = SQFS_COMP_GZIP;
+ cfg->flags = gzip->opt.strategies;
+ cfg->block_size = gzip->block_size;
+ cfg->opt.gzip.level = gzip->opt.level;
+ cfg->opt.gzip.window_size = gzip->opt.window;
+
+ if (!gzip->compress)
+ cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS;
+}
+
static int gzip_write_options(sqfs_compressor_t *base, sqfs_file_t *file)
{
gzip_compressor_t *gzip = (gzip_compressor_t *)base;
@@ -263,6 +279,7 @@ sqfs_compressor_t *gzip_compressor_create(const sqfs_compressor_config_t *cfg)
gzip->opt.strategies = cfg->flags & SQFS_COMP_FLAG_GZIP_ALL;
gzip->compress = (cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS) == 0;
gzip->block_size = cfg->block_size;
+ base->get_configuration = gzip_get_configuration;
base->do_block = gzip_do_block;
base->write_options = gzip_write_options;
base->read_options = gzip_read_options;
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;
diff --git a/lib/sqfs/comp/lzma.c b/lib/sqfs/comp/lzma.c
index 900cc14..451a6ca 100644
--- a/lib/sqfs/comp/lzma.c
+++ b/lib/sqfs/comp/lzma.c
@@ -143,6 +143,19 @@ static sqfs_s32 lzma_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
return hdrsize;
}
+static void lzma_get_configuration(const sqfs_compressor_t *base,
+ sqfs_compressor_config_t *cfg)
+{
+ const lzma_compressor_t *lzma = (const lzma_compressor_t *)base;
+
+ memset(cfg, 0, sizeof(*cfg));
+ cfg->id = SQFS_COMP_LZMA;
+ cfg->block_size = lzma->block_size;
+
+ if (base->do_block == lzma_uncomp_block)
+ cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS;
+}
+
static sqfs_compressor_t *lzma_create_copy(sqfs_compressor_t *cmp)
{
lzma_compressor_t *copy = malloc(sizeof(*copy));
@@ -176,6 +189,7 @@ sqfs_compressor_t *lzma_compressor_create(const sqfs_compressor_config_t *cfg)
if (lzma->block_size < SQFS_META_BLOCK_SIZE)
lzma->block_size = SQFS_META_BLOCK_SIZE;
+ base->get_configuration = lzma_get_configuration;
base->do_block = (cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS) ?
lzma_uncomp_block : lzma_comp_block;
base->write_options = lzma_write_options;
diff --git a/lib/sqfs/comp/xz.c b/lib/sqfs/comp/xz.c
index d612729..a600956 100644
--- a/lib/sqfs/comp/xz.c
+++ b/lib/sqfs/comp/xz.c
@@ -196,6 +196,21 @@ static sqfs_s32 xz_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
return SQFS_ERROR_COMPRESSOR;
}
+static void xz_get_configuration(const sqfs_compressor_t *base,
+ sqfs_compressor_config_t *cfg)
+{
+ const xz_compressor_t *xz = (const xz_compressor_t *)base;
+
+ memset(cfg, 0, sizeof(*cfg));
+ cfg->id = SQFS_COMP_XZ;
+ cfg->flags = xz->flags;
+ cfg->block_size = xz->block_size;
+ cfg->opt.xz.dict_size = xz->dict_size;
+
+ if (base->do_block == xz_uncomp_block)
+ cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS;
+}
+
static sqfs_compressor_t *xz_create_copy(sqfs_compressor_t *cmp)
{
xz_compressor_t *xz = malloc(sizeof(*xz));
@@ -233,6 +248,7 @@ sqfs_compressor_t *xz_compressor_create(const sqfs_compressor_config_t *cfg)
xz->flags = cfg->flags;
xz->dict_size = cfg->opt.xz.dict_size;
xz->block_size = cfg->block_size;
+ base->get_configuration = xz_get_configuration;
base->do_block = (cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS) ?
xz_uncomp_block : xz_comp_block;
base->write_options = xz_write_options;
diff --git a/lib/sqfs/comp/zstd.c b/lib/sqfs/comp/zstd.c
index 4bd9456..e01f87d 100644
--- a/lib/sqfs/comp/zstd.c
+++ b/lib/sqfs/comp/zstd.c
@@ -18,6 +18,7 @@
typedef struct {
sqfs_compressor_t base;
+ size_t block_size;
ZSTD_CCtx *zctx;
int level;
} zstd_compressor_t;
@@ -91,6 +92,21 @@ static sqfs_s32 zstd_uncomp_block(sqfs_compressor_t *base, const sqfs_u8 *in,
return ret;
}
+static void zstd_get_configuration(const sqfs_compressor_t *base,
+ sqfs_compressor_config_t *cfg)
+{
+ const zstd_compressor_t *zstd = (const zstd_compressor_t *)base;
+
+ memset(cfg, 0, sizeof(*cfg));
+ cfg->id = SQFS_COMP_ZSTD;
+
+ cfg->block_size = zstd->block_size;
+ cfg->opt.zstd.level = zstd->level;
+
+ if (base->do_block == zstd_uncomp_block)
+ cfg->flags |= SQFS_COMP_FLAG_UNCOMPRESS;
+}
+
static sqfs_compressor_t *zstd_create_copy(sqfs_compressor_t *cmp)
{
zstd_compressor_t *zstd = malloc(sizeof(*zstd));
@@ -136,12 +152,14 @@ sqfs_compressor_t *zstd_compressor_create(const sqfs_compressor_config_t *cfg)
if (zstd == NULL)
return NULL;
+ zstd->block_size = cfg->block_size;
zstd->zctx = ZSTD_createCCtx();
if (zstd->zctx == NULL) {
free(zstd);
return NULL;
}
+ base->get_configuration = zstd_get_configuration;
base->do_block = cfg->flags & SQFS_COMP_FLAG_UNCOMPRESS ?
zstd_uncomp_block : zstd_comp_block;
base->write_options = zstd_write_options;