summaryrefslogtreecommitdiff
path: root/include/frag_reader.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-03 17:35:37 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-05-03 21:45:46 +0200
commit12c8196ad46808dc9d0e84b3a798509dcf1a41e7 (patch)
tree9069df66c14ca427540290ca1fb88688c859bb15 /include/frag_reader.h
parent0903622b468136ef4354f33ebb24b12df0f549bb (diff)
Add utility functions to read the fragment data from an image
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/frag_reader.h')
-rw-r--r--include/frag_reader.h31
1 files changed, 31 insertions, 0 deletions
diff --git a/include/frag_reader.h b/include/frag_reader.h
new file mode 100644
index 0000000..6495f5b
--- /dev/null
+++ b/include/frag_reader.h
@@ -0,0 +1,31 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+#ifndef FRAG_READER_H
+#define FRAG_READER_H
+
+#include "squashfs.h"
+#include "compress.h"
+
+#include <stdint.h>
+#include <stddef.h>
+
+typedef struct {
+ sqfs_fragment_t *tbl;
+ size_t num_fragments;
+
+ int fd;
+ compressor_t *cmp;
+ size_t block_size;
+ size_t used;
+ size_t current_index;
+ uint8_t buffer[];
+} frag_reader_t;
+
+frag_reader_t *frag_reader_create(sqfs_super_t *super, int fd,
+ compressor_t *cmp);
+
+void frag_reader_destroy(frag_reader_t *f);
+
+int frag_reader_read(frag_reader_t *f, size_t index, size_t offset,
+ void *buffer, size_t size);
+
+#endif /* FRAG_READER_H */