bug-tar
[Top][All Lists]
Advanced

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

Re: [Bug-tar] tar behaviour concerning overwriting of symlinks to target


From: Matthias Koenig
Subject: Re: [Bug-tar] tar behaviour concerning overwriting of symlinks to target directories
Date: Tue, 17 Apr 2007 15:32:46 +0200
User-agent: Gnus/5.110006 (No Gnus v0.6) Emacs/21.3 (gnu/linux)

Jean-Louis Martineau <address@hidden> writes:

> Paul Eggert wrote:
>> Matthias Koenig <address@hidden> writes:
>>
>>
>>> Is this behaviour correct? The documentation isn't that clear about
>>> overwriting of links to a target directory.
>>>
>>
>> I think it's correct, since "--no-overwrite-dir" is supposed
>> to keep the metadata of existing directories, and this includes
>> keeping whether the existing directory is actually a symlink to
>> a directory.
>>
>
> It's not the reverse that is done?

Hmm, as far as I understand it, it is referring to the metadata of the 
directory in the archive. Interpreting it like this then makes
sense.

> With "--no-overwrite-dir", the existing symlink is erased and a new
> directory is created.
> Without "--no-overwrite-dir", the symlink is kept and followed.

This option keeps the metadata, i.e. since  it is a directory in the 
archive, the link has to be deleteted and a directory created when 
extracting.

> Without "--no-overwrite-dir", the symlink is kept and followed.

Omitting the option does not keep the metadata of directories, so it does
not matter that the existing directory is actually a link.

>> The documentation could be clearer though; perhaps you could suggest
>> an improvement?

In section 4.4.2 (Dealing with old files) is stated:
"When extracting files, if `tar' discovers that the extracted file
already exists, it normally replaces the file by removing it before
extracting it, to prevent confusion in the presence of hard or symbolic
links.  (If the existing file is a symbolic link, it is removed, not
followed.) However, if a directory cannot be removed because it is
nonempty, `tar' normally overwrites its metadata (ownership,
permission, etc.).  The `--overwrite-dir' option enables this default
behavior.  To be more cautious and preserve the metadata of such a
directory, use the `--no-overwrite-dir' option."

In section 2.8.3 is stated:
"Extracting directories which are members of an archive is similar to
extracting other files.  The main difference to be aware of is that if
the extracted directory has the same name as any directory already in
the working directory, then files in the extracted directory will be
placed into the directory of the same name."

It is hard to understand what happens to an existing symlink to a 
directory with the same name as a directory in the archive.
Does a link to a directory fit to the exceptional rule of 2.8.3
(files will be extracted into the existing directory)?
Or to the rule in 4.4.2 (symbolic links are removed).

Maybe there should be an additional sentence in section 4.4.2,
appended after the first paragraph:

"... To be more cautious and preserve the metadata of such a directory, 
use the `--no-overwrite-dir' option. (This option will also overwrite an 
existing symbolic link pointing to a directory, with the link having the 
same name as a directory in the archive. The default is to follow the 
symbolic link to a directory.)"

Matthias





reply via email to

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