aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-01-28 21:23:21 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-01-29 17:22:50 +0100
commit9d5b0c381a7961a14d2a94a6b31a4e25a2543eae (patch)
tree089a3cc96f54cd7b09762840d03e4dc2420c5ea9
parent60ff56b68ea0593782d7a2ef0ac4e667437418d2 (diff)
Rename sqfs_data_writer_t back to sqfs_block_processor_t
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--include/common.h15
-rw-r--r--include/sqfs/block.h18
-rw-r--r--include/sqfs/block_processor.h (renamed from include/sqfs/data_writer.h)96
-rw-r--r--include/sqfs/predef.h2
-rw-r--r--lib/common/data_writer.c8
-rw-r--r--lib/common/statistics.c15
-rw-r--r--lib/common/writer.c19
-rw-r--r--lib/sqfs/Makemodule.am19
-rw-r--r--lib/sqfs/block_processor/block.c (renamed from lib/sqfs/data_writer/block.c)12
-rw-r--r--lib/sqfs/block_processor/common.c (renamed from lib/sqfs/data_writer/common.c)16
-rw-r--r--lib/sqfs/block_processor/fileapi.c (renamed from lib/sqfs/data_writer/fileapi.c)18
-rw-r--r--lib/sqfs/block_processor/fragment.c (renamed from lib/sqfs/data_writer/fragment.c)2
-rw-r--r--lib/sqfs/block_processor/internal.h (renamed from lib/sqfs/data_writer/internal.h)27
-rw-r--r--lib/sqfs/block_processor/serial.c (renamed from lib/sqfs/data_writer/serial.c)34
-rw-r--r--lib/sqfs/block_processor/winpthread.c (renamed from lib/sqfs/data_writer/winpthread.c)68
-rw-r--r--mkfs/mkfs.c4
16 files changed, 190 insertions, 183 deletions
diff --git a/include/common.h b/include/common.h
index 386d8fd..f2431ab 100644
--- a/include/common.h
+++ b/include/common.h
@@ -18,7 +18,7 @@
#include "sqfs/error.h"
#include "sqfs/meta_writer.h"
#include "sqfs/data_reader.h"
-#include "sqfs/data_writer.h"
+#include "sqfs/block_processor.h"
#include "sqfs/dir_writer.h"
#include "sqfs/dir_reader.h"
#include "sqfs/block.h"
@@ -42,10 +42,10 @@ typedef struct {
size_t frag_dup;
sqfs_u64 bytes_written;
sqfs_u64 bytes_read;
-} data_writer_stats_t;
+} block_processor_stats_t;
typedef struct {
- sqfs_data_writer_t *data;
+ sqfs_block_processor_t *data;
sqfs_dir_writer_t *dirwr;
sqfs_meta_writer_t *dm;
sqfs_meta_writer_t *im;
@@ -54,7 +54,7 @@ typedef struct {
sqfs_file_t *outfile;
sqfs_super_t super;
fstree_t fs;
- data_writer_stats_t stats;
+ block_processor_stats_t stats;
sqfs_xattr_writer_t *xwr;
} sqfs_writer_t;
@@ -99,7 +99,7 @@ typedef struct sqfs_hard_link_t {
int sqfs_serialize_fstree(const char *filename, sqfs_writer_t *wr);
/* Print out fancy statistics for squashfs packing tools */
-void sqfs_print_statistics(sqfs_super_t *super, data_writer_stats_t *stats);
+void sqfs_print_statistics(sqfs_super_t *super, block_processor_stats_t *stats);
void compressor_print_available(void);
@@ -122,9 +122,10 @@ int sqfs_data_reader_dump(const char *name, sqfs_data_reader_t *data,
sqfs_file_t *sqfs_get_stdin_file(FILE *fp, const sparse_map_t *map,
sqfs_u64 size);
-void register_stat_hooks(sqfs_data_writer_t *data, data_writer_stats_t *stats);
+void register_stat_hooks(sqfs_block_processor_t *data,
+ block_processor_stats_t *stats);
-int write_data_from_file(const char *filename, sqfs_data_writer_t *data,
+int write_data_from_file(const char *filename, sqfs_block_processor_t *data,
sqfs_inode_generic_t *inode,
sqfs_file_t *file, int flags);
diff --git a/include/sqfs/block.h b/include/sqfs/block.h
index b37cdd5..1098c96 100644
--- a/include/sqfs/block.h
+++ b/include/sqfs/block.h
@@ -68,14 +68,14 @@ typedef enum {
* @brief Only calculate checksum, do NOT compress the data.
*
* If set, the blocks of a file will not be compressed by the
- * @ref sqfs_data_writer_t.
+ * @ref sqfs_block_processor_t.
*/
SQFS_BLK_DONT_COMPRESS = 0x0001,
/**
* @brief Align the block on disk to device block size.
*
- * If set, the @ref sqfs_data_writer_t will add padding before the
+ * If set, the @ref sqfs_block_processor_t will add padding before the
* first block of the affected file and after the last block.
*/
SQFS_BLK_ALIGN = 0x0002,
@@ -83,38 +83,38 @@ typedef enum {
/**
* @brief Don't add the tail end of a file to a fragment block.
*
- * If set, the @ref sqfs_data_writer_t will always generate a final
+ * If set, the @ref sqfs_block_processor_t will always generate a final
* block for a file, even if it is truncated. It will not add the
* tail end to a fragment block.
*/
SQFS_BLK_DONT_FRAGMENT = 0x0004,
/**
- * @brief Set by the @ref sqfs_data_writer_t on the first
+ * @brief Set by the @ref sqfs_block_processor_t on the first
* block of a file.
*/
SQFS_BLK_FIRST_BLOCK = 0x0800,
/**
- * @brief Set by the @ref sqfs_data_writer_t on the last
+ * @brief Set by the @ref sqfs_block_processor_t on the last
* block of a file.
*/
SQFS_BLK_LAST_BLOCK = 0x1000,
/**
- * @brief Set by the @ref sqfs_data_writer_t to indicate that a block
- * is a tail end of a file and the block.
+ * @brief Set by the @ref sqfs_block_processor_t to indicate that a
+ * block is a tail end of a file and the block.
*/
SQFS_BLK_IS_FRAGMENT = 0x2000,
/**
- * @brief Set by the @ref sqfs_data_writer_t on fragment blocks that
+ * @brief Set by the @ref sqfs_block_processor_t on fragment blocks that
* it generates.
*/
SQFS_BLK_FRAGMENT_BLOCK = 0x4000,
/**
- * @brief Set by @ref sqfs_data_writer_t if the block was
+ * @brief Set by @ref sqfs_block_processor_t if the block was
* actually compressed.
*/
SQFS_BLK_IS_COMPRESSED = 0x8000,
diff --git a/include/sqfs/data_writer.h b/include/sqfs/block_processor.h
index 7b6ee0f..c6dd734 100644
--- a/include/sqfs/data_writer.h
+++ b/include/sqfs/block_processor.h
@@ -1,6 +1,6 @@
/* SPDX-License-Identifier: LGPL-3.0-or-later */
/*
- * data_writer.h - This file is part of libsquashfs
+ * block_processor.h - This file is part of libsquashfs
*
* Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
*
@@ -17,25 +17,26 @@
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
-#ifndef SFQS_DATA_WRITER_H
-#define SFQS_DATA_WRITER_H
+#ifndef SFQS_BLOCK_PROCESSOR_H
+#define SFQS_BLOCK_PROCESSOR_H
#include "sqfs/predef.h"
/**
- * @file data_writer.h
+ * @file block_processor.h
*
* @brief Contains declarations for the data block processor.
*/
/**
- * @struct sqfs_data_writer_t
+ * @struct sqfs_block_processor_t
*
* @brief Abstracts generating of file data and fragment blocks.
*
* This data structure provides a simple begin/append/end interface
- * to generate file data blocks (see @ref sqfs_data_writer_begin_file,
- * @ref sqfs_data_writer_append and @ref sqfs_data_writer_end respectively).
+ * to generate file data blocks (see @ref sqfs_block_processor_begin_file,
+ * @ref sqfs_block_processor_append and @ref sqfs_block_processor_end
+ * respectively).
*
* Internally it takes care of partitioning data in the correct block sizes,
* adding tail-ens to fragment blocks, compressing the data, deduplicating data
@@ -47,7 +48,7 @@
*
* @brief A set of hooks for tapping into the data writer.
*
- * This structure can be registered with an @ref sqfs_data_writer_t and
+ * This structure can be registered with an @ref sqfs_block_processor_t and
* contains function pointers that will be called during various stages
* when writing data to disk.
*
@@ -63,9 +64,9 @@ struct sqfs_block_hooks_t {
*
* This is required for future expandabillity while maintaining ABI
* compatibillity. At the current time, the implementation of
- * @ref sqfs_data_writer_set_hooks rejects any hook struct where this
- * isn't the exact size. If new hooks are added in the future, the
- * struct grows and the future implementation can tell by the size
+ * @ref sqfs_block_processor_set_hooks rejects any hook struct where
+ * this isn't the exact size. If new hooks are added in the future,
+ * the struct grows and the future implementation can tell by the size
* whether the application uses the new version or the old one.
*/
size_t size;
@@ -155,7 +156,7 @@ extern "C" {
/**
* @brief Create a data block writer.
*
- * @memberof sqfs_data_writer_t
+ * @memberof sqfs_block_processor_t
*
* @param max_block_size The maximum size of a data block. Required for the
* internal scratch buffer used for compressing data.
@@ -174,39 +175,40 @@ extern "C" {
* failure or on failure to create and initialize the worker threads.
*/
SQFS_API
-sqfs_data_writer_t *sqfs_data_writer_create(size_t max_block_size,
- sqfs_compressor_t *cmp,
- unsigned int num_workers,
- size_t max_backlog,
- size_t devblksz,
- sqfs_file_t *file);
+sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
+ sqfs_compressor_t *cmp,
+ unsigned int num_workers,
+ size_t max_backlog,
+ size_t devblksz,
+ sqfs_file_t *file);
/**
* @brief Destroy a data writer and free all memory used by it.
*
- * @memberof sqfs_data_writer_t
+ * @memberof sqfs_block_processor_t
*
* @param proc A pointer to a data writer object.
*/
-SQFS_API void sqfs_data_writer_destroy(sqfs_data_writer_t *proc);
+SQFS_API void sqfs_block_processor_destroy(sqfs_block_processor_t *proc);
/**
* @brief Start writing a file.
*
- * @memberof sqfs_data_writer_t
+ * @memberof sqfs_block_processor_t
*
- * After calling this function, call @ref sqfs_data_writer_append repeatedly to
- * add data to the file. Finally call @ref sqfs_data_writer_end_file when you
- * are done. After writing all files, use @ref sqfs_data_writer_finish to wait
- * until all blocks that are still in flight are done and written to disk.
+ * After calling this function, call @ref sqfs_block_processor_append
+ * repeatedly to add data to the file. Finally
+ * call @ref sqfs_block_processor_end_file when you
+ * are done. After writing all files, use @ref sqfs_block_processor_finish to
+ * wait until all blocks that are still in flight are done and written to disk.
*
* The specified inode pointer is kept internally and updated with the
* compressed block sizes and final destinations of the file and possible
* fragment. You need to make sure it has enough backing-store for all blocks
* to come. Furthermore, since there can still be blocks in-flight even after
- * calling @ref sqfs_data_writer_end_file, the data in the inode may still
+ * calling @ref sqfs_block_processor_end_file, the data in the inode may still
* change. The only point at which the data writer is guarnteed to not touch
- * them anymore is after @ref sqfs_data_writer_finish has returned.
+ * them anymore is after @ref sqfs_block_processor_finish has returned.
*
* @param proc A pointer to a data writer object.
* @param inode The regular file inode representing the file. The data writer
@@ -216,16 +218,16 @@ SQFS_API void sqfs_data_writer_destroy(sqfs_data_writer_t *proc);
*
* @return Zero on success, an @ref E_SQFS_ERROR value on failure.
*/
-SQFS_API int sqfs_data_writer_begin_file(sqfs_data_writer_t *proc,
- sqfs_inode_generic_t *inode,
- sqfs_u32 flags);
+SQFS_API int sqfs_block_processor_begin_file(sqfs_block_processor_t *proc,
+ sqfs_inode_generic_t *inode,
+ sqfs_u32 flags);
/**
* @brief Append data to the current file.
*
- * @memberof sqfs_data_writer_t
+ * @memberof sqfs_block_processor_t
*
- * Call this after @ref sqfs_data_writer_begin_file to add data to a file.
+ * Call this after @ref sqfs_block_processor_begin_file to add data to a file.
*
* @param proc A pointer to a data writer object.
* @param data A pointer to a buffer to read data from.
@@ -234,32 +236,32 @@ SQFS_API int sqfs_data_writer_begin_file(sqfs_data_writer_t *proc,
*
* @return Zero on success, an @ref E_SQFS_ERROR value on failure.
*/
-SQFS_API int sqfs_data_writer_append(sqfs_data_writer_t *proc,
- const void *data, size_t size);
+SQFS_API int sqfs_block_processor_append(sqfs_block_processor_t *proc,
+ const void *data, size_t size);
/**
* @brief Stop writing the current file and flush everything that is
* buffered internally.
*
- * @memberof sqfs_data_writer_t
+ * @memberof sqfs_block_processor_t
*
- * The counter part to @ref sqfs_data_writer_begin_file.
+ * The counter part to @ref sqfs_block_processor_begin_file.
*
* Even after calling this, there might still be data blocks in-flight.
- * Use @ref sqfs_data_writer_finish when you are done writing files to force
+ * Use @ref sqfs_block_processor_finish when you are done writing files to force
* the remaining blocks to be processed and written to disk.
*
* @param proc A pointer to a data writer object.
*
* @return Zero on success, an @ref E_SQFS_ERROR value on failure.
*/
-SQFS_API int sqfs_data_writer_end_file(sqfs_data_writer_t *proc);
+SQFS_API int sqfs_block_processor_end_file(sqfs_block_processor_t *proc);
/**
* @brief Wait for the in-flight data blocks to finish and finally flush the
* current fragment block.
*
- * @memberof sqfs_data_writer_t
+ * @memberof sqfs_block_processor_t
*
* @param proc A pointer to a block processor object.
*
@@ -267,12 +269,12 @@ SQFS_API int sqfs_data_writer_end_file(sqfs_data_writer_t *proc);
* return value can either be an error encountered during enqueueing,
* processing or writing to disk.
*/
-SQFS_API int sqfs_data_writer_finish(sqfs_data_writer_t *proc);
+SQFS_API int sqfs_block_processor_finish(sqfs_block_processor_t *proc);
/**
* @brief Write the completed fragment table to disk.
*
- * @memberof sqfs_data_writer_t
+ * @memberof sqfs_block_processor_t
*
* Call this after producing the inode and directory table to generate
* the fragment table for the squashfs image.
@@ -284,13 +286,13 @@ SQFS_API int sqfs_data_writer_finish(sqfs_data_writer_t *proc);
* @return Zero on success, an @ref E_SQFS_ERROR value on failure.
*/
SQFS_API
-int sqfs_data_writer_write_fragment_table(sqfs_data_writer_t *proc,
- sqfs_super_t *super);
+int sqfs_block_processor_write_fragment_table(sqfs_block_processor_t *proc,
+ sqfs_super_t *super);
/**
* @brief Register a set of hooks to be invoked when writing blocks to disk.
*
- * @memberof sqfs_data_writer_t
+ * @memberof sqfs_block_processor_t
*
* @param proc A pointer to a data writer object.
* @param user_ptr A user pointer to pass to the callbacks.
@@ -300,11 +302,11 @@ int sqfs_data_writer_write_fragment_table(sqfs_data_writer_t *proc,
* the hooks doesn't match any size knwon to the library.
*/
SQFS_API
-int sqfs_data_writer_set_hooks(sqfs_data_writer_t *proc, void *user_ptr,
- const sqfs_block_hooks_t *hooks);
+int sqfs_block_processor_set_hooks(sqfs_block_processor_t *proc, void *user_ptr,
+ const sqfs_block_hooks_t *hooks);
#ifdef __cplusplus
}
#endif
-#endif /* SFQS_DATA_WRITER_H */
+#endif /* SFQS_BLOCK_PROCESSOR_H */
diff --git a/include/sqfs/predef.h b/include/sqfs/predef.h
index 234b015..924aecc 100644
--- a/include/sqfs/predef.h
+++ b/include/sqfs/predef.h
@@ -68,7 +68,7 @@ typedef int32_t sqfs_s32;
typedef int64_t sqfs_s64;
typedef struct sqfs_block_t sqfs_block_t;
-typedef struct sqfs_data_writer_t sqfs_data_writer_t;
+typedef struct sqfs_block_processor_t sqfs_block_processor_t;
typedef struct sqfs_compressor_config_t sqfs_compressor_config_t;
typedef struct sqfs_compressor_t sqfs_compressor_t;
typedef struct sqfs_dir_writer_t sqfs_dir_writer_t;
diff --git a/lib/common/data_writer.c b/lib/common/data_writer.c
index c5beba8..8ebd868 100644
--- a/lib/common/data_writer.c
+++ b/lib/common/data_writer.c
@@ -8,7 +8,7 @@
static sqfs_u8 buffer[4096];
-int write_data_from_file(const char *filename, sqfs_data_writer_t *data,
+int write_data_from_file(const char *filename, sqfs_block_processor_t *data,
sqfs_inode_generic_t *inode, sqfs_file_t *file,
int flags)
{
@@ -16,7 +16,7 @@ int write_data_from_file(const char *filename, sqfs_data_writer_t *data,
size_t diff;
int ret;
- ret = sqfs_data_writer_begin_file(data, inode, flags);
+ ret = sqfs_block_processor_begin_file(data, inode, flags);
if (ret) {
sqfs_perror(filename, "beginning file data blocks", ret);
return -1;
@@ -37,14 +37,14 @@ int write_data_from_file(const char *filename, sqfs_data_writer_t *data,
return -1;
}
- ret = sqfs_data_writer_append(data, buffer, diff);
+ ret = sqfs_block_processor_append(data, buffer, diff);
if (ret) {
sqfs_perror(filename, "packing file data", ret);
return -1;
}
}
- ret = sqfs_data_writer_end_file(data);
+ ret = sqfs_block_processor_end_file(data);
if (ret) {
sqfs_perror(filename, "finishing file data", ret);
return -1;
diff --git a/lib/common/statistics.c b/lib/common/statistics.c
index 7bf8fca..b41cd22 100644
--- a/lib/common/statistics.c
+++ b/lib/common/statistics.c
@@ -11,7 +11,7 @@
static void post_block_write(void *user, const sqfs_block_t *block,
sqfs_file_t *file)
{
- data_writer_stats_t *stats = user;
+ block_processor_stats_t *stats = user;
(void)file;
if (block->size == 0)
@@ -28,7 +28,7 @@ static void post_block_write(void *user, const sqfs_block_t *block,
static void pre_fragment_store(void *user, sqfs_block_t *block)
{
- data_writer_stats_t *stats = user;
+ block_processor_stats_t *stats = user;
(void)block;
stats->frag_count += 1;
@@ -36,7 +36,7 @@ static void pre_fragment_store(void *user, sqfs_block_t *block)
static void notify_blocks_erased(void *user, size_t count, sqfs_u64 bytes)
{
- data_writer_stats_t *stats = user;
+ block_processor_stats_t *stats = user;
stats->bytes_written -= bytes;
stats->blocks_written -= count;
@@ -45,7 +45,7 @@ static void notify_blocks_erased(void *user, size_t count, sqfs_u64 bytes)
static void notify_fragment_discard(void *user, const sqfs_block_t *block)
{
- data_writer_stats_t *stats = user;
+ block_processor_stats_t *stats = user;
(void)block;
stats->frag_dup += 1;
@@ -59,12 +59,13 @@ static const sqfs_block_hooks_t hooks = {
.notify_fragment_discard = notify_fragment_discard,
};
-void register_stat_hooks(sqfs_data_writer_t *data, data_writer_stats_t *stats)
+void register_stat_hooks(sqfs_block_processor_t *data,
+ block_processor_stats_t *stats)
{
- sqfs_data_writer_set_hooks(data, stats, &hooks);
+ sqfs_block_processor_set_hooks(data, stats, &hooks);
}
-void sqfs_print_statistics(sqfs_super_t *super, data_writer_stats_t *stats)
+void sqfs_print_statistics(sqfs_super_t *super, block_processor_stats_t *stats)
{
size_t ratio;
diff --git a/lib/common/writer.c b/lib/common/writer.c
index b6adc59..ed3ebbd 100644
--- a/lib/common/writer.c
+++ b/lib/common/writer.c
@@ -123,11 +123,11 @@ int sqfs_writer_init(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *wrcfg)
if (ret > 0)
sqfs->super.flags |= SQFS_FLAG_COMPRESSOR_OPTIONS;
- sqfs->data = sqfs_data_writer_create(sqfs->super.block_size,
- sqfs->cmp, wrcfg->num_jobs,
- wrcfg->max_backlog,
- wrcfg->devblksize,
- sqfs->outfile);
+ sqfs->data = sqfs_block_processor_create(sqfs->super.block_size,
+ sqfs->cmp, wrcfg->num_jobs,
+ wrcfg->max_backlog,
+ wrcfg->devblksize,
+ sqfs->outfile);
if (sqfs->data == NULL) {
perror("creating data block processor");
goto fail_cmp;
@@ -187,7 +187,7 @@ fail_xwr:
fail_id:
sqfs_id_table_destroy(sqfs->idtbl);
fail_data:
- sqfs_data_writer_destroy(sqfs->data);
+ sqfs_block_processor_destroy(sqfs->data);
fail_cmp:
sqfs->cmp->destroy(sqfs->cmp);
fail_fs:
@@ -204,7 +204,7 @@ int sqfs_writer_finish(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *cfg)
if (!cfg->quiet)
fputs("Waiting for remaining data blocks...\n", stdout);
- ret = sqfs_data_writer_finish(sqfs->data);
+ ret = sqfs_block_processor_finish(sqfs->data);
if (ret) {
sqfs_perror(cfg->filename, "finishing data blocks", ret);
return -1;
@@ -221,7 +221,8 @@ int sqfs_writer_finish(sqfs_writer_t *sqfs, const sqfs_writer_cfg_t *cfg)
if (!cfg->quiet)
fputs("Writing fragment table...\n", stdout);
- ret = sqfs_data_writer_write_fragment_table(sqfs->data, &sqfs->super);
+ ret = sqfs_block_processor_write_fragment_table(sqfs->data,
+ &sqfs->super);
if (ret) {
sqfs_perror(cfg->filename, "writing fragment table", ret);
return -1;
@@ -291,7 +292,7 @@ void sqfs_writer_cleanup(sqfs_writer_t *sqfs)
sqfs_meta_writer_destroy(sqfs->dm);
sqfs_meta_writer_destroy(sqfs->im);
sqfs_id_table_destroy(sqfs->idtbl);
- sqfs_data_writer_destroy(sqfs->data);
+ sqfs_block_processor_destroy(sqfs->data);
sqfs->cmp->destroy(sqfs->cmp);
fstree_cleanup(&sqfs->fs);
sqfs->outfile->destroy(sqfs->outfile);
diff --git a/lib/sqfs/Makemodule.am b/lib/sqfs/Makemodule.am
index 47b9ad7..cde947d 100644
--- a/lib/sqfs/Makemodule.am
+++ b/lib/sqfs/Makemodule.am
@@ -1,6 +1,6 @@
LIBSQFS_HEARDS = include/sqfs/meta_writer.h \
include/sqfs/meta_reader.h include/sqfs/id_table.h \
- include/sqfs/compressor.h include/sqfs/data_writer.h \
+ include/sqfs/compressor.h include/sqfs/block_processor.h \
include/sqfs/super.h include/sqfs/inode.h \
include/sqfs/dir.h include/sqfs/xattr.h \
include/sqfs/table.h include/sqfs/predef.h \
@@ -19,11 +19,12 @@ 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/comp/internal.h lib/sqfs/xattr_writer.c
libsquashfs_la_SOURCES += lib/sqfs/dir_reader.c lib/sqfs/read_tree.c
-libsquashfs_la_SOURCES += lib/sqfs/inode.c lib/sqfs/data_writer/fragment.c
-libsquashfs_la_SOURCES += lib/sqfs/write_super.c lib/sqfs/data_writer/block.c
-libsquashfs_la_SOURCES += lib/sqfs/data_writer/internal.h lib/sqfs/data_reader.c
-libsquashfs_la_SOURCES += lib/sqfs/data_writer/common.c
-libsquashfs_la_SOURCES += lib/sqfs/data_writer/fileapi.c
+libsquashfs_la_SOURCES += lib/sqfs/inode.c lib/sqfs/block_processor/fragment.c
+libsquashfs_la_SOURCES += lib/sqfs/write_super.c lib/sqfs/data_reader.c
+libsquashfs_la_SOURCES += lib/sqfs/block_processor/block.c
+libsquashfs_la_SOURCES += lib/sqfs/block_processor/internal.h
+libsquashfs_la_SOURCES += lib/sqfs/block_processor/common.c
+libsquashfs_la_SOURCES += lib/sqfs/block_processor/fileapi.c
libsquashfs_la_SOURCES += lib/sqfs/str_table.c lib/sqfs/str_table.h
libsquashfs_la_SOURCES += lib/sqfs/alloc.c lib/sqfs/util.h
libsquashfs_la_SOURCES += lib/sqfs/frag_table.c include/sqfs/frag_table.h
@@ -45,13 +46,13 @@ libsquashfs_la_SOURCES += lib/sqfs/unix/io_file.c
endif
if HAVE_PTHREAD
-libsquashfs_la_SOURCES += lib/sqfs/data_writer/winpthread.c
+libsquashfs_la_SOURCES += lib/sqfs/block_processor/winpthread.c
libsquashfs_la_CPPFLAGS += -DWITH_PTHREAD
else
if WINDOWS
-libsquashfs_la_SOURCES += lib/sqfs/data_writer/winpthread.c
+libsquashfs_la_SOURCES += lib/sqfs/block_processor/winpthread.c
else
-libsquashfs_la_SOURCES += lib/sqfs/data_writer/serial.c
+libsquashfs_la_SOURCES += lib/sqfs/block_processor/serial.c
endif
endif
diff --git a/lib/sqfs/data_writer/block.c b/lib/sqfs/block_processor/block.c
index b45b1ff..49892be 100644
--- a/lib/sqfs/data_writer/block.c
+++ b/lib/sqfs/block_processor/block.c
@@ -9,7 +9,7 @@
#include <string.h>
-static int store_block_location(sqfs_data_writer_t *proc, sqfs_u64 offset,
+static int store_block_location(sqfs_block_processor_t *proc, sqfs_u64 offset,
sqfs_u32 size, sqfs_u32 chksum)
{
size_t new_sz;
@@ -32,7 +32,7 @@ static int store_block_location(sqfs_data_writer_t *proc, sqfs_u64 offset,
return 0;
}
-static size_t deduplicate_blocks(sqfs_data_writer_t *proc, size_t count)
+static size_t deduplicate_blocks(sqfs_block_processor_t *proc, size_t count)
{
size_t i, j;
@@ -50,7 +50,7 @@ static size_t deduplicate_blocks(sqfs_data_writer_t *proc, size_t count)
return i;
}
-static int align_file(sqfs_data_writer_t *proc, sqfs_block_t *blk)
+static int align_file(sqfs_block_processor_t *proc, sqfs_block_t *blk)
{
sqfs_u32 chksum;
void *padding;
@@ -83,7 +83,7 @@ static int align_file(sqfs_data_writer_t *proc, sqfs_block_t *blk)
return store_block_location(proc, size, diff | (1 << 24), chksum);
}
-int process_completed_block(sqfs_data_writer_t *proc, sqfs_block_t *blk)
+int process_completed_block(sqfs_block_processor_t *proc, sqfs_block_t *blk)
{
sqfs_u64 offset, bytes;
size_t start, count;
@@ -171,8 +171,8 @@ int process_completed_block(sqfs_data_writer_t *proc, sqfs_block_t *blk)
return 0;
}
-int data_writer_do_block(sqfs_block_t *block, sqfs_compressor_t *cmp,
- sqfs_u8 *scratch, size_t scratch_size)
+int block_processor_do_block(sqfs_block_t *block, sqfs_compressor_t *cmp,
+ sqfs_u8 *scratch, size_t scratch_size)
{
ssize_t ret;
diff --git a/lib/sqfs/data_writer/common.c b/lib/sqfs/block_processor/common.c
index b207291..c6375dd 100644
--- a/lib/sqfs/data_writer/common.c
+++ b/lib/sqfs/block_processor/common.c
@@ -18,9 +18,9 @@ void free_blk_list(sqfs_block_t *list)
}
}
-int data_writer_init(sqfs_data_writer_t *proc, size_t max_block_size,
- sqfs_compressor_t *cmp, unsigned int num_workers,
- size_t max_backlog, size_t devblksz, sqfs_file_t *file)
+int block_processor_init(sqfs_block_processor_t *proc, size_t max_block_size,
+ sqfs_compressor_t *cmp, unsigned int num_workers,
+ size_t max_backlog, size_t devblksz, sqfs_file_t *file)
{
proc->max_block_size = max_block_size;
proc->num_workers = num_workers;
@@ -41,7 +41,7 @@ int data_writer_init(sqfs_data_writer_t *proc, size_t max_block_size,
return 0;
}
-void data_writer_cleanup(sqfs_data_writer_t *proc)
+void block_processor_cleanup(sqfs_block_processor_t *proc)
{
if (proc->frag_tbl != NULL)
sqfs_frag_table_destroy(proc->frag_tbl);
@@ -53,15 +53,15 @@ void data_writer_cleanup(sqfs_data_writer_t *proc)
free(proc);
}
-int sqfs_data_writer_write_fragment_table(sqfs_data_writer_t *proc,
- sqfs_super_t *super)
+int sqfs_block_processor_write_fragment_table(sqfs_block_processor_t *proc,
+ sqfs_super_t *super)
{
return sqfs_frag_table_write(proc->frag_tbl, proc->file,
super, proc->cmp);
}
-int sqfs_data_writer_set_hooks(sqfs_data_writer_t *proc, void *user_ptr,
- const sqfs_block_hooks_t *hooks)
+int sqfs_block_processor_set_hooks(sqfs_block_processor_t *proc, void *user_ptr,
+ const sqfs_block_hooks_t *hooks)
{
if (hooks->size != sizeof(*hooks))
return SQFS_ERROR_UNSUPPORTED;
diff --git a/lib/sqfs/data_writer/fileapi.c b/lib/sqfs/block_processor/fileapi.c
index 89bac0b..9e59c1d 100644
--- a/lib/sqfs/data_writer/fileapi.c
+++ b/lib/sqfs/block_processor/fileapi.c
@@ -12,7 +12,7 @@ static bool is_zero_block(unsigned char *ptr, size_t size)
return ptr[0] == 0 && memcmp(ptr, ptr + 1, size - 1) == 0;
}
-static int enqueue_block(sqfs_data_writer_t *proc, sqfs_block_t *block)
+static int enqueue_block(sqfs_block_processor_t *proc, sqfs_block_t *block)
{
int status;
@@ -28,7 +28,7 @@ static int enqueue_block(sqfs_data_writer_t *proc, sqfs_block_t *block)
return append_to_work_queue(proc, block, proc->notify_threads);
}
-static int add_sentinel_block(sqfs_data_writer_t *proc)
+static int add_sentinel_block(sqfs_block_processor_t *proc)
{
sqfs_block_t *blk = calloc(1, sizeof(*blk));
@@ -41,8 +41,8 @@ static int add_sentinel_block(sqfs_data_writer_t *proc)
return enqueue_block(proc, blk);
}
-int sqfs_data_writer_begin_file(sqfs_data_writer_t *proc,
- sqfs_inode_generic_t *inode, sqfs_u32 flags)
+int sqfs_block_processor_begin_file(sqfs_block_processor_t *proc,
+ sqfs_inode_generic_t *inode, sqfs_u32 flags)
{
if (proc->inode != NULL)
return test_and_set_status(proc, SQFS_ERROR_INTERNAL);
@@ -57,7 +57,7 @@ int sqfs_data_writer_begin_file(sqfs_data_writer_t *proc,
return 0;
}
-static int flush_block(sqfs_data_writer_t *proc, sqfs_block_t *block)
+static int flush_block(sqfs_block_processor_t *proc, sqfs_block_t *block)
{
block->index = proc->blk_index++;
block->flags = proc->blk_flags;
@@ -83,8 +83,8 @@ static int flush_block(sqfs_data_writer_t *proc, sqfs_block_t *block)
return enqueue_block(proc, block);
}
-int sqfs_data_writer_append(sqfs_data_writer_t *proc, const void *data,
- size_t size)
+int sqfs_block_processor_append(sqfs_block_processor_t *proc, const void *data,
+ size_t size)
{
size_t diff;
void *new;
@@ -133,7 +133,7 @@ int sqfs_data_writer_append(sqfs_data_writer_t *proc, const void *data,
return 0;
}
-int sqfs_data_writer_end_file(sqfs_data_writer_t *proc)
+int sqfs_block_processor_end_file(sqfs_block_processor_t *proc)
{
int err;
@@ -162,7 +162,7 @@ int sqfs_data_writer_end_file(sqfs_data_writer_t *proc)
return 0;
}
-int sqfs_data_writer_finish(sqfs_data_writer_t *proc)
+int sqfs_block_processor_finish(sqfs_block_processor_t *proc)
{
int status = 0;
diff --git a/lib/sqfs/data_writer/fragment.c b/lib/sqfs/block_processor/fragment.c
index 9862c89..3701b3c 100644
--- a/lib/sqfs/data_writer/fragment.c
+++ b/lib/sqfs/block_processor/fragment.c
@@ -7,7 +7,7 @@
#define SQFS_BUILDING_DLL
#include "internal.h"
-int process_completed_fragment(sqfs_data_writer_t *proc, sqfs_block_t *frag,
+int process_completed_fragment(sqfs_block_processor_t *proc, sqfs_block_t *frag,
sqfs_block_t **blk_out)
{
sqfs_u32 index, offset;
diff --git a/lib/sqfs/data_writer/internal.h b/lib/sqfs/block_processor/internal.h
index 8f59fb7..40871b9 100644
--- a/lib/sqfs/data_writer/internal.h
+++ b/lib/sqfs/block_processor/internal.h
@@ -9,7 +9,7 @@
#include "config.h"
-#include "sqfs/data_writer.h"
+#include "sqfs/block_processor.h"
#include "sqfs/frag_table.h"
#include "sqfs/compressor.h"
#include "sqfs/inode.h"
@@ -46,7 +46,7 @@ typedef struct {
typedef struct compress_worker_t compress_worker_t;
-struct sqfs_data_writer_t {
+struct sqfs_block_processor_t {
/* synchronization primitives */
#ifdef WITH_PTHREAD
pthread_mutex_t mtx;
@@ -108,33 +108,34 @@ struct sqfs_data_writer_t {
#endif
};
-SQFS_INTERNAL int process_completed_block(sqfs_data_writer_t *proc,
+SQFS_INTERNAL int process_completed_block(sqfs_block_processor_t *proc,
sqfs_block_t *block);
SQFS_INTERNAL
-int process_completed_fragment(sqfs_data_writer_t *proc, sqfs_block_t *frag,
+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);
SQFS_INTERNAL
-int data_writer_init(sqfs_data_writer_t *proc, size_t max_block_size,
- sqfs_compressor_t *cmp, unsigned int num_workers,
- size_t max_backlog, size_t devblksz, sqfs_file_t *file);
+int block_processor_init(sqfs_block_processor_t *proc, size_t max_block_size,
+ sqfs_compressor_t *cmp, unsigned int num_workers,
+ size_t max_backlog, size_t devblksz,
+ sqfs_file_t *file);
-SQFS_INTERNAL void data_writer_cleanup(sqfs_data_writer_t *proc);
+SQFS_INTERNAL void block_processor_cleanup(sqfs_block_processor_t *proc);
SQFS_INTERNAL
-int data_writer_do_block(sqfs_block_t *block, sqfs_compressor_t *cmp,
- sqfs_u8 *scratch, size_t scratch_size);
+int block_processor_do_block(sqfs_block_t *block, sqfs_compressor_t *cmp,
+ sqfs_u8 *scratch, size_t scratch_size);
SQFS_INTERNAL
-int test_and_set_status(sqfs_data_writer_t *proc, int status);
+int test_and_set_status(sqfs_block_processor_t *proc, int status);
SQFS_INTERNAL
-int append_to_work_queue(sqfs_data_writer_t *proc, sqfs_block_t *block,
+int append_to_work_queue(sqfs_block_processor_t *proc, sqfs_block_t *block,
bool notify_threads);
-SQFS_INTERNAL int wait_completed(sqfs_data_writer_t *proc);
+SQFS_INTERNAL int wait_completed(sqfs_block_processor_t *proc);
#endif /* INTERNAL_H */
diff --git a/lib/sqfs/data_writer/serial.c b/lib/sqfs/block_processor/serial.c
index 82f7836..eedb19c 100644
--- a/lib/sqfs/data_writer/serial.c
+++ b/lib/sqfs/block_processor/serial.c
@@ -7,35 +7,35 @@
#define SQFS_BUILDING_DLL
#include "internal.h"
-sqfs_data_writer_t *sqfs_data_writer_create(size_t max_block_size,
- sqfs_compressor_t *cmp,
- unsigned int num_workers,
- size_t max_backlog,
- size_t devblksz,
- sqfs_file_t *file)
+sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
+ sqfs_compressor_t *cmp,
+ unsigned int num_workers,
+ size_t max_backlog,
+ size_t devblksz,
+ sqfs_file_t *file)
{
- sqfs_data_writer_t *proc;
+ sqfs_block_processor_t *proc;
proc = alloc_flex(sizeof(*proc), 1, max_block_size);
if (proc == NULL)
return NULL;
- if (data_writer_init(proc, max_block_size, cmp, num_workers,
- max_backlog, devblksz, file)) {
- data_writer_cleanup(proc);
+ if (block_processor_init(proc, max_block_size, cmp, num_workers,
+ max_backlog, devblksz, file)) {
+ block_processor_cleanup(proc);
return NULL;
}
return proc;
}
-void sqfs_data_writer_destroy(sqfs_data_writer_t *proc)
+void sqfs_block_processor_destroy(sqfs_block_processor_t *proc)
{
- data_writer_cleanup(proc);
+ block_processor_cleanup(proc);
}
-int test_and_set_status(sqfs_data_writer_t *proc, int status)
+int test_and_set_status(sqfs_block_processor_t *proc, int status)
{
if (proc->status == 0)
proc->status = status;
@@ -43,7 +43,7 @@ int test_and_set_status(sqfs_data_writer_t *proc, int status)
return proc->status;
}
-int append_to_work_queue(sqfs_data_writer_t *proc, sqfs_block_t *block,
+int append_to_work_queue(sqfs_block_processor_t *proc, sqfs_block_t *block,
bool signal_threads)
{
sqfs_block_t *fragblk = NULL;
@@ -72,8 +72,8 @@ int append_to_work_queue(sqfs_data_writer_t *proc, sqfs_block_t *block,
block = fragblk;
}
- proc->status = data_writer_do_block(block, proc->cmp, proc->scratch,
- proc->max_block_size);
+ proc->status = block_processor_do_block(block, proc->cmp, proc->scratch,
+ proc->max_block_size);
if (proc->status == 0)
proc->status = process_completed_block(proc, block);
@@ -82,7 +82,7 @@ int append_to_work_queue(sqfs_data_writer_t *proc, sqfs_block_t *block,
return proc->status;
}
-int wait_completed(sqfs_data_writer_t *proc)
+int wait_completed(sqfs_block_processor_t *proc)
{
return proc->status;
}
diff --git a/lib/sqfs/data_writer/winpthread.c b/lib/sqfs/block_processor/winpthread.c
index e575859..b16a17c 100644
--- a/lib/sqfs/data_writer/winpthread.c
+++ b/lib/sqfs/block_processor/winpthread.c
@@ -28,7 +28,7 @@
#endif
struct compress_worker_t {
- sqfs_data_writer_t *shared;
+ sqfs_block_processor_t *shared;
sqfs_compressor_t *cmp;
THREAD_HANDLE thread;
sqfs_u8 scratch[];
@@ -37,7 +37,7 @@ struct compress_worker_t {
static THREAD_TYPE worker_proc(THREAD_ARG arg)
{
compress_worker_t *worker = arg;
- sqfs_data_writer_t *shared = worker->shared;
+ sqfs_block_processor_t *shared = worker->shared;
sqfs_block_t *it, *prev, *blk = NULL;
int status = 0;
@@ -85,23 +85,23 @@ static THREAD_TYPE worker_proc(THREAD_ARG arg)
if (blk == NULL)
break;
- status = data_writer_do_block(blk, worker->cmp,
- worker->scratch,
- shared->max_block_size);
+ status = block_processor_do_block(blk, worker->cmp,
+ worker->scratch,
+ shared->max_block_size);
}
return THREAD_EXIT_SUCCESS;
}
#if defined(_WIN32) || defined(__WINDOWS__)
-sqfs_data_writer_t *sqfs_data_writer_create(size_t max_block_size,
- sqfs_compressor_t *cmp,
- unsigned int num_workers,
- size_t max_backlog,
- size_t devblksz,
- sqfs_file_t *file)
+sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
+ sqfs_compressor_t *cmp,
+ unsigned int num_workers,
+ size_t max_backlog,
+ size_t devblksz,
+ sqfs_file_t *file)
{
- sqfs_data_writer_t *proc;
+ sqfs_block_processor_t *proc;
unsigned int i;
if (num_workers < 1)
@@ -116,8 +116,8 @@ sqfs_data_writer_t *sqfs_data_writer_create(size_t max_block_size,
InitializeConditionVariable(&proc->queue_cond);
InitializeConditionVariable(&proc->done_cond);
- if (data_writer_init(proc, max_block_size, cmp, num_workers,
- max_backlog, devblksz, file)) {
+ if (block_processor_init(proc, max_block_size, cmp, num_workers,
+ max_backlog, devblksz, file)) {
goto fail;
}
@@ -142,11 +142,11 @@ sqfs_data_writer_t *sqfs_data_writer_create(size_t max_block_size,
return proc;
fail:
- sqfs_data_writer_destroy(proc);
+ sqfs_block_processor_destroy(proc);
return NULL;
}
-void sqfs_data_writer_destroy(sqfs_data_writer_t *proc)
+void sqfs_block_processor_destroy(sqfs_block_processor_t *proc)
{
unsigned int i;
@@ -171,17 +171,17 @@ void sqfs_data_writer_destroy(sqfs_data_writer_t *proc)
}
DeleteCriticalSection(&proc->mtx);
- data_writer_cleanup(proc);
+ block_processor_cleanup(proc);
}
#else
-sqfs_data_writer_t *sqfs_data_writer_create(size_t max_block_size,
- sqfs_compressor_t *cmp,
- unsigned int num_workers,
- size_t max_backlog,
- size_t devblksz,
- sqfs_file_t *file)
+sqfs_block_processor_t *sqfs_block_processor_create(size_t max_block_size,
+ sqfs_compressor_t *cmp,
+ unsigned int num_workers,
+ size_t max_backlog,
+ size_t devblksz,
+ sqfs_file_t *file)
{
- sqfs_data_writer_t *proc;
+ sqfs_block_processor_t *proc;
sigset_t set, oldset;
unsigned int i;
int ret;
@@ -198,8 +198,8 @@ sqfs_data_writer_t *sqfs_data_writer_create(size_t max_block_size,
proc->queue_cond = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
proc->done_cond = (pthread_cond_t)PTHREAD_COND_INITIALIZER;
- if (data_writer_init(proc, max_block_size, cmp, num_workers,
- max_backlog, devblksz, file)) {
+ if (block_processor_init(proc, max_block_size, cmp, num_workers,
+ max_backlog, devblksz, file)) {
goto fail_init;
}
@@ -257,11 +257,11 @@ fail_init:
pthread_cond_destroy(&proc->done_cond);
pthread_cond_destroy(&proc->queue_cond);
pthread_mutex_destroy(&proc->mtx);
- data_writer_cleanup(proc);
+ block_processor_cleanup(proc);
return NULL;
}
-void sqfs_data_writer_destroy(sqfs_data_writer_t *proc)
+void sqfs_block_processor_destroy(sqfs_block_processor_t *proc)
{
unsigned int i;
@@ -281,11 +281,11 @@ void sqfs_data_writer_destroy(sqfs_data_writer_t *proc)
pthread_cond_destroy(&proc->queue_cond);
pthread_mutex_destroy(&proc->mtx);
- data_writer_cleanup(proc);
+ block_processor_cleanup(proc);
}
#endif
-int append_to_work_queue(sqfs_data_writer_t *proc, sqfs_block_t *block,
+int append_to_work_queue(sqfs_block_processor_t *proc, sqfs_block_t *block,
bool signal_threads)
{
int status;
@@ -317,7 +317,7 @@ out:
return 0;
}
-static sqfs_block_t *try_dequeue(sqfs_data_writer_t *proc)
+static sqfs_block_t *try_dequeue(sqfs_block_processor_t *proc)
{
sqfs_block_t *queue, *it, *prev;
@@ -363,7 +363,7 @@ static sqfs_block_t *queue_merge(sqfs_block_t *lhs, sqfs_block_t *rhs)
return head;
}
-static int process_done_queue(sqfs_data_writer_t *proc, sqfs_block_t *queue)
+static int process_done_queue(sqfs_block_processor_t *proc, sqfs_block_t *queue)
{
sqfs_block_t *it, *block = NULL;
int status = 0;
@@ -410,7 +410,7 @@ static int process_done_queue(sqfs_data_writer_t *proc, sqfs_block_t *queue)
return status;
}
-int test_and_set_status(sqfs_data_writer_t *proc, int status)
+int test_and_set_status(sqfs_block_processor_t *proc, int status)
{
LOCK(&proc->mtx);
if (proc->status == 0) {
@@ -423,7 +423,7 @@ int test_and_set_status(sqfs_data_writer_t *proc, int status)
return status;
}
-int wait_completed(sqfs_data_writer_t *proc)
+int wait_completed(sqfs_block_processor_t *proc)
{
sqfs_block_t *queue;
int status;
diff --git a/mkfs/mkfs.c b/mkfs/mkfs.c
index b5d3443..bccbd79 100644
--- a/mkfs/mkfs.c
+++ b/mkfs/mkfs.c
@@ -39,8 +39,8 @@ static int set_working_dir(options_t *opt)
return 0;
}
-static int pack_files(sqfs_data_writer_t *data, fstree_t *fs,
- data_writer_stats_t *stats, options_t *opt)
+static int pack_files(sqfs_block_processor_t *data, fstree_t *fs,
+ block_processor_stats_t *stats, options_t *opt)
{
sqfs_inode_generic_t *inode;
size_t max_blk_count;