aboutsummaryrefslogtreecommitdiff
path: root/lib/fstree/src
diff options
context:
space:
mode:
Diffstat (limited to 'lib/fstree/src')
-rw-r--r--lib/fstree/src/hardlink.c13
-rw-r--r--lib/fstree/src/post_process.c25
2 files changed, 21 insertions, 17 deletions
diff --git a/lib/fstree/src/hardlink.c b/lib/fstree/src/hardlink.c
index 81636c7..b6467e2 100644
--- a/lib/fstree/src/hardlink.c
+++ b/lib/fstree/src/hardlink.c
@@ -18,16 +18,17 @@ static int resolve_link(fstree_t *fs, tree_node_t *node)
tree_node_t *start = node;
for (;;) {
- if (node->mode == FSTREE_MODE_HARD_LINK_RESOLVED) {
+ if (!S_ISLNK(node->mode) || !(node->flags & FLAG_LINK_IS_HARD))
+ break;
+
+ if (node->flags & FLAG_LINK_RESOVED) {
node = node->data.target_node;
- } else if (node->mode == FSTREE_MODE_HARD_LINK) {
+ } else {
node = fstree_get_node_by_path(fs, fs->root,
node->data.target,
false, false);
if (node == NULL)
return -1;
- } else {
- break;
}
if (node == start) {
@@ -46,7 +47,7 @@ static int resolve_link(fstree_t *fs, tree_node_t *node)
return -1;
}
- start->mode = FSTREE_MODE_HARD_LINK_RESOLVED;
+ start->flags |= FLAG_LINK_RESOVED;
start->data.target_node = node;
node->link_count++;
@@ -70,7 +71,7 @@ tree_node_t *fstree_add_hard_link(fstree_t *fs, const char *path,
return NULL;
}
- n->mode = FSTREE_MODE_HARD_LINK;
+ n->flags |= FLAG_LINK_IS_HARD;
}
n->next_by_type = fs->links_unresolved;
diff --git a/lib/fstree/src/post_process.c b/lib/fstree/src/post_process.c
index f8bc0f7..c5a15a3 100644
--- a/lib/fstree/src/post_process.c
+++ b/lib/fstree/src/post_process.c
@@ -35,18 +35,19 @@ static int alloc_inode_num_dfs(fstree_t *fs, tree_node_t *root)
}
for (it = root->data.children; it != NULL; it = it->next) {
- if (it->mode != FSTREE_MODE_HARD_LINK_RESOLVED) {
- if (SZ_ADD_OV(fs->unique_inode_count, 1, &inum))
- goto fail_ov;
+ if (S_ISLNK(it->mode) && (it->flags & FLAG_LINK_IS_HARD))
+ continue;
- if ((sizeof(size_t) > sizeof(sqfs_u32)) &&
- inum > 0x0FFFFFFFFUL) {
- goto fail_ov;
- }
+ if (SZ_ADD_OV(fs->unique_inode_count, 1, &inum))
+ goto fail_ov;
- it->inode_num = (sqfs_u32)inum;
- fs->unique_inode_count = inum;
+ if ((sizeof(size_t) > sizeof(sqfs_u32)) &&
+ inum > 0x0FFFFFFFFUL) {
+ goto fail_ov;
}
+
+ it->inode_num = (sqfs_u32)inum;
+ fs->unique_inode_count = inum;
}
return 0;
@@ -87,7 +88,7 @@ static tree_node_t *file_list_dfs(tree_node_t *n)
static void map_inodes_dfs(fstree_t *fs, tree_node_t *n)
{
- if (n->mode == FSTREE_MODE_HARD_LINK_RESOLVED)
+ if (S_ISLNK(n->mode) && (n->flags & FLAG_LINK_IS_HARD))
return;
fs->inodes[n->inode_num - 1] = n;
@@ -110,7 +111,9 @@ static void reorder_hard_links(fstree_t *fs)
it = fs->inodes[i]->data.children;
for (; it != NULL; it = it->next) {
- if (it->mode != FSTREE_MODE_HARD_LINK_RESOLVED)
+ if (!S_ISLNK(it->mode))
+ continue;
+ if (!(it->flags & FLAG_LINK_IS_HARD))
continue;
tgt = it->data.target_node;