GNU bug report logs - #15173
[cp] --link overrides dereference settings

Previous Next

Package: coreutils;

Reported by: Gian Piero Carrubba <gpiero <at> rm-rf.it>

Date: Fri, 23 Aug 2013 21:55:02 UTC

Severity: normal

Tags: fixed

Merged with 23120

Done: Bernhard Voelker <mail <at> bernhard-voelker.de>

Bug is archived. No further changes may be made.

Full log


View this message in rfc822 format

From: Bernhard Voelker <mail <at> bernhard-voelker.de>
To: Pádraig Brady <P <at> draigBrady.com>
Cc: Gian Piero Carrubba <gpiero <at> rm-rf.it>, Eric Blake <eblake <at> redhat.com>, 15173 <at> debbugs.gnu.org
Subject: bug#15173: [cp] --link overrides dereference settings
Date: Tue, 05 Nov 2013 00:02:47 +0100
[Message part 1 (text/plain, inline)]
On 11/04/2013 10:37 AM, Pádraig Brady wrote:
> On 11/04/2013 12:48 AM, Bernhard Voelker wrote:
>> It got late again. I'll have a look tomorrow again - maybe there
>> are no side effects with the following:
>>
>> diff --git a/src/cp.c b/src/cp.c
>> index 7bc8630..78c0a04 100644
>> --- a/src/cp.c
>> +++ b/src/cp.c
>> @@ -1135,7 +1135,7 @@ main (int argc, char **argv)
>>
>>    if (x.dereference == DEREF_UNDEFINED)
>>      {
>> -      if (x.recursive)
>> +      if (x.recursive && ! x.hard_link)
>>          /* This is compatible with FreeBSD.  */
>>          x.dereference = DEREF_NEVER;
>>        else
> 
> Yes I didn't consider -R in the table as I don't see any reason
> for it to behave differently when -l is specified (and -l aplies
> neither to POSIX or BSD (comment)).  So the above adjustment
> looks correct to me.

Indeed, that adjustment seems to be the right one - finally. ;-)
I have added it to the patch as well as a new test case. I've added
a "Co-authored-by:"-me line for that.

@Gian: please note that we use "double-blank after-dot" format in
comments. I've fixed that for you.

The patch passes make check and syntax-check.

I've also attached the test result cp-8.21 versus the new one.
These are the differences (I leave out the --preserve=links cases
as these are also affected but unrelated):

COMMAND                   | 8.21 | NEW
cp  -l   filelink ...     |  S   |  T
cp  -l -R  filelink ...   |  S   |  T
cp -L -l   filelink ...   |  S   |  T
cp -L -l -R  filelink ... |  S   |  T
cp -H -l   filelink ...   |  S   |  T
cp -H -l -R  filelink ... |  S   |  T
cp  -l -R  dirlink ...    |  S   |  NDH
cp  -l -R  danglink ...   |  S   |  ERR_DEREF

  NDH = New directory with hard links below
  S = hard link to symlink
  T = hard link to symlink target
  ERR_DEREF = failure because dereferencing fails

Now, the dereferencing behavior of cp --link is not related to -R anymore.
I hope we don't introduce a regression ...

Comments?

Have a nice day,
Berny
[cp--link--deref-v3.patch (text/x-patch, attachment)]
[testit.log.xz (application/x-xz, attachment)]

This bug report was last modified 6 years and 207 days ago.

Previous Next


GNU bug tracking system
Copyright (C) 1999 Darren O. Benham, 1997,2003 nCipher Corporation Ltd, 1994-97 Ian Jackson.