diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-23 15:28:25 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-23 15:35:36 +0200 |
commit | b86cbb04c9cc72506783e175e871338b1f0e6750 (patch) | |
tree | dcb4f92b6962aa35cacb2db09219fd4dfbaf3d60 /lib/sqfs/blk_proc/fragtbl.c | |
parent | 8ee4a30a0f3545dac5b9a93b40c172f4fb4d44a1 (diff) |
Move the bulk of the work from the data writer to the block processor
Instead of calling a callback, the block processor now takes care of
writing the data blocks to the file in the correct order, keeping
track of fragment blocks and deduplicating blocks.
Some cleanup work remains to be done and the statistics have to be
repaired (yet again).
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/blk_proc/fragtbl.c')
-rw-r--r-- | lib/sqfs/blk_proc/fragtbl.c | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/sqfs/blk_proc/fragtbl.c b/lib/sqfs/blk_proc/fragtbl.c new file mode 100644 index 0000000..81baf09 --- /dev/null +++ b/lib/sqfs/blk_proc/fragtbl.c @@ -0,0 +1,36 @@ +/* SPDX-License-Identifier: LGPL-3.0-or-later */ +/* + * fragtbl.c + * + * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> + */ +#define SQFS_BUILDING_DLL +#include "internal.h" + +int sqfs_block_processor_write_fragment_table(sqfs_block_processor_t *proc, + sqfs_super_t *super) +{ + uint64_t start; + size_t size; + int ret; + + if (proc->num_fragments == 0) { + super->fragment_entry_count = 0; + super->fragment_table_start = 0xFFFFFFFFFFFFFFFFUL; + super->flags &= ~SQFS_FLAG_ALWAYS_FRAGMENTS; + super->flags |= SQFS_FLAG_NO_FRAGMENTS; + return 0; + } + + size = sizeof(proc->fragments[0]) * proc->num_fragments; + ret = sqfs_write_table(proc->file, proc->cmp, + proc->fragments, size, &start); + if (ret) + return ret; + + super->flags &= ~SQFS_FLAG_NO_FRAGMENTS; + super->flags |= SQFS_FLAG_ALWAYS_FRAGMENTS; + super->fragment_entry_count = proc->num_fragments; + super->fragment_table_start = start; + return 0; +} |