diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-09-16 03:00:30 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-09-19 11:45:53 +0200 |
commit | 2d01fe534a775dcab61651ef807fc118c579dd3d (patch) | |
tree | 188a0e75e971a23a5f4a2dc80d3a56b08a2ea36f /lib/sqfs | |
parent | 273a5ef517dd6c3f8b795b1dacf40d5a83acbbcc (diff) |
libsqfs: Expose the directory reader cache query function
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs')
-rw-r--r-- | lib/sqfs/src/dir_reader.c | 41 |
1 files changed, 23 insertions, 18 deletions
diff --git a/lib/sqfs/src/dir_reader.c b/lib/sqfs/src/dir_reader.c index 042b93a..6920a7d 100644 --- a/lib/sqfs/src/dir_reader.c +++ b/lib/sqfs/src/dir_reader.c @@ -63,21 +63,6 @@ static int dcache_add(sqfs_dir_reader_t *rd, return rbtree_insert(&rd->dcache, &inum, &ref); } -static int dcache_find(sqfs_dir_reader_t *rd, sqfs_u32 inode, sqfs_u64 *ref) -{ - rbtree_node_t *node; - - if (!(rd->flags & SQFS_DIR_READER_DOT_ENTRIES)) - return SQFS_ERROR_NO_ENTRY; - - node = rbtree_lookup(&rd->dcache, &inode); - if (node == NULL) - return SQFS_ERROR_NO_ENTRY; - - *ref = *((sqfs_u64 *)rbtree_node_value(node)); - return 0; -} - static void dir_reader_destroy(sqfs_object_t *obj) { sqfs_dir_reader_t *rd = (sqfs_dir_reader_t *)obj; @@ -208,12 +193,15 @@ int sqfs_dir_reader_open_dir(sqfs_dir_reader_t *rd, parent = inode->data.dir.parent_inode; } - if (dcache_find(rd, inode->base.inode_number, &state->dir_ref)) - return SQFS_ERROR_NO_ENTRY; + ret = sqfs_dir_reader_resolve_inum(rd, inode->base.inode_number, + &state->dir_ref); + if (ret) + return ret; if (state->dir_ref == rd->super.root_inode_ref) { state->parent_ref = state->dir_ref; - } else if (dcache_find(rd, parent, &state->parent_ref)) { + } else if (sqfs_dir_reader_resolve_inum(rd, parent, + &state->parent_ref)) { return SQFS_ERROR_NO_ENTRY; } @@ -291,3 +279,20 @@ int sqfs_dir_reader_get_root_inode(sqfs_dir_reader_t *rd, { return sqfs_dir_reader_get_inode(rd, rd->super.root_inode_ref, inode); } + +int sqfs_dir_reader_resolve_inum(sqfs_dir_reader_t *rd, + sqfs_u32 inode, sqfs_u64 *ref) +{ + rbtree_node_t *node; + + *ref = 0; + if (!(rd->flags & SQFS_DIR_READER_DOT_ENTRIES)) + return SQFS_ERROR_NO_ENTRY; + + node = rbtree_lookup(&rd->dcache, &inode); + if (node == NULL) + return SQFS_ERROR_NO_ENTRY; + + *ref = *((sqfs_u64 *)rbtree_node_value(node)); + return 0; +} |