diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-06-07 23:10:41 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-06-07 23:10:41 +0200 |
commit | 9c9ef7cae619e95232f44be21d4648edb5f0777a (patch) | |
tree | aa40581ab35a7032dd49aaca312a77b0c882bbe7 /include/sqfs/xattr_reader.h | |
parent | 9221d4dce6ff3e3cdd0f630a884b3643e6a1cac4 (diff) |
libsquashfs: Add utility functions to read xattrs into list
The common pattern is used in rdsquashfs and sqfs2tar, move the code
to libsquashfs.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'include/sqfs/xattr_reader.h')
-rw-r--r-- | include/sqfs/xattr_reader.h | 36 |
1 files changed, 36 insertions, 0 deletions
diff --git a/include/sqfs/xattr_reader.h b/include/sqfs/xattr_reader.h index a0242fb..2c65afa 100644 --- a/include/sqfs/xattr_reader.h +++ b/include/sqfs/xattr_reader.h @@ -190,6 +190,42 @@ int sqfs_xattr_reader_read_value(sqfs_xattr_reader_t *xr, const sqfs_xattr_entry_t *key, sqfs_xattr_value_t **val_out); +/** + * @brief Read a combined key-value pair into an @ref sqfs_xattr_t struct + * + * @memberof sqfs_xattr_reader_t + * + * @param xr A pointer to an xattr reader instance. + * @param out Returns a pointer to a combined key-value struct. + * + * @return Zero on success, a negative @ref SQFS_ERROR value on failure. + */ +SQFS_API +int sqfs_xattr_reader_read(sqfs_xattr_reader_t *xr, sqfs_xattr_t **out); + +/** + * @brief Read all xattrs associated with an ID into memory + * + * @memberof sqfs_xattr_reader_t + * + * This is a convenience function that internally resolves the xattr index + * using @ref sqfs_xattr_reader_get_desc, seeks to the key-value list using + * @ref sqfs_xattr_reader_seek_kv and reads all the entries into a liked + * list of @ref sqfs_xattr_t structs. + * + * If the index is the special value 0xFFFFFFFF, the function successfully + * returns an empty list. + * + * @param xr A pointer to an xattr reader instance. + * @param idx An xattr index. + * @param out Returns a linked list to key-value pairs on success. + * + * @return Zero on success, a negative @ref SQFS_ERROR value on failure. + */ +SQFS_API int sqfs_xattr_reader_read_all(sqfs_xattr_reader_t *xr, sqfs_u32 idx, + sqfs_xattr_t **out); + + #ifdef __cplusplus } #endif |