diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-25 06:50:03 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-09-25 06:50:03 +0200 |
commit | 9434bdfaedb733e1441d87fedde8056efeda7145 (patch) | |
tree | 48b2d8c9e113170f9b64337507acd5d0981e9c87 /lib/sqfs/blk_proc/process_block.c | |
parent | 8f0f1f4c8047a97012c55dc057780ff76667aacc (diff) |
More refactoring of the block processor
Basically just moving functions around and renaming things.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/blk_proc/process_block.c')
-rw-r--r-- | lib/sqfs/blk_proc/process_block.c | 90 |
1 files changed, 0 insertions, 90 deletions
diff --git a/lib/sqfs/blk_proc/process_block.c b/lib/sqfs/blk_proc/process_block.c deleted file mode 100644 index 2951406..0000000 --- a/lib/sqfs/blk_proc/process_block.c +++ /dev/null @@ -1,90 +0,0 @@ -/* SPDX-License-Identifier: LGPL-3.0-or-later */ -/* - * process_block.c - * - * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at> - */ -#define SQFS_BUILDING_DLL -#include "internal.h" - -#include <string.h> - -static int allign_file(sqfs_block_processor_t *proc, sqfs_block_t *blk) -{ - if (!(blk->flags & SQFS_BLK_ALLIGN)) - return 0; - - return padd_sqfs(proc->file, proc->file->get_size(proc->file), - proc->devblksz); -} - -int process_completed_block(sqfs_block_processor_t *proc, sqfs_block_t *blk) -{ - size_t start, count; - uint64_t offset; - uint32_t out; - int err; - - if (blk->flags & SQFS_BLK_FIRST_BLOCK) { - proc->start = proc->file->get_size(proc->file); - proc->file_start = proc->num_blocks; - - err = allign_file(proc, blk); - if (err) - return err; - } - - if (blk->size != 0) { - out = blk->size; - if (!(blk->flags & SQFS_BLK_IS_COMPRESSED)) - out |= 1 << 24; - - offset = proc->file->get_size(proc->file); - - if (blk->flags & SQFS_BLK_FRAGMENT_BLOCK) { - offset = htole64(offset); - proc->fragments[blk->index].start_offset = offset; - proc->fragments[blk->index].pad0 = 0; - proc->fragments[blk->index].size = htole32(out); - } else { - blk->inode->block_sizes[blk->index] = out; - } - - err = store_block_location(proc, offset, out, blk->checksum); - if (err) - return err; - - err = proc->file->write_at(proc->file, offset, - blk->data, blk->size); - if (err) - return err; - } - - if (blk->flags & SQFS_BLK_LAST_BLOCK) { - err = allign_file(proc, blk); - if (err) - return err; - - count = proc->num_blocks - proc->file_start; - start = deduplicate_blocks(proc, count); - offset = proc->blocks[start].offset; - - sqfs_inode_set_file_block_start(blk->inode, offset); - - if (start < proc->file_start) { - offset = start + count; - - if (offset >= proc->file_start) { - proc->num_blocks = offset; - } else { - proc->num_blocks = proc->file_start; - } - - err = proc->file->truncate(proc->file, proc->start); - if (err) - return err; - } - } - - return 0; -} |