aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sqfs/block_processor.h11
-rw-r--r--lib/Makemodule.am1
-rw-r--r--lib/sqfs/comp/create_block.c37
-rw-r--r--lib/sqfshelper/data_writer.c25
4 files changed, 24 insertions, 50 deletions
diff --git a/include/sqfs/block_processor.h b/include/sqfs/block_processor.h
index b7550aa..5d7ed3b 100644
--- a/include/sqfs/block_processor.h
+++ b/include/sqfs/block_processor.h
@@ -95,17 +95,6 @@ int block_processor_enqueue(block_processor_t *proc, block_t *block);
int block_processor_finish(block_processor_t *proc);
/*
- Convenience function to create a block structure and optionally fill it with
- content.
-
- filename is used for printing error messages. If fd is a valid file
- descriptor (>= 0), the function attempts to populate the payload data
- from the input file.
- */
-block_t *create_block(const char *filename, int fd, size_t size,
- void *user, uint32_t flags);
-
-/*
Convenience function to process a data block. Returns 0 on success,
prints to stderr on failure.
*/
diff --git a/lib/Makemodule.am b/lib/Makemodule.am
index 186719e..6938fd7 100644
--- a/lib/Makemodule.am
+++ b/lib/Makemodule.am
@@ -57,7 +57,6 @@ libsquashfs_la_SOURCES += lib/sqfs/readdir.c
libsquashfs_la_SOURCES += lib/sqfs/xattr.c lib/sqfs/xattr_reader.c
libsquashfs_la_SOURCES += lib/sqfs/read_table.c
libsquashfs_la_SOURCES += lib/sqfs/comp/compressor.c lib/sqfs/comp/internal.h
-libsquashfs_la_SOURCES += lib/sqfs/comp/create_block.c
libsquashfs_la_SOURCES += lib/sqfs/comp/process_block.c
libsquashfs_la_CPPFLAGS = $(AM_CPPFLAGS)
libsquashfs_la_CFLAGS = $(AM_CFLAGS) $(PTHREAD_CFLAGS) $(ZLIB_CFLAGS)
diff --git a/lib/sqfs/comp/create_block.c b/lib/sqfs/comp/create_block.c
deleted file mode 100644
index 0494e73..0000000
--- a/lib/sqfs/comp/create_block.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-/*
- * create_block.c
- *
- * Copyright (C) 2019 David Oberhollenzer <goliath@infraroot.at>
- */
-#include "config.h"
-
-#include "sqfs/block_processor.h"
-#include "util.h"
-
-#include <string.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-block_t *create_block(const char *filename, int fd, size_t size,
- void *user, uint32_t flags)
-{
- block_t *blk = alloc_flex(sizeof(*blk), 1, size);
-
- if (blk == NULL) {
- perror(filename);
- return NULL;
- }
-
- if (fd >= 0) {
- if (read_data(filename, fd, blk->data, size)) {
- free(blk);
- return NULL;
- }
- }
-
- blk->size = size;
- blk->user = user;
- blk->flags = flags;
- return blk;
-}
diff --git a/lib/sqfshelper/data_writer.c b/lib/sqfshelper/data_writer.c
index da2aae8..4838f9a 100644
--- a/lib/sqfshelper/data_writer.c
+++ b/lib/sqfshelper/data_writer.c
@@ -262,6 +262,29 @@ static int add_sentinel_block(data_writer_t *data, file_info_t *fi,
return block_processor_enqueue(data->proc, blk);
}
+static block_t *create_block(file_info_t *fi, int fd, size_t size,
+ uint32_t flags)
+{
+ block_t *blk = alloc_flex(sizeof(*blk), 1, size);
+
+ if (blk == NULL) {
+ perror(fi->input_file);
+ return NULL;
+ }
+
+ if (fd >= 0) {
+ if (read_data(fi->input_file, fd, blk->data, size)) {
+ free(blk);
+ return NULL;
+ }
+ }
+
+ blk->size = size;
+ blk->user = fi;
+ blk->flags = flags;
+ return blk;
+}
+
int write_data_from_fd(data_writer_t *data, file_info_t *fi,
int infd, int flags)
{
@@ -286,7 +309,7 @@ int write_data_from_fd(data_writer_t *data, file_info_t *fi,
diff = file_size;
}
- blk = create_block(fi->input_file, infd, diff, fi, blk_flags);
+ blk = create_block(fi, infd, diff, blk_flags);
if (blk == NULL)
return -1;