diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-09-15 16:37:57 +0200 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2023-09-15 21:48:47 +0200 |
commit | 0b3f650fa4eb0dcce2258c7bb8974a1304468a05 (patch) | |
tree | 03370de760017b7e410a8e474f487e5664e5a01a | |
parent | f0479f3acd90a46f8354277360c96763fa74ef65 (diff) |
libsqfs: Remove sqfs_dir_reader_t functions unused in the code base
Those functions are only used in the example code, we remove them for
now to make restructuring easier and fix the examples later.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r-- | include/sqfs/dir_reader.h | 33 | ||||
-rw-r--r-- | lib/sqfs/src/dir_reader.c | 90 |
2 files changed, 0 insertions, 123 deletions
diff --git a/include/sqfs/dir_reader.h b/include/sqfs/dir_reader.h index eb90b7a..0f1f231 100644 --- a/include/sqfs/dir_reader.h +++ b/include/sqfs/dir_reader.h @@ -207,17 +207,6 @@ SQFS_API int sqfs_dir_reader_open_dir(sqfs_dir_reader_t *rd, sqfs_u32 flags); /** - * @brief Reset a directory reader back to the beginning of the listing. - * - * @memberof sqfs_dir_reader_t - * - * @param rd A pointer to a directory reader. - * - * @return Zero on success, an @ref SQFS_ERROR value on failure. - */ -SQFS_API int sqfs_dir_reader_rewind(sqfs_dir_reader_t *rd); - -/** * @brief Read a directory entry and advance the internal position indicator * to the next one. * @@ -269,28 +258,6 @@ SQFS_API int sqfs_dir_reader_get_inode(sqfs_dir_reader_t *rd, 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 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. - * @param out Returns a pointer to a generic inode that can be freed with a - * single @ref sqfs_free call. - * - * @return Zero on success, an @ref 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); - #ifdef __cplusplus } #endif diff --git a/lib/sqfs/src/dir_reader.c b/lib/sqfs/src/dir_reader.c index ce93795..c904f35 100644 --- a/lib/sqfs/src/dir_reader.c +++ b/lib/sqfs/src/dir_reader.c @@ -40,17 +40,6 @@ struct sqfs_dir_reader_t { sqfs_dir_reader_state_t state; }; -static int inode_copy(const sqfs_inode_generic_t *inode, - sqfs_inode_generic_t **out) -{ - *out = alloc_flex(sizeof(*inode), 1, inode->payload_bytes_used); - if (*out == NULL) - return SQFS_ERROR_ALLOC; - - memcpy(*out, inode, sizeof(*inode) + inode->payload_bytes_used); - return 0; -} - static int dcache_key_compare(const void *ctx, const void *l, const void *r) { sqfs_u32 lhs = *((const sqfs_u32 *)l), rhs = *((const sqfs_u32 *)r); @@ -285,16 +274,6 @@ int sqfs_dir_reader_read(sqfs_dir_reader_t *rd, sqfs_dir_node_t **out) out, NULL, &rd->state.ent_ref); } -int sqfs_dir_reader_rewind(sqfs_dir_reader_t *rd) -{ - if (rd->state.state == DIR_STATE_NONE) - return SQFS_ERROR_SEQUENCE; - - sqfs_readdir_state_reset(&rd->state.cursor); - rd->state.state = rd->state.start_state; - return 0; -} - int sqfs_dir_reader_get_inode(sqfs_dir_reader_t *rd, sqfs_inode_generic_t **inode) { @@ -323,72 +302,3 @@ 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) -{ - sqfs_inode_generic_t *inode; - const char *ptr; - int ret = 0; - char *name; - - if (start == NULL) { - ret = sqfs_dir_reader_get_root_inode(rd, &inode); - } else { - ret = inode_copy(start, &inode); - } - - if (ret) - return ret; - - for (; *path != '\0'; path = ptr) { - if (*path == '/') { - for (ptr = path; *ptr == '/'; ++ptr) - ; - continue; - } - - ret = sqfs_dir_reader_open_dir(rd, inode, 0); - free(inode); - if (ret) - return ret; - - ptr = strchrnul(path, '/'); - - name = strndup(path, ptr - path); - if (name == NULL) - return SQFS_ERROR_ALLOC; - - ret = find_entry(rd, name); - free(name); - if (ret) - return ret; - - ret = sqfs_dir_reader_get_inode(rd, &inode); - if (ret) - return ret; - } - - *out = inode; - return 0; -} |