aboutsummaryrefslogtreecommitdiff
path: root/bin/tar2sqfs/process_tarball.c
diff options
context:
space:
mode:
Diffstat (limited to 'bin/tar2sqfs/process_tarball.c')
-rw-r--r--bin/tar2sqfs/process_tarball.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/bin/tar2sqfs/process_tarball.c b/bin/tar2sqfs/process_tarball.c
index 1de35fa..984a1ef 100644
--- a/bin/tar2sqfs/process_tarball.c
+++ b/bin/tar2sqfs/process_tarball.c
@@ -156,6 +156,7 @@ int process_tarball(FILE *input_file, sqfs_writer_t *sqfs)
sqfs_u64 offset, count;
sparse_map_t *m;
size_t rootlen;
+ char *target;
int ret;
rootlen = root_becomes == NULL ? 0 : strlen(root_becomes);
@@ -204,6 +205,26 @@ int process_tarball(FILE *input_file, sqfs_writer_t *sqfs)
stderr);
skip = true;
}
+
+ if (hdr.link_target != NULL &&
+ (hdr.is_hard_link || !no_symlink_retarget)) {
+ target = strdup(hdr.link_target);
+ if (target == NULL) {
+ fprintf(stderr, "packing '%s': %s\n",
+ hdr.name, strerror(errno));
+ goto fail;
+ }
+
+ if (canonicalize_name(target) == 0 &&
+ !strncmp(target, root_becomes, rootlen) &&
+ target[rootlen] == '/') {
+ memmove(hdr.link_target,
+ target + rootlen,
+ strlen(target + rootlen) + 1);
+ }
+
+ free(target);
+ }
} else if (hdr.name[0] == '\0') {
is_root = true;
}