From c2e01ed987e942005fa66f11d96b8edb1d930c99 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Mon, 20 May 2019 11:01:10 +0200 Subject: cleanup: internalize meta reader/writer implementations Signed-off-by: David Oberhollenzer --- include/fstree.h | 2 +- include/meta_reader.h | 42 +----------------------------------------- include/meta_writer.h | 42 ++++++------------------------------------ 3 files changed, 8 insertions(+), 78 deletions(-) (limited to 'include') diff --git a/include/fstree.h b/include/fstree.h index e8324a9..4986ec2 100644 --- a/include/fstree.h +++ b/include/fstree.h @@ -28,7 +28,7 @@ struct tree_xattr_t { size_t num_attr; size_t max_attr; - uint32_t block; + uint64_t block; uint32_t offset; uint32_t size; diff --git a/include/meta_reader.h b/include/meta_reader.h index 78c0db3..a662959 100644 --- a/include/meta_reader.h +++ b/include/meta_reader.h @@ -5,47 +5,7 @@ #include "compress.h" #include "squashfs.h" -/** - * @struct meta_reader_t - * - * @brief Abstracts away I/O on SquashFS meta data - */ -typedef struct { - /** - * @brief The location of the current block in the file - */ - uint64_t block_offset; - - /** - * @brief The location of the next block after the current one - */ - uint64_t next_block; - - /** - * @brief A byte offset into the uncompressed data of the current block - */ - size_t offset; - - /** - * @brief The underlying file descriptor to read from - */ - int fd; - - /** - * @brief A pointer to the compressor to use for extracting data - */ - compressor_t *cmp; - - /** - * @brief The raw data read from the input file - */ - uint8_t data[SQFS_META_BLOCK_SIZE]; - - /** - * @brief The uncompressed data read from the input file - */ - uint8_t scratch[SQFS_META_BLOCK_SIZE]; -} meta_reader_t; +typedef struct meta_reader_t meta_reader_t; /** * @brief Create a meta data reader diff --git a/include/meta_writer.h b/include/meta_writer.h index 9dcc22d..6bcb29b 100644 --- a/include/meta_writer.h +++ b/include/meta_writer.h @@ -5,42 +5,7 @@ #include "compress.h" #include "squashfs.h" -/** - * @struct meta_writer_t - * - * @brief Abstracts away I/O on SquashFS meta data - */ -typedef struct { - /** - * @brief A byte offset into the uncompressed data of the current block - */ - size_t offset; - - /** - * @brief The location of the current block in the file - */ - size_t block_offset; - - /** - * @brief The underlying file descriptor to write to - */ - int outfd; - - /** - * @brief A pointer to the compressor to use for compressing the data - */ - compressor_t *cmp; - - /** - * @brief The raw data chunk that data is appended to - */ - uint8_t data[SQFS_META_BLOCK_SIZE + 2]; - - /** - * @brief Scratch buffer for compressing data - */ - uint8_t scratch[SQFS_META_BLOCK_SIZE + 2]; -} meta_writer_t; +typedef struct meta_writer_t meta_writer_t; /** * @brief Create a meta data writer @@ -102,4 +67,9 @@ int meta_writer_flush(meta_writer_t *m); */ int meta_writer_append(meta_writer_t *m, const void *data, size_t size); +void meta_writer_get_position(const meta_writer_t *m, uint64_t *block_start, + uint32_t *offset); + +void meta_writer_reset(meta_writer_t *m); + #endif /* META_WRITER_H */ -- cgit v1.2.3