summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/sqfs/inode.h18
-rw-r--r--lib/sqfs/dir_reader.c11
-rw-r--r--lib/sqfs/inode.c14
3 files changed, 9 insertions, 34 deletions
diff --git a/include/sqfs/inode.h b/include/sqfs/inode.h
index 0323bef..a6e7111 100644
--- a/include/sqfs/inode.h
+++ b/include/sqfs/inode.h
@@ -544,24 +544,6 @@ size_t sqfs_inode_get_file_block_count(const sqfs_inode_generic_t *inode)
}
/**
- * @brief Create a deep copy of a generic inode.
- *
- * The @ref sqfs_inode_generic_t structure contains inlined fields that have a
- * size depending on the inode data and pointers to the inlined fields. This
- * helper function calculates the actual size of the structure in memory, makes
- * a copy and propperly sets up the pointers.
- *
- * @param src The inode to copy.
- * @param copy Returns a pointer to the copy on success. Can be released with a
- * single free call.
- *
- * @return Zero on success, an @ref SQFS_ERROR_CORRUPTED if the node has
- * an unknown type set.
- */
-SQFS_API int sqfs_inode_copy(const sqfs_inode_generic_t *src,
- sqfs_inode_generic_t **copy);
-
-/**
* @brief Get the extended attribute index of an inode
*
* For basic inodes, this returns the inode index 0xFFFFFFFF, i.e. the
diff --git a/lib/sqfs/dir_reader.c b/lib/sqfs/dir_reader.c
index 39e3e57..4e2a5b8 100644
--- a/lib/sqfs/dir_reader.c
+++ b/lib/sqfs/dir_reader.c
@@ -222,12 +222,19 @@ int sqfs_dir_reader_find_by_path(sqfs_dir_reader_t *rd,
sqfs_inode_generic_t *inode;
sqfs_dir_entry_t *ent;
const char *ptr;
- int ret;
+ int ret = 0;
if (start == NULL) {
ret = sqfs_dir_reader_get_root_inode(rd, &inode);
} else {
- ret = sqfs_inode_copy(start, &inode);
+ inode = alloc_flex(sizeof(*inode), 1,
+ start->payload_bytes_used);
+ if (inode == NULL) {
+ ret = SQFS_ERROR_ALLOC;
+ } else {
+ memcpy(inode, start,
+ sizeof(*start) + start->payload_bytes_used);
+ }
}
if (ret)
diff --git a/lib/sqfs/inode.c b/lib/sqfs/inode.c
index bda244b..02d23e2 100644
--- a/lib/sqfs/inode.c
+++ b/lib/sqfs/inode.c
@@ -33,20 +33,6 @@ static int inverse_type[] = {
[SQFS_INODE_EXT_SOCKET] = SQFS_INODE_SOCKET,
};
-int sqfs_inode_copy(const sqfs_inode_generic_t *src,
- sqfs_inode_generic_t **out)
-{
- size_t size = sizeof(*src) + src->payload_bytes_used;
- sqfs_inode_generic_t *copy = calloc(1, size);
-
- if (copy == NULL)
- return SQFS_ERROR_ALLOC;
-
- memcpy(copy, src, size);
- *out = copy;
- return 0;
-}
-
int sqfs_inode_get_xattr_index(const sqfs_inode_generic_t *inode,
sqfs_u32 *out)
{