From 44fb01e8a8417fadd79ba347c9ad3f0bb3a1d0b8 Mon Sep 17 00:00:00 2001 From: David Oberhollenzer Date: Thu, 16 Apr 2020 01:19:13 +0200 Subject: sqfs2tar: Fix trailing slashes for directory names sqfs2tar is supposed to append slashes to directory names. Until now, it assumed a tree node to be a directory if it has children. This simple check obviously fails for empty directories. This commit fixes the check by actually testing the inode mode. Signed-off-by: David Oberhollenzer --- tar/sqfs2tar.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tar/sqfs2tar.c b/tar/sqfs2tar.c index b21570a..6d2a51a 100644 --- a/tar/sqfs2tar.c +++ b/tar/sqfs2tar.c @@ -351,6 +351,8 @@ static int write_tree_dfs(const sqfs_tree_node_t *n) size_t len; int ret; + inode_stat(n, &sb); + if (n->parent == NULL) { if (root_becomes == NULL) goto skip_hdr; @@ -394,13 +396,11 @@ static int write_tree_dfs(const sqfs_tree_node_t *n) } } - name = assemble_tar_path(name, n->children != NULL); + name = assemble_tar_path(name, S_ISDIR(sb.st_mode)); if (name == NULL) return -1; } - inode_stat(n, &sb); - if (lnk != NULL) { ret = write_hard_link(out_file, &sb, name, lnk->target, record_counter++); -- cgit v1.2.3