bug-tar
[Top][All Lists]
Advanced

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

Re: [Bug-tar] Bug with files which have hardlinks


From: Bob Proulx
Subject: Re: [Bug-tar] Bug with files which have hardlinks
Date: Sat, 9 Oct 2010 01:19:41 -0600
User-agent: Mutt/1.5.20 (2009-06-14)

Paul Eggert wrote:
> Thomas Graf wrote:
> > touch afile
> > link afile hlink
> > gtar -cvvf x.tar afile afile afile
> > -rw-r--r-- tom/users         0 2010-10-08 01:49 afile
> > hrw-r--r-- tom/users         0 2010-10-08 01:49 afile link to afile
> > hrw-r--r-- tom/users         0 2010-10-08 01:49 afile link to afile
> 
> I don't see a bug there.  You asked "tar" to archive the same file
> three times, and it did.
> 
> Solaris 10 /bin/tar behaves the same way.

That does seem odd to me.  Compare these two cases:

  $ date -R > afile
  $ ls -l afile
  -rw-rw-r-- 1 bob bob 32 2010-10-09 01:07 afile
  $ tar cvvf x.tar afile afile afile
  -rw-rw-r-- bob/bob          32 2010-10-09 01:07 afile
  -rw-rw-r-- bob/bob          32 2010-10-09 01:07 afile
  -rw-rw-r-- bob/bob          32 2010-10-09 01:07 afile

All three copies of the file are in the archive.  Now let's add a hard
link to the file.

  $ ln afile hlink
  $ ls -l afile
  -rw-rw-r-- 2 bob bob 32 2010-10-09 01:07 afile

Then try the tar archive creation again.

  $ tar cvvf x.tar afile afile afile
  -rw-rw-r-- bob/bob          32 2010-10-09 01:07 afile
  hrw-rw-r-- bob/bob           0 2010-10-09 01:07 afile link to afile
  hrw-rw-r-- bob/bob           0 2010-10-09 01:07 afile link to afile

Why did having afile hardlinked to another file change the behavior of
tar?  Why did having afile's hardlink count greater than 1 cause tar
to think that afile was a hardlink to afile?  It is reporting it as
being a hard link to itself.  That doesn't look right.  Why didn't it
just archive the file again as it did in the first case?

Of course when untar'ing the archive the file is restored okay.  So
this seems like a completely academic question of why did tar behave
differently and show a cosmetic difference in behavior trace output.
As opposed to actually producing a result on disk which is incorrect.

Bob



reply via email to

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