From 1a4af498b497bfe1acb40d8aff0c65d9b22b3aa5 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Sun, 19 Jan 2020 17:51:33 +0100 Subject: Add a helper function to unpack directory index entries Signed-off-by: David Oberhollenzer --- include/sqfs/inode.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'include/sqfs') 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 -- cgit v1.2.3