summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-01-19 17:51:33 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2020-01-19 17:51:33 +0100
commit1a4af498b497bfe1acb40d8aff0c65d9b22b3aa5 (patch)
treebe88b633cf30bc168cc22afedec57114bc3d410d /include
parent84bd62267760fd02db895e21c5c2c8bf20162342 (diff)
Add a helper function to unpack directory index entries
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include')
-rw-r--r--include/sqfs/inode.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/include/sqfs/inode.h b/include/sqfs/inode.h
index 2b4a550..f2b6ede 100644
--- a/include/sqfs/inode.h
+++ b/include/sqfs/inode.h
@@ -696,6 +696,27 @@ SQFS_API int sqfs_inode_get_frag_location(const sqfs_inode_generic_t *inode,
SQFS_API int sqfs_inode_get_file_block_start(const sqfs_inode_generic_t *inode,
sqfs_u64 *location);
+/**
+ * @brief Unpack the a directory index structure from an inode.
+ *
+ * The generic inode contains in its payload the raw directory index (with
+ * bytes swapped to host enian), but still with single byte alignment. This
+ * function seeks through the blob using an integer index (not offset) and
+ * fiddles the raw data out into a propperly aligned, external structure.
+ *
+ * @param inode A pointer to an inode.
+ * @param out Returns the index entry. Can be freed with a single free call.
+ * @param index An index value between 0 and inodex_count.
+ *
+ * @return Zero on success, @ref SQFS_ERROR_OUT_OF_BOUNDS if the given index
+ * points outside the directory index. Can return other error codes
+ * (e.g. if the inode isn't a directory or allocation failed).
+ */
+SQFS_API
+int sqfs_inode_unpack_dir_index_entry(const sqfs_inode_generic_t *inode,
+ sqfs_dir_index_t **out,
+ size_t index);
+
#ifdef __cplusplus
}
#endif