summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/sqfs/Makemodule.am5
-rw-r--r--lib/sqfs/blk_proc/block.c (renamed from lib/sqfs/blk_proc/process_block.c)41
-rw-r--r--lib/sqfs/blk_proc/deduplicate.c49
-rw-r--r--lib/sqfs/blk_proc/fragment.c (renamed from lib/sqfs/blk_proc/fragtbl.c)4
-rw-r--r--lib/sqfs/blk_proc/internal.h11
-rw-r--r--lib/sqfs/blk_proc/pthread.c2
-rw-r--r--lib/sqfs/blk_proc/serial.c3
7 files changed, 50 insertions, 65 deletions
diff --git a/lib/sqfs/Makemodule.am b/lib/sqfs/Makemodule.am
index 7a02fa4..e8b9284 100644
--- a/lib/sqfs/Makemodule.am
+++ b/lib/sqfs/Makemodule.am
@@ -17,10 +17,9 @@ libsquashfs_la_SOURCES += lib/sqfs/dir_writer.c lib/sqfs/xattr_reader.c
libsquashfs_la_SOURCES += lib/sqfs/read_table.c lib/sqfs/comp/compressor.c
libsquashfs_la_SOURCES += lib/sqfs/io_stdin.c lib/sqfs/comp/internal.h
libsquashfs_la_SOURCES += lib/sqfs/dir_reader.c lib/sqfs/read_tree.c
-libsquashfs_la_SOURCES += lib/sqfs/inode.c lib/sqfs/blk_proc/fragtbl.c
-libsquashfs_la_SOURCES += lib/sqfs/blk_proc/process_block.c lib/sqfs/io.c
+libsquashfs_la_SOURCES += lib/sqfs/inode.c lib/sqfs/blk_proc/fragment.c
+libsquashfs_la_SOURCES += lib/sqfs/blk_proc/block.c lib/sqfs/io.c
libsquashfs_la_SOURCES += lib/sqfs/blk_proc/internal.h lib/sqfs/data_reader.c
-libsquashfs_la_SOURCES += lib/sqfs/blk_proc/deduplicate.c
libsquashfs_la_SOURCES += lib/sqfs/blk_proc/common.c
libsquashfs_la_CPPFLAGS = $(AM_CPPFLAGS)
libsquashfs_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS)
diff --git a/lib/sqfs/blk_proc/process_block.c b/lib/sqfs/blk_proc/block.c
index 2951406..69a7119 100644
--- a/lib/sqfs/blk_proc/process_block.c
+++ b/lib/sqfs/blk_proc/block.c
@@ -9,6 +9,47 @@
#include <string.h>
+static int store_block_location(sqfs_block_processor_t *proc, uint64_t offset,
+ uint32_t size, uint32_t chksum)
+{
+ size_t new_sz;
+ void *new;
+
+ if (proc->num_blocks == proc->max_blocks) {
+ new_sz = proc->max_blocks * 2;
+ new = realloc(proc->blocks, sizeof(proc->blocks[0]) * new_sz);
+
+ if (new == NULL)
+ return SQFS_ERROR_ALLOC;
+
+ proc->blocks = new;
+ proc->max_blocks = new_sz;
+ }
+
+ proc->blocks[proc->num_blocks].offset = offset;
+ proc->blocks[proc->num_blocks].hash = MK_BLK_HASH(chksum, size);
+ proc->num_blocks += 1;
+ return 0;
+}
+
+static size_t deduplicate_blocks(sqfs_block_processor_t *proc, size_t count)
+{
+ size_t i, j;
+
+ for (i = 0; i < proc->file_start; ++i) {
+ for (j = 0; j < count; ++j) {
+ if (proc->blocks[i + j].hash !=
+ proc->blocks[proc->file_start + j].hash)
+ break;
+ }
+
+ if (j == count)
+ break;
+ }
+
+ return i;
+}
+
static int allign_file(sqfs_block_processor_t *proc, sqfs_block_t *blk)
{
if (!(blk->flags & SQFS_BLK_ALLIGN))
diff --git a/lib/sqfs/blk_proc/deduplicate.c b/lib/sqfs/blk_proc/deduplicate.c
deleted file mode 100644
index 08a108e..0000000
--- a/lib/sqfs/blk_proc/deduplicate.c
+++ /dev/null
@@ -1,49 +0,0 @@
-/* SPDX-License-Identifier: LGPL-3.0-or-later */
-/*
- * deduplicate.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#define SQFS_BUILDING_DLL
-#include "internal.h"
-
-int store_block_location(sqfs_block_processor_t *proc, uint64_t offset,
- uint32_t size, uint32_t chksum)
-{
- size_t new_sz;
- void *new;
-
- if (proc->num_blocks == proc->max_blocks) {
- new_sz = proc->max_blocks * 2;
- new = realloc(proc->blocks, sizeof(proc->blocks[0]) * new_sz);
-
- if (new == NULL)
- return SQFS_ERROR_ALLOC;
-
- proc->blocks = new;
- proc->max_blocks = new_sz;
- }
-
- proc->blocks[proc->num_blocks].offset = offset;
- proc->blocks[proc->num_blocks].hash = MK_BLK_HASH(chksum, size);
- proc->num_blocks += 1;
- return 0;
-}
-
-size_t deduplicate_blocks(sqfs_block_processor_t *proc, size_t count)
-{
- size_t i, j;
-
- for (i = 0; i < proc->file_start; ++i) {
- for (j = 0; j < count; ++j) {
- if (proc->blocks[i + j].hash !=
- proc->blocks[proc->file_start + j].hash)
- break;
- }
-
- if (j == count)
- break;
- }
-
- return i;
-}
diff --git a/lib/sqfs/blk_proc/fragtbl.c b/lib/sqfs/blk_proc/fragment.c
index 39e8136..5fa2349 100644
--- a/lib/sqfs/blk_proc/fragtbl.c
+++ b/lib/sqfs/blk_proc/fragment.c
@@ -72,8 +72,8 @@ static int store_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag,
return 0;
}
-int handle_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag,
- sqfs_block_t **blk_out)
+int process_completed_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag,
+ sqfs_block_t **blk_out)
{
uint64_t hash;
size_t i, size;
diff --git a/lib/sqfs/blk_proc/internal.h b/lib/sqfs/blk_proc/internal.h
index b6a0342..1c403a9 100644
--- a/lib/sqfs/blk_proc/internal.h
+++ b/lib/sqfs/blk_proc/internal.h
@@ -111,15 +111,8 @@ SQFS_INTERNAL int process_completed_block(sqfs_block_processor_t *proc,
sqfs_block_t *block);
SQFS_INTERNAL
-int handle_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag,
- sqfs_block_t **blk_out);
-
-SQFS_INTERNAL size_t deduplicate_blocks(sqfs_block_processor_t *proc,
- size_t count);
-
-SQFS_INTERNAL int store_block_location(sqfs_block_processor_t *proc,
- uint64_t offset, uint32_t size,
- uint32_t chksum);
+int process_completed_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag,
+ sqfs_block_t **blk_out);
SQFS_INTERNAL void free_blk_list(sqfs_block_t *list);
diff --git a/lib/sqfs/blk_proc/pthread.c b/lib/sqfs/blk_proc/pthread.c
index 57b61c1..7b95c7c 100644
--- a/lib/sqfs/blk_proc/pthread.c
+++ b/lib/sqfs/blk_proc/pthread.c
@@ -226,7 +226,7 @@ static int process_done_queue(sqfs_block_processor_t *proc,
if (it->flags & SQFS_BLK_IS_FRAGMENT) {
block = NULL;
- status = handle_fragment(proc, it, &block);
+ status = process_completed_fragment(proc, it, &block);
if (block != NULL && status == 0) {
pthread_mutex_lock(&proc->mtx);
diff --git a/lib/sqfs/blk_proc/serial.c b/lib/sqfs/blk_proc/serial.c
index 67272a3..fcbf002 100644
--- a/lib/sqfs/blk_proc/serial.c
+++ b/lib/sqfs/blk_proc/serial.c
@@ -54,7 +54,8 @@ int sqfs_block_processor_enqueue(sqfs_block_processor_t *proc,
if (block->flags & SQFS_BLK_IS_FRAGMENT) {
block->checksum = crc32(0, block->data, block->size);
- proc->status = handle_fragment(proc, block, &fragblk);
+ proc->status = process_completed_fragment(proc, block,
+ &fragblk);
free(block);
if (proc->status != 0) {