diff options
author | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-12-19 16:31:39 +0100 |
---|---|---|
committer | David Oberhollenzer <david.oberhollenzer@sigma-star.at> | 2019-12-22 22:07:44 +0100 |
commit | b16616ef092e8cd97674aac3380c5d7c600d7c61 (patch) | |
tree | 87f5042e0f7e7c701b3a67ed264ffddfe03cd864 /tar | |
parent | 1466f1f8571aca423156ee7ef4094a0c082f88d7 (diff) |
Add hard link support to gensquashfs and tar2sqfs
In libtar, set a special flag if the header is actually a hard link.
In tar2sqfs, create a hard link node and skip the rest for hard links.
Also refues to set the root attributes from a hard link, it may refere
to a node that we have missed earlier, there is nothing else that we
can do here.
In fstree_from_file, add a "link" command for adding hard links.
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tar')
-rw-r--r-- | tar/tar2sqfs.c | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tar/tar2sqfs.c b/tar/tar2sqfs.c index 63933eb..f522239 100644 --- a/tar/tar2sqfs.c +++ b/tar/tar2sqfs.c @@ -355,6 +355,19 @@ static int create_node_and_repack_data(tar_header_decoded_t *hdr) { tree_node_t *node; + if (hdr->is_hard_link) { + node = fstree_add_hard_link(&sqfs.fs, hdr->name, + hdr->link_target); + if (node == NULL) + goto fail_errno; + + if (!cfg.quiet) { + printf("Hard link %s -> %s\n", hdr->name, + hdr->link_target); + } + return 0; + } + if (!keep_time) { hdr->sb.st_mtime = sqfs.fs.defaults.st_mtime; } @@ -385,7 +398,7 @@ fail_errno: static int set_root_attribs(const tar_header_decoded_t *hdr) { - if (!S_ISDIR(hdr->sb.st_mode)) { + if (hdr->is_hard_link || !S_ISDIR(hdr->sb.st_mode)) { fprintf(stderr, "'%s' is not a directory!\n", hdr->name); return -1; } |