diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-09-15 14:50:58 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-09-15 21:48:47 +0200 |
commit | 2f172b69bda25d26790538cea7a15044f8207a7b (patch) | |
tree | 10977ece69d001d828ea6a857ba30af0d74ec022 /lib/sqfs | |
parent | e543ea3c6f46b336fb5a6f9ecdb9fab89e2f02ee (diff) |
libsqfs: Internalize sqfs_dir_reader_find function
The only user in the code base is sqfs_dir_reader_find_by_path.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'lib/sqfs')
-rw-r--r-- | lib/sqfs/src/dir_reader.c | 44 |
1 files changed, 20 insertions, 24 deletions
diff --git a/lib/sqfs/src/dir_reader.c b/lib/sqfs/src/dir_reader.c index d5a8cbd..c44198e 100644 --- a/lib/sqfs/src/dir_reader.c +++ b/lib/sqfs/src/dir_reader.c @@ -301,29 +301,6 @@ int sqfs_dir_reader_rewind(sqfs_dir_reader_t *rd) return 0; } -int sqfs_dir_reader_find(sqfs_dir_reader_t *rd, const char *name) -{ - sqfs_dir_node_t *ent; - int ret; - - ret = sqfs_dir_reader_rewind(rd); - if (ret != 0) - return ret; - - do { - ret = sqfs_dir_reader_read(rd, &ent); - if (ret < 0) - return ret; - if (ret > 0) - return SQFS_ERROR_NO_ENTRY; - - ret = strcmp((const char *)ent->name, name); - free(ent); - } while (ret < 0); - - return ret == 0 ? 0 : SQFS_ERROR_NO_ENTRY; -} - int sqfs_dir_reader_get_inode(sqfs_dir_reader_t *rd, sqfs_inode_generic_t **inode) { @@ -353,6 +330,25 @@ int sqfs_dir_reader_get_root_inode(sqfs_dir_reader_t *rd, return dcache_add(rd, *inode, rd->super.root_inode_ref); } +static int find_entry(sqfs_dir_reader_t *rd, const char *name) +{ + sqfs_dir_node_t *ent; + int ret; + + do { + ret = sqfs_dir_reader_read(rd, &ent); + if (ret < 0) + return ret; + if (ret > 0) + return SQFS_ERROR_NO_ENTRY; + + ret = strcmp((const char *)ent->name, name); + free(ent); + } while (ret < 0); + + return ret == 0 ? 0 : SQFS_ERROR_NO_ENTRY; +} + 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) @@ -389,7 +385,7 @@ int sqfs_dir_reader_find_by_path(sqfs_dir_reader_t *rd, if (name == NULL) return SQFS_ERROR_ALLOC; - ret = sqfs_dir_reader_find(rd, name); + ret = find_entry(rd, name); free(name); if (ret) return ret; |