Fix handling of hard link targets by -c --transform

* src/create.c (file_count_links): Transform link target
before the look up.
* tests/xform-h.at: New test case.
* tests/Makefile.am (TESTSUITE_AT): Add xform-h.at.
* tests/testsuite.at: Add xform-h.at
This commit is contained in:
Sergey Poznyakoff
2009-07-30 11:43:16 +03:00
parent 01c4475b17
commit f74cab3a93
4 changed files with 74 additions and 5 deletions
+12 -5
View File
@@ -1427,19 +1427,26 @@ file_count_links (struct tar_stat_info *st)
if (st->stat.st_nlink > 1)
{
struct link *duplicate;
struct link *lp = xmalloc (offsetof (struct link, name)
+ strlen (st->orig_file_name) + 1);
char *linkname = NULL;
struct link *lp;
assign_string (&linkname, st->orig_file_name);
transform_name (&linkname, XFORM_LINK);
lp = xmalloc (offsetof (struct link, name)
+ strlen (linkname) + 1);
lp->ino = st->stat.st_ino;
lp->dev = st->stat.st_dev;
lp->nlink = st->stat.st_nlink;
strcpy (lp->name, st->orig_file_name);
strcpy (lp->name, linkname);
free (linkname);
if (! ((link_table
|| (link_table = hash_initialize (0, 0, hash_link,
compare_links, 0)))
&& (duplicate = hash_insert (link_table, lp))))
xalloc_die ();
if (duplicate != lp)
abort ();
lp->nlink--;