GNU bug report logs - #20775
cp: improve hardlink dups handling with "cp -a -u"

Previous Next

Package: coreutils;

Reported by: Steffen Zahn <steffzahn <at> gmail.com>

Date: Tue, 9 Jun 2015 04:35:03 UTC

Severity: wishlist

To reply to this bug, email your comments to 20775 AT debbugs.gnu.org.

Toggle the display of automated, internal messages from the tracker.

View this report as an mbox folder, status mbox, maintainer mbox


Report forwarded to bug-coreutils <at> gnu.org:
bug#20775; Package coreutils. (Tue, 09 Jun 2015 04:35:03 GMT) Full text and rfc822 format available.

Acknowledgement sent to Steffen Zahn <steffzahn <at> gmail.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Tue, 09 Jun 2015 04:35:04 GMT) Full text and rfc822 format available.

Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):

From: Steffen Zahn <steffzahn <at> gmail.com>
To: bug-coreutils <at> gnu.org
Subject: cp -a -u destroys files after they are copied
Date: Tue, 09 Jun 2015 04:18:34 +0000
[Message part 1 (text/plain, inline)]
Hello,

I found that the cp command acts "sub-optimal" when copying hard-linked
files of the same name from several directories to one target directory, it
first copies the files then removes them. I cannot see how that can be the
intended behaviour. Please fix this.

best regards
     Steffen Zahn

sz <at> gandalf:~ $ cd /tmp
sz <at> gandalf:/tmp $ mkdir 1 2 3
sz <at> gandalf:/tmp $ touch 1/a
sz <at> gandalf:/tmp $ ln 1/a 2/
sz <at> gandalf:/tmp $ ls -li 1 2
1:
total 0
262424 -rw-r--r-- 2 sz sz 0 Jun  9 06:10 a

2:
total 0
262424 -rw-r--r-- 2 sz sz 0 Jun  9 06:10 a
sz <at> gandalf:/tmp $ cp -a -u --verbose 1/* 2/* 3/
'1/a' -> '3/a'
removed '3/a'
cp: cannot create hard link '3/a' to '3/a': No such file or directory
sz <at> gandalf:/tmp $ cp --version
cp (GNU coreutils) 8.21
Copyright (C) 2013 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html
>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Written by Torbjorn Granlund, David MacKenzie, and Jim Meyering.
sz <at> gandalf:/tmp $ ls -la 3/
total 8
drwxr-xr-x  2 sz   sz   4096 Jun  9 06:11 .
drwxrwxrwt 13 root root 4096 Jun  9 06:11 ..
sz <at> gandalf:/tmp $ uname -a
Linux gandalf 3.13.0-24-generic #47-Ubuntu SMP Fri May 2 23:30:00 UTC 2014
x86_64 x86_64 x86_64 GNU/Linux
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#20775; Package coreutils. (Tue, 30 Jun 2015 07:04:02 GMT) Full text and rfc822 format available.

Message #8 received at 20775 <at> debbugs.gnu.org (full text, mbox):

From: "L. A. Walsh" <coreutils <at> tlinx.org>
To: Steffen Zahn <steffzahn <at> gmail.com>, 20775 <at> debbugs.gnu.org,
 10471 <at> debbugs.gnu.org
Subject: Re: bug#20775: cp -a -u destroys files after they are copied
Date: Tue, 30 Jun 2015 00:02:51 -0700
I think you'll find this was reported 3 years ago..

    "bug#10471: Severe or critical - deletes existing files and leaves 
nothing. (cp)"
https://lists.gnu.org/archive/html/bug-coreutils/2015-04/msg00001.html

Unfortunately it was closed it out w/the reason that  it was a 
"cygwin/windows-only"
-- which I disagreed with.  I was told the cygwin dev would check it out and
if it was in coreutils would move it back to active status (that was 3+ 
years ago).

On 6/8/2015 9:18 PM, Steffen Zahn wrote:
> Hello,
>
> I found that the cp command acts "sub-optimal" when copying 
> hard-linked files of the same name from several directories to one 
> target directory, it first copies the files then removes them. I 
> cannot see how that can be the intended behaviour. Please fix this.
>
> best regards
>      Steffen Zahn
>
> sz <at> gandalf:~ $ cd /tmp
> sz <at> gandalf:/tmp $ mkdir 1 2 3
> sz <at> gandalf:/tmp $ touch 1/a
> sz <at> gandalf:/tmp $ ln 1/a 2/
> sz <at> gandalf:/tmp $ ls -li 1 2
> 1:
> total 0
> 262424 -rw-r--r-- 2 sz sz 0 Jun  9 06:10 a
>
> 2:
> total 0
> 262424 -rw-r--r-- 2 sz sz 0 Jun  9 06:10 a
> sz <at> gandalf:/tmp $ cp -a -u --verbose 1/* 2/* 3/
> '1/a' -> '3/a'
> removed '3/a'
> cp: cannot create hard link '3/a' to '3/a': No such file or directory
> sz <at> gandalf:/tmp $ cp --version
>





Information forwarded to bug-coreutils <at> gnu.org:
bug#20775; Package coreutils. (Tue, 30 Jun 2015 08:36:04 GMT) Full text and rfc822 format available.

Message #11 received at 20775 <at> debbugs.gnu.org (full text, mbox):

From: Steffen Zahn <steffzahn <at> gmail.com>
To: "L. A. Walsh" <coreutils <at> tlinx.org>, 20775 <at> debbugs.gnu.org,
 10471 <at> debbugs.gnu.org
Subject: Re: bug#20775: cp -a -u destroys files after they are copied
Date: Tue, 30 Jun 2015 08:35:36 +0000
[Message part 1 (text/plain, inline)]
Hello,

the bug was observed on Linux this time. Unfortunately I was hit with the
bug when backing up several large photo directories with hard-links to one
target directory on an external drive. So it was not obvious for me at
first, that something was going wrong.

From my point of view (without looking at the source) it should be easy to
repair by

- not attempting to create a hard-link from a file to itself
- not deleting a file that is about to be used as the source paramter of a
hard-link to be created.


best regards
  Steffen Zahn



On Tue, Jun 30, 2015 at 9:02 AM L. A. Walsh <coreutils <at> tlinx.org> wrote:

> I think you'll find this was reported 3 years ago..
>
>      "bug#10471: Severe or critical - deletes existing files and leaves
> nothing. (cp)"
> https://lists.gnu.org/archive/html/bug-coreutils/2015-04/msg00001.html
>
> Unfortunately it was closed it out w/the reason that  it was a
> "cygwin/windows-only"
> -- which I disagreed with.  I was told the cygwin dev would check it out
> and
> if it was in coreutils would move it back to active status (that was 3+
> years ago).
>
> On 6/8/2015 9:18 PM, Steffen Zahn wrote:
> > Hello,
> >
> > I found that the cp command acts "sub-optimal" when copying
> > hard-linked files of the same name from several directories to one
> > target directory, it first copies the files then removes them. I
> > cannot see how that can be the intended behaviour. Please fix this.
> >
> > best regards
> >      Steffen Zahn
> >
> > sz <at> gandalf:~ $ cd /tmp
> > sz <at> gandalf:/tmp $ mkdir 1 2 3
> > sz <at> gandalf:/tmp $ touch 1/a
> > sz <at> gandalf:/tmp $ ln 1/a 2/
> > sz <at> gandalf:/tmp $ ls -li 1 2
> > 1:
> > total 0
> > 262424 -rw-r--r-- 2 sz sz 0 Jun  9 06:10 a
> >
> > 2:
> > total 0
> > 262424 -rw-r--r-- 2 sz sz 0 Jun  9 06:10 a
> > sz <at> gandalf:/tmp $ cp -a -u --verbose 1/* 2/* 3/
> > '1/a' -> '3/a'
> > removed '3/a'
> > cp: cannot create hard link '3/a' to '3/a': No such file or directory
> > sz <at> gandalf:/tmp $ cp --version
> >
>
>
[Message part 2 (text/html, inline)]

Information forwarded to bug-coreutils <at> gnu.org:
bug#20775; Package coreutils. (Tue, 30 Jun 2015 16:12:03 GMT) Full text and rfc822 format available.

Message #14 received at 20775 <at> debbugs.gnu.org (full text, mbox):

From: Paul Eggert <eggert <at> cs.ucla.edu>
To: Steffen Zahn <steffzahn <at> gmail.com>, "L. A. Walsh" <coreutils <at> tlinx.org>,
 20775 <at> debbugs.gnu.org, 10471 <at> debbugs.gnu.org
Subject: Re: bug#20775: cp -a -u destroys files after they are copied
Date: Tue, 30 Jun 2015 09:10:52 -0700
Steffen Zahn wrote:
> it should be easy to repair

Really?  Without significantly affecting performance in the usual case?  Let's 
see a patch.




Information forwarded to bug-coreutils <at> gnu.org:
bug#20775; Package coreutils. (Fri, 11 Jan 2019 08:54:01 GMT) Full text and rfc822 format available.

Message #17 received at 20775 <at> debbugs.gnu.org (full text, mbox):

From: Assaf Gordon <assafgordon <at> gmail.com>
To: Steffen Zahn <steffzahn <at> gmail.com>, 20775 <at> debbugs.gnu.org
Subject: Re: bug#20775: cp -a -u destroys files after they are copied
Date: Fri, 11 Jan 2019 01:53:27 -0700
severity 20775 wishlist
retitle 20775 cp: improve hardlink dups handling with "cp -a -u"
stop

With no further comments in more than 3 years,
I'm marking this as a "wish list" item.

-assaf




Severity set to 'wishlist' from 'normal' Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 11 Jan 2019 08:54:02 GMT) Full text and rfc822 format available.

Changed bug title to 'cp: improve hardlink dups handling with "cp -a -u"' from 'cp -a -u destroys files after they are copied' Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 11 Jan 2019 08:54:02 GMT) Full text and rfc822 format available.

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

Previous Next


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