bug-coreutils
[Top][All Lists]
Advanced

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

bug#15173: [cp] --link overrides dereference settings


From: Pádraig Brady
Subject: bug#15173: [cp] --link overrides dereference settings
Date: Thu, 31 Oct 2013 12:12:55 +0000
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130110 Thunderbird/17.0.2

On 10/31/2013 02:07 AM, Bernhard Voelker wrote:
> On 10/30/2013 01:13 PM, Bernhard Voelker wrote:
>> Thanks again for looking into this.  It's really quite complex.
>> I'll come up with the test (old vs. new) cases soon.
> 
> Okay, here we go:
> 
> the attached patch is updated regarding the issues you mentioned.
> 
> I furthermore tweaked the NEWS entry:
> 
> * instead of just mentioning the --dereference option,
> mention both the -L and -H options explicitly.
> 
> * add a note that "cp -l dangling" and "cp -l symlink-to-dir"
> now create hard links as expected - cp doesn't try to dereference
> the src anymore which would lead to different error diagnostics
> in the two cases [*].
> 
> Then, I created a few test cases to check the changes in behaviour
> of cp-8.21 against the changed cp.  It runs various combinations of
> the options -l, -s, -R, -H, -L, -P and --preserve=links on symlinks
> to a file ('filelink'), to a directory ('dirlink') and on a dangling
> symlink ('danglink').
> The script is already ugly enough, so I omitted checking the
> files, dir and links in the subdirectory for changes.
> The changes so far - 12 out of 144 - are:
> 
>   $ grep "DIFFERENCE in Test: " testit.log | sed 's/^.*: //'
>   cp -L -l   filelink ...
>   cp -L -l  --preserve=links filelink ...
>   cp -L -l -R  filelink ...
>   cp -L -l -R --preserve=links filelink ...
>   cp -H -l   filelink ...
>   cp -H -l  --preserve=links filelink ...
>   cp -H -l -R  filelink ...
>   cp -H -l -R --preserve=links filelink ...

So -HL are now honored in this regard

>   cp  -l   dirlink ...
>   cp  -l  --preserve=links dirlink ...
>   cp  -l   danglink ...
>   cp  -l  --preserve=links danglink ...

and by default we don't deref the above.

That all seems consistent with expectations and what we previously discussed.

But...

I've just now read POSIX for cp, and it states:

 "If the -R option was not specified, cp shall take actions based on the type
  and contents of the file referenced by the symbolic link, and not by the
  symbolic link itself, unless the -P option was specified."

This suggests that -HL should only be significant with -R ?
That is a bit surprising TBH. What do you think Eric?

It also suggests that we should hardlink to a symlink only with -P,
i.e. that we should AT_SYMLINK_FOLLOW unless -P is specified ?
That's also a bit surprising, given that POSIX for ln states
that it's implementation defined what's done if neither -P or -L is specified.
I wouldn't be inclined to follow POSIX in that regard.

Also worth comparing is --symbolic-link, which seems closer to POSIX in this 
regard.
--symbolic-link does need -P to be able to reference dangling links
even though the target of the created symlink is the source symlink rather than 
its target.
Should we remove the -P requirement to symlink dangling links
as is the case for --link above.

thanks,
Pádraig.





reply via email to

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