summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-12-19 16:31:39 +0100
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-12-22 22:07:44 +0100
commitb16616ef092e8cd97674aac3380c5d7c600d7c61 (patch)
tree87f5042e0f7e7c701b3a67ed264ffddfe03cd864 /lib
parent1466f1f8571aca423156ee7ef4094a0c082f88d7 (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 'lib')
-rw-r--r--lib/fstree/fstree_from_file.c14
-rw-r--r--lib/tar/read_header.c3
2 files changed, 15 insertions, 2 deletions
diff --git a/lib/fstree/fstree_from_file.c b/lib/fstree/fstree_from_file.c
index 9cdf9a1..bf11755 100644
--- a/lib/fstree/fstree_from_file.c
+++ b/lib/fstree/fstree_from_file.c
@@ -62,6 +62,19 @@ static int add_file(fstree_t *fs, const char *filename, size_t line_num,
return add_generic(fs, filename, line_num, path, basic, extra);
}
+static int add_hard_link(fstree_t *fs, const char *filename, size_t line_num,
+ const char *path, struct stat *basic, const char *extra)
+{
+ (void)basic;
+
+ if (fstree_add_hard_link(fs, path, extra) == NULL) {
+ fprintf(stderr, "%s: " PRI_SZ ": %s\n",
+ filename, line_num, strerror(errno));
+ return -1;
+ }
+ return 0;
+}
+
static const struct {
const char *keyword;
unsigned int mode;
@@ -71,6 +84,7 @@ static const struct {
} file_list_hooks[] = {
{ "dir", S_IFDIR, false, add_generic },
{ "slink", S_IFLNK, true, add_generic },
+ { "link", 0, true, add_hard_link },
{ "nod", 0, true, add_device },
{ "pipe", S_IFIFO, false, add_generic },
{ "sock", S_IFSOCK, false, add_generic },
diff --git a/lib/tar/read_header.c b/lib/tar/read_header.c
index 7d209ae..f82f9a5 100644
--- a/lib/tar/read_header.c
+++ b/lib/tar/read_header.c
@@ -345,8 +345,7 @@ static int decode_header(const tar_header_t *hdr, unsigned int set_by_pax,
out->sb.st_mode |= S_IFREG;
break;
case TAR_TYPE_LINK:
- /* XXX: hard links are not support yet */
- out->sb.st_mode = S_IFLNK | 0777;
+ out->is_hard_link = true;
break;
case TAR_TYPE_SLINK:
out->sb.st_mode = S_IFLNK | 0777;