summaryrefslogtreecommitdiff
path: root/tar/sqfs2tar.c
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-16 12:36:37 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-16 12:36:37 +0200
commitad83b0f167f3e65a2aa04cf358d1f995f1241a3c (patch)
tree6e2b21dc608b41c6adcebe8f23b3b78017025bd1 /tar/sqfs2tar.c
parent69742b622a228babad255cbd64330d04c39c7e81 (diff)
sqfs2tar: cleanup tar header generation
- use struct stat instead of tree node - compact some of the code Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tar/sqfs2tar.c')
-rw-r--r--tar/sqfs2tar.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/tar/sqfs2tar.c b/tar/sqfs2tar.c
index f7f7e71..1be1b7e 100644
--- a/tar/sqfs2tar.c
+++ b/tar/sqfs2tar.c
@@ -105,7 +105,8 @@ static int terminate_archive(void)
static int write_tree_dfs(fstree_t *fs, tree_node_t *n, data_reader_t *data)
{
- char *name;
+ char *name, *target;
+ struct stat sb;
int ret;
if (n->parent != NULL || !S_ISDIR(n->mode)) {
@@ -117,7 +118,10 @@ static int write_tree_dfs(fstree_t *fs, tree_node_t *n, data_reader_t *data)
assert(canonicalize_name(name) == 0);
- ret = write_tar_header(STDOUT_FILENO, fs, n, name);
+ fstree_node_stat(fs, n, &sb);
+
+ target = S_ISLNK(sb.st_mode) ? n->data.slink_target : NULL;
+ ret = write_tar_header(STDOUT_FILENO, &sb, name, target);
free(name);
if (ret < 0)