Subject: bug#8419: cp -au : New hard links in source becomes new files at destination when using cp -au

From: [email-masked]
Date: Mon, 4 Apr 2011 11:29:00 +0200

Hi

I have tried to use the command cp combining the -a and the -u options.
I had to stop the copying process midways and restarted it again, and to my
suprice the diskusage at the destination was 10 -20 % larger than the
diskusage at the source and my disks ran full even though the destination
disks was the same size as the source disks.

My disks contained rsync snapshot backup data so every inod had typically
15 hard links to it.
I found out that when I ran cp -au to update the target, cp -au creates new
files in the destination when there is a new hard link in the source to a
file already existing in the destination directory.
This is not the behaviour I expected.

I got the same behavior on:
SUSE Linux Enterprise Server 11 (x86_64)
and
Ubuntu 10.04

I have included a series of commands to:
    create a source directory with hard linked files,
    make folder target, and copy the directory to this folder
    add a new hard link in the source folder
    update the target folder with the command cp -au
    listing the directory contents of source and target to show that the
source contains 3 hard links to the same file, in the target directory
hardlink2 has become a separate identical file.

If you disagree with me that this is not the desired behaviour of cp -au,
please let me know why.
If you agree, I hope the behaviour of cp -au will change some time in the
future.

regards
Odd Harry Mannsverk

> mkdir source
> touch source/file1
> ln  source/file1 source/hardlink1
> mkdir target
> cp -a source target
> ln  source/file1 source/hardlink2
> cp -au source target
> ls -1iR source
source:
229418 file1
229418 hardlink1
229418 hardlink2
> ls -1iR target
target:
229414 source

target/source:
229415 file1
229415 hardlink1
229416 hardlink2