summaryrefslogtreecommitdiff
path: root/lib/sqfs/block_processor/serial.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-01-16 00:23:20 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-01-19 06:01:51 +0100
commit8026849fda277f54a2a3e4fa5cf5d183cbc84bef (patch)
treef000e36ec9caab771888ad03338094a92e2e958b /lib/sqfs/block_processor/serial.c
parentc1a5ea0d4dceeb9354ff792fc510caa854223463 (diff)
libsqfs: Implement exact matching of fragments
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs/block_processor/serial.c')
-rw-r--r--lib/sqfs/block_processor/serial.c17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/sqfs/block_processor/serial.c b/lib/sqfs/block_processor/serial.c
index daa11fe..b20d5b0 100644
--- a/lib/sqfs/block_processor/serial.c
+++ b/lib/sqfs/block_processor/serial.c
@@ -61,6 +61,22 @@ static int block_processor_sync(sqfs_block_processor_t *proc)
return ((serial_block_processor_t *)proc)->status;
}
+static int compare_frag_in_flight(sqfs_block_processor_t *proc,
+ sqfs_block_t *frag, sqfs_u32 index,
+ sqfs_u32 offset)
+{
+ if (proc->frag_block == NULL || index != proc->frag_block->index)
+ return -1;
+
+ if (offset >= proc->frag_block->size)
+ return -1;
+
+ if (frag->size > (proc->frag_block->size - offset))
+ return -1;
+
+ return memcmp(proc->frag_block->data + offset, frag->data, frag->size);
+}
+
int sqfs_block_processor_create_ex(const sqfs_block_processor_desc_t *desc,
sqfs_block_processor_t **out)
{
@@ -82,6 +98,7 @@ int sqfs_block_processor_create_ex(const sqfs_block_processor_desc_t *desc,
proc->base.sync = block_processor_sync;
proc->base.append_to_work_queue = append_to_work_queue;
+ proc->base.compare_frag_in_flight = compare_frag_in_flight;
((sqfs_object_t *)proc)->destroy = block_processor_destroy;
*out = (sqfs_block_processor_t *)proc;