[Bug 2755] New: Copy (cp) command handles hard links incorrectly

bugzilla at busybox.net bugzilla at busybox.net
Fri Oct 29 12:57:13 UTC 2010


           Summary: Copy (cp) command handles hard links incorrectly
           Product: Busybox
           Version: 1.14.x
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Severity: major
          Priority: P5
         Component: Standard Compliance
        AssignedTo: unassigned at busybox.net
        ReportedBy: nhathaway at ubiquisys.com
                CC: busybox-cvs at busybox.net
   Estimated Hours: 0.0

We did the following tests on Ubuntu 9.10 (non-BusyBox) Centos 5.4
(non-BusyBox) and BusyBox 1.14.1 compiled from source:

mkdir dir1
echo "Hello" > dir1/file1
ln dir1/file1 dir1/file2
stat dir1/*
cp -r dir1 dir2
stat dir2/*
cp -a dir1 dir3
stat dir3/*

On the two non-BusyBox systems, the first copy did NOT create hard links for
the two files whereas the second copy did.

On the BusyBox system, BOTH of them created hard links.

We have checked through existing bugs and it seems very likely that this is the
first reporting of this bug, and that it is still present in the latest
(1.17.3) version.

We looked at the source code in coreutils/cp.c and there is a comment as
follows (line 46 in 1.14.1 source):

    // -R (and therefore -r) turns on -d (coreutils does this)

We believe that this statement is in error and violates the standards. If it is
the GNU coreutils that are being referred to, then it is likely that this was a
bug fixed some time ago.

The upshot of this is that it is impossible to do reliable a recursive copy of
a cramfs file system using BusyBox cp (we had to do a work-around using
back-to-back tar for the time being). Cramfs, in order to save space
presumably, creates had links for files that have identical contents. We do an
update by copying the cramfs (from flash) to a temporary RAM directory,
updating the files, doing a mkcramfs and then saving back to flash. We had 2
identical files, one of which we changed, but both got changed unexpectedly.

Configure bugmail: https://bugs.busybox.net/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.

More information about the busybox-cvs mailing list