diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2021-01-15 17:34:58 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2021-01-19 04:05:53 +0100 |
commit | 5191a25b92f903bcc2142be7ea1bfbe5ea1f5096 (patch) | |
tree | 9ae06f311ea53d765c5bf156cd49d0f578a6a196 /lib | |
parent | 405d133e7f0dc0f92f54f08ef6078208028448a1 (diff) |
libcommon: Use the newer API for the block processor
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib')
-rw-r--r-- | lib/common/writer/cleanup.c | 1 | ||||
-rw-r--r-- | lib/common/writer/init.c | 49 |
2 files changed, 40 insertions, 10 deletions
diff --git a/lib/common/writer/cleanup.c b/lib/common/writer/cleanup.c index 16e846b..1af7a99 100644 --- a/lib/common/writer/cleanup.c +++ b/lib/common/writer/cleanup.c @@ -21,6 +21,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); diff --git a/lib/common/writer/init.c b/lib/common/writer/init.c index d606d26..06726ce 100644 --- a/lib/common/writer/init.c +++ b/lib/common/writer/init.c @@ -40,6 +40,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; @@ -76,23 +77,40 @@ 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_cmp; + } + ret = sqfs_super_init(&sqfs->super, wrcfg->block_size, sqfs->fs.defaults.st_mtime, wrcfg->comp_id); if (ret) { sqfs_perror(wrcfg->filename, "initializing super block", ret); - goto fail_cmp; + goto fail_uncmp; } ret = sqfs_super_write(&sqfs->super, sqfs->outfile); if (ret) { sqfs_perror(wrcfg->filename, "writing super block", ret); - goto fail_cmp; + goto fail_uncmp; } ret = sqfs->cmp->write_options(sqfs->cmp, sqfs->outfile); if (ret < 0) { sqfs_perror(wrcfg->filename, "writing compressor options", ret); - goto fail_cmp; + goto fail_uncmp; } if (ret > 0) @@ -102,7 +120,7 @@ int sqfs_writer_init(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *wrcfg) wrcfg->devblksize, 0); if (sqfs->blkwr == NULL) { perror("creating block writer"); - goto fail_cmp; + goto fail_uncmp; } sqfs->fragtbl = sqfs_frag_table_create(0); @@ -111,12 +129,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; } @@ -176,6 +203,8 @@ fail_fragtbl: sqfs_destroy(sqfs->fragtbl); fail_blkwr: sqfs_destroy(sqfs->blkwr); +fail_uncmp: + sqfs_destroy(sqfs->uncmp); fail_cmp: sqfs_destroy(sqfs->cmp); fail_fs: |