diff options
-rw-r--r-- | include/sqfs/dir_reader.h | 6 | ||||
-rw-r--r-- | lib/sqfs/dir_reader.c | 12 |
2 files changed, 14 insertions, 4 deletions
diff --git a/include/sqfs/dir_reader.h b/include/sqfs/dir_reader.h index 8071ef4..82121ed 100644 --- a/include/sqfs/dir_reader.h +++ b/include/sqfs/dir_reader.h @@ -269,11 +269,14 @@ SQFS_API int sqfs_dir_reader_get_root_inode(sqfs_dir_reader_t *rd, sqfs_inode_generic_t **inode); /** - * @brief Find an inode through path traversal from the root node downwards. + * @brief Find an inode through path traversal starting from the root or a + * given node downwards. * * @memberof sqfs_dir_reader_t * * @param rd A pointer to a directory reader. + * @param start If not NULL, path traversal starts at this node downwards. If + * set to NULL, start at the root node. * @param path A path to resolve into an inode. Forward or backward slashes can * be used to separate path components. Resolving '.' or '..' is * not supported. @@ -283,6 +286,7 @@ SQFS_API int sqfs_dir_reader_get_root_inode(sqfs_dir_reader_t *rd, * @return Zero on success, an @ref E_SQFS_ERROR value on failure. */ SQFS_API int sqfs_dir_reader_find_by_path(sqfs_dir_reader_t *rd, + const sqfs_inode_generic_t *start, const char *path, sqfs_inode_generic_t **out); diff --git a/lib/sqfs/dir_reader.c b/lib/sqfs/dir_reader.c index bda7d7a..8eae5bd 100644 --- a/lib/sqfs/dir_reader.c +++ b/lib/sqfs/dir_reader.c @@ -210,15 +210,21 @@ int sqfs_dir_reader_get_root_inode(sqfs_dir_reader_t *rd, block_start, offset, inode); } -int sqfs_dir_reader_find_by_path(sqfs_dir_reader_t *rd, const char *path, - sqfs_inode_generic_t **out) +int sqfs_dir_reader_find_by_path(sqfs_dir_reader_t *rd, + const sqfs_inode_generic_t *start, + const char *path, sqfs_inode_generic_t **out) { sqfs_inode_generic_t *inode; sqfs_dir_entry_t *ent; const char *ptr; int ret; - ret = sqfs_dir_reader_get_root_inode(rd, &inode); + if (start == NULL) { + ret = sqfs_dir_reader_get_root_inode(rd, &inode); + } else { + ret = sqfs_inode_copy(start, &inode); + } + if (ret) return ret; |