--- Begin Message ---
Subject: |
cp -a --attributes-only zeroes a file with more than one link |
Date: |
Tue, 31 Mar 2020 14:32:13 +0200 |
Hello,
When you cp -a --attributes-only a file which has a more than one “hardlink”, it zeroes the file:
$ echo hello > aaa
$ cp aaa foo
$ chmod 777 aaa
$ ls -li
total 8
407584 -rwxrwxrwx 1 matt matt 6 mars 31 14:19 aaa
399313 -rw-r--r-- 1 matt matt 6 mars 31 14:19 foo
$ cp -a --attributes-only aaa foo # this is fine
$ ls -li
total 8
407584 -rwxrwxrwx 1 matt matt 6 mars 31 14:19 aaa
399313 -rwxrwxrwx 1 matt matt 6 mars 31 14:19 foo
$ ln foo foo2
$ cp -a --attributes-only aaa foo # here comes the bug
$ ls -li
total 8
407584 -rwxrwxrwx 1 matt matt 6 mars 31 14:19 aaa
407740 -rwxrwxrwx 1 matt matt 0 mars 31 14:19 foo
399313 -rwxrwxrwx 1 matt matt 6 mars 31 14:19 foo2
foo has a size of 0 bytes!
The user thinks he's replicating timestamp and permissions, and he's actually deleting data. (Well, the data is still in foo2, but...)
coreutils 8.30
Matt
--- End Message ---
--- Begin Message ---
Subject: |
Re: bug#40352: cp -a --attributes-only zeroes a file with more than one link |
Date: |
Wed, 1 Apr 2020 13:10:02 +0100 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:73.0) Gecko/20100101 Thunderbird/73.0 |
On 31/03/2020 13:32, Matt Kloss wrote:
Hello,
When you cp -a --attributes-only a [dest] file which has a more than one
“hardlink”, it zeroes the file:
The attached fixes this, which I'll push later.
Marking this as done.
thanks!
Pádraig
cp-a--attributes-only.patch
Description: Text Data
--- End Message ---