summaryrefslogtreecommitdiff
path: root/lib/sqfs/meta_writer.c
diff options
context:
space:
mode:
Diffstat (limited to 'lib/sqfs/meta_writer.c')
-rw-r--r--lib/sqfs/meta_writer.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/lib/sqfs/meta_writer.c b/lib/sqfs/meta_writer.c
index 77ceeb9..2dacaa0 100644
--- a/lib/sqfs/meta_writer.c
+++ b/lib/sqfs/meta_writer.c
@@ -8,6 +8,26 @@
#include <unistd.h>
#include <stdio.h>
+struct meta_writer_t {
+ /* A byte offset into the uncompressed data of the current block */
+ size_t offset;
+
+ /* The location of the current block in the file */
+ size_t block_offset;
+
+ /* The underlying file descriptor to write to */
+ int outfd;
+
+ /* A pointer to the compressor to use for compressing the data */
+ compressor_t *cmp;
+
+ /* The raw data chunk that data is appended to */
+ uint8_t data[SQFS_META_BLOCK_SIZE + 2];
+
+ /* Scratch buffer for compressing data */
+ uint8_t scratch[SQFS_META_BLOCK_SIZE + 2];
+};
+
meta_writer_t *meta_writer_create(int fd, compressor_t *cmp)
{
meta_writer_t *m = calloc(1, sizeof(*m));
@@ -95,3 +115,16 @@ int meta_writer_append(meta_writer_t *m, const void *data, size_t size)
return 0;
}
+
+void meta_writer_get_position(const meta_writer_t *m, uint64_t *block_start,
+ uint32_t *offset)
+{
+ *block_start = m->block_offset;
+ *offset = m->offset;
+}
+
+void meta_writer_reset(meta_writer_t *m)
+{
+ m->block_offset = 0;
+ m->offset = 0;
+}