summaryrefslogtreecommitdiff
path: root/include/sqfs/io.h
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-15 20:40:01 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-09-15 20:44:41 +0200
commit428aa363dd2b44756a5b16aa17e8c2030de801a0 (patch)
tree8bc507fdcc795a5c75ef7a148e66e940d4df91b9 /include/sqfs/io.h
parent129e1758a5e2cf851f042e139fdd808a9be9ce94 (diff)
Move condensed-sparse-file handling to libsquashfs
Add another helper function for getting a blocks from a condensed sparse file, then rewrite the data writer to use that instead, using an sqfs_file_t pointer instead of direct file i/o. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/sqfs/io.h')
-rw-r--r--include/sqfs/io.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/include/sqfs/io.h b/include/sqfs/io.h
index cf6f1fa..bbc3da9 100644
--- a/include/sqfs/io.h
+++ b/include/sqfs/io.h
@@ -189,6 +189,35 @@ SQFS_API int sqfs_file_create_block(sqfs_file_t *file, uint64_t offset,
size_t size, void *user, uint32_t flags,
sqfs_block_t **out);
+/**
+ * @brief Read a chunk from a condensed version of a sparse file and turn it
+ * into a block that can be fed to a block processor.
+ *
+ * @member sqfs_file_t
+ *
+ * This function works on condensed sparse files, i.e. a sparse file that had
+ * its holdes removed. The given mapping describes the original data region
+ * that are actually packed next to each other. The function emulates the
+ * orignal sparse file by zero-initializing the block data, then figuring
+ * out which regions overlap the block, working out their physical location and
+ * stitching the block together.
+ *
+ * @param file A pointer to a file implementation.
+ * @param offset A byte offset into the file.
+ * @param size The number of bytes to read, starting at the given offset.
+ * @param user A user pointer to set for the block.
+ * @param flags The flags to store in the newly created block.
+ * @param map Describes the data regions of the original sparse file.
+ * @param out Returns a pointer to a block on success.
+ *
+ * @return Zero on success, an @ref E_SQFS_ERROR identifier on failure.
+ */
+SQFS_API int sqfs_file_create_block_dense(sqfs_file_t *file, uint64_t offset,
+ size_t size, void *user,
+ uint32_t flags,
+ const sqfs_sparse_map_t *map,
+ sqfs_block_t **out);
+
#ifdef __cplusplus
}
#endif