summaryrefslogtreecommitdiff
path: root/lib/common
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-01-19 10:43:33 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-01-19 11:04:33 +0100
commit07f73dfc2c4b5779fe57095b79c962fca4549788 (patch)
tree6fdff620035ac085c3e4ef1eec2092d93fa7edc5 /lib/common
parent4249e123d321650050259fb602f06497519077d0 (diff)
libcommon: backport block processor API update
The changes from commit 5191a25b92f903bcc2142be7ea1bfbe5ea1f5096 are backported here in a separate commit since master had some restructuring of libcommon.a after version 1.0.2 and the commit cannot be rebased directly. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/common')
-rw-r--r--lib/common/writer.c42
1 files changed, 36 insertions, 6 deletions
diff --git a/lib/common/writer.c b/lib/common/writer.c
index 9032a99..dc7d193 100644
--- a/lib/common/writer.c
+++ b/lib/common/writer.c
@@ -67,6 +67,7 @@ void sqfs_writer_cfg_init(sqfs_writer_cfg_t *cfg)
int sqfs_writer_init(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *wrcfg)
{
+ sqfs_block_processor_desc_t blkdesc;
sqfs_compressor_config_t cfg;
int ret, flags;
@@ -103,6 +104,23 @@ int sqfs_writer_init(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *wrcfg)
goto fail_fs;
}
+ cfg.flags |= SQFS_COMP_FLAG_UNCOMPRESS;
+ ret = sqfs_compressor_create(&cfg, &sqfs->uncmp);
+
+#ifdef WITH_LZO
+ if (cfg.id == SQFS_COMP_LZO) {
+ if (ret == 0 && sqfs->uncmp != NULL)
+ sqfs_destroy(sqfs->uncmp);
+
+ ret = lzo_compressor_create(&cfg, &sqfs->uncmp);
+ }
+#endif
+
+ if (ret != 0) {
+ sqfs_perror(wrcfg->filename, "creating uncompressor", ret);
+ goto fail_cmp1;
+ }
+
ret = sqfs_super_init(&sqfs->super, wrcfg->block_size,
sqfs->fs.defaults.st_mtime, wrcfg->comp_id);
if (ret) {
@@ -138,12 +156,21 @@ int sqfs_writer_init(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *wrcfg)
goto fail_blkwr;
}
- sqfs->data = sqfs_block_processor_create(sqfs->super.block_size,
- sqfs->cmp, wrcfg->num_jobs,
- wrcfg->max_backlog,
- sqfs->blkwr, sqfs->fragtbl);
- if (sqfs->data == NULL) {
- perror("creating data block processor");
+ memset(&blkdesc, 0, sizeof(blkdesc));
+ blkdesc.size = sizeof(blkdesc);
+ blkdesc.max_block_size = wrcfg->block_size;
+ blkdesc.num_workers = wrcfg->num_jobs;
+ blkdesc.max_backlog = wrcfg->max_backlog;
+ blkdesc.cmp = sqfs->cmp;
+ blkdesc.wr = sqfs->blkwr;
+ blkdesc.tbl = sqfs->fragtbl;
+ blkdesc.file = sqfs->outfile;
+ blkdesc.uncmp = sqfs->uncmp;
+
+ ret = sqfs_block_processor_create_ex(&blkdesc, &sqfs->data);
+ if (ret != 0) {
+ sqfs_perror(wrcfg->filename, "creating data block processor",
+ ret);
goto fail_fragtbl;
}
@@ -204,6 +231,8 @@ fail_fragtbl:
fail_blkwr:
sqfs_destroy(sqfs->blkwr);
fail_cmp:
+ sqfs_destroy(sqfs->uncmp);
+fail_cmp1:
sqfs_destroy(sqfs->cmp);
fail_fs:
fstree_cleanup(&sqfs->fs);
@@ -311,6 +340,7 @@ void sqfs_writer_cleanup(sqfs_writer_t *sqfs, int status)
sqfs_destroy(sqfs->blkwr);
sqfs_destroy(sqfs->fragtbl);
sqfs_destroy(sqfs->cmp);
+ sqfs_destroy(sqfs->uncmp);
fstree_cleanup(&sqfs->fs);
sqfs_destroy(sqfs->outfile);