From caa34ed48ba55a50a4187cd1ae307c09c6b75311 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 19 Dec 2019 16:33:47 +0100 Subject: Fix link count for file inodes in tree serialization. Signed-off-by: David Oberhollenzer --- lib/common/serialize_fstree.c | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'lib/common') diff --git a/lib/common/serialize_fstree.c b/lib/common/serialize_fstree.c index 39f8f94..73f4e67 100644 --- a/lib/common/serialize_fstree.c +++ b/lib/common/serialize_fstree.c @@ -118,6 +118,13 @@ static int serialize_tree_node(const char *filename, sqfs_writer_t *wr, inode = n->data.file.user_ptr; n->data.file.user_ptr = NULL; ret = SQFS_ERROR_INTERNAL; + + if (inode->base.type == SQFS_INODE_FILE && n->link_count > 1) { + sqfs_inode_make_extended(inode); + inode->data.file_ext.nlink = n->link_count; + } else { + inode->data.file_ext.nlink = n->link_count; + } } else { inode = tree_node_to_inode(n); ret = SQFS_ERROR_ALLOC; -- cgit v1.2.3