bug-tar
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: tar is creating corrupt archives when soft links are present


From: Martin Simmons
Subject: Re: tar is creating corrupt archives when soft links are present
Date: Sat, 03 Dec 2022 17:00:51 +0000

>>>>> On Thu, 1 Dec 2022 16:14:42 -0500, Timothe Litt said:
> 
> The hard link problem reproduces with this (note the two soft links turning 
> into a soft and a hard(!) - according to tar:
> 
> # ( cd / && ls -li bin/awk bin/bash && tar -cf - bin/awk bin/bash | tar -tvf 
> - )
> 22683669 lrwxrwxrwx 1 root root  4 Nov 28 08:45 bin/awk -> gawk
> 22683657 lrwxrwxrwx 1 root root 21 Nov 28 08:45 bin/bash -> 
> ../usr/local/bin/bash
> lrwxrwxrwx root/root         0 2022-11-29 14:37 bin/awk -> gawk
> hrwxrwxrwx root/root         0 2022-11-29 14:37 bin/bash link to bin/awk
> 
> Clearly, the bin/bash (a) is not a hard link on disk, and (b) does not link 
> to bin/awk.

The timestamps also differ.

Maybe your tar is miscompiled (e.g. mixing different versions of the
stat structure)?

If you can recompile it, then you could try adding the patch below to
make it print more info when creating the tar file.

------------------------------------------------------------------------------
--- src/create.c        2021-02-04 14:00:33.000000000 +0000
+++ src/create.c        2022-12-03 16:28:08.469456354 +0000
@@ -1471,6 +1471,11 @@
 static bool
 dump_hard_link (struct tar_stat_info *st)
 {
+  fprintf (stdlis, "%s %llu %llu %llu\n",
+          st->file_name,
+          (unsigned long long)st->stat.st_nlink,
+          (unsigned long long)st->stat.st_ino,
+          (unsigned long long)st->stat.st_dev);
   if (link_table
       && (trivial_link_count < st->stat.st_nlink || remove_files_option))
     {
------------------------------------------------------------------------------

Then run it with:

( cd / && stat bin/awk bin/bash && tar -cf - bin/awk bin/bash | tar -tvf - )

__Martin



reply via email to

[Prev in Thread] Current Thread [Next in Thread]