bug-tar
[Top][All Lists]
Advanced

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

Re: [Bug-tar] TAR creates hard links or duplicated files in side archive


From: Marek Kielar
Subject: Re: [Bug-tar] TAR creates hard links or duplicated files in side archive when using -T option
Date: Wed, 07 Nov 2012 15:21:49 +0100



Dnia 5 listopada 2012 23:36 Paul Eggert <address@hidden> napisaƂ(a):

> On 11/05/2012 02:07 PM, Marek Kielar wrote:
> 
> > I would expect a hard link to be included only when the
> > same file was listed again but through an additional hard
> > link with some other name, and that also included only
> > once, if given multiple times on the command line.
> 
> I've read that sentence two or three times, and I'm
> afraid I still don't know what it means.  Which sort
> of underscores that we're in a tricky area here.
> 
> If I understand you correctly, one objection to your
> approach is that it's not trivial to determine whether
> a file is "an additional hard link with some other
> name".  For example, after "mkdir d; touch f; ln f d/f; ln
> -s . dot", the file names "dot/f" and "f" name the same hard
> link, whereas the file names "d/f" and "f" name different
> hard links, but this cannot be determined merely by invoking
> lstat on "d/f", "f", and "dot/f".
> 

The word "name" was a slip of a mind, I was thinking about an absolute path 
(through the hard link) to a file in the virtual file system of the archive. 
Thus, rewriting the paragraph:

I would expect a hard link to be included only when the same file was listed 
again but through a hard link with some other ABSOLUTE PATH, and that also 
included only once, if given multiple times on the command line.

That is, I would expect:

$ touch f
$ mkdir d
$ ln f d/f
$ mkdir dot
$ ln -s f dot/f
$ gtar -cf t.tar f f d/f d d/f dot/f dot/f
gtar: f: already added to archive, skipping
gtar: d/f: already added to archive, skipping
gtar: d/f: already added to archive. skipping
gtar: dot/f: already added to archive, skipping
$ gtar -tvf t.tar
-rw-rw-r-- user/group         0 2012-11-07 13:38 f
hrw-rw-r-- user/group         0 2012-11-07 13:38 d/f link to f
drwxrwxr-x user/group         0 2012-11-07 13:42 d/
lrwxrwxrwx user/group         0 2012-11-07 13:50 dot/f -> f

I don't think it is a very sophisticated idea, but surely wouldn't call trivial 
implementing it from scratch as it most probably calls for keeping a tree or a 
list of this virtual file system in memory to verify whether a specified hard 
link was already included in the archive. Though, as I see, GNU tar already 
verifies that the file is already in the archive and then makes a new hard link 
when this happens.

Best regards,
Marek Kielar




reply via email to

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