GNU bug report logs - #14618
cp: erroneous sparse copy command results in empty file

Previous Next

Package: coreutils;

Reported by: Koen De Wit <koen.de.wit <at> oracle.com>

Date: Fri, 14 Jun 2013 16:00:03 UTC

Severity: normal

Done: Assaf Gordon <assafgordon <at> gmail.com>

Bug is archived. No further changes may be made.

To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 14618 in the body.
You can then email your comments to 14618 AT debbugs.gnu.org in the normal way.

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#14618; Package coreutils. (Fri, 14 Jun 2013 16:00:05 GMT) Full text and rfc822 format available.

Acknowledgement sent to Koen De Wit <koen.de.wit <at> oracle.com>:
New bug report received and forwarded. Copy sent to bug-coreutils <at> gnu.org. (Fri, 14 Jun 2013 16:00:06 GMT) Full text and rfc822 format available.

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

From: Koen De Wit <koen.de.wit <at> oracle.com>
To: bug-coreutils <at> gnu.org
Subject: Erroneous sparse copy command results in empty file
Date: Fri, 14 Jun 2013 13:35:59 +0200
When trying to create a sparse copy of a file on a different filesystem 
you get an "Invalid cross-device link" error, as expected. However, an 
empty file is created instead of the sparse copy:

# mkfs.btrfs -f /dev/sde1
# mkfs.btrfs -f /dev/sde2
# mount /dev/sde1 /mnt/part1
# mount /dev/sde2 /mnt/part2
# echo "abc" > /mnt/part1/testfile
# ./cp --reflink /mnt/part1/testfile /mnt/part2/testcopy
./cp: failed to clone ‘/mnt/part2/testcopy’ from ‘/mnt/part1/testfile’: 
Invalid cross-device link
# ls -la /mnt/part1/testfile
-rw-r--r--. 1 root root 4 Jun 14 14:49 /mnt/part1/testfile
# ls -la /mnt/part2/testcopy
-rw-r--r--. 1 root root 0 Jun 14 14:49 /mnt/part2/testcopy

The same occurs when trying to create a sparse copy on a filesystem that 
does not support sparse copies:

# mkfs.ext3 /dev/sde1
# mount /dev/sde1 /mnt/part1
# echo "abc" > /mnt/part1/testfile
# ./cp --reflink /mnt/part1/testfile /mnt/part1/testcopy
./cp: failed to clone ‘/mnt/part1/testcopy’ from ‘/mnt/part1/testfile’: 
Inappropriate ioctl for device
# ls -la /mnt/part1
(...)
-rw-r--r--. 1 root root 0 Jun 14 14:58 testcopy
-rw-r--r--. 1 root root 4 Jun 14 14:58 testfile

If creating a sparse copy fails, no file should be created.

ln treats this error in the right way:

# ln /mnt/part1/testfile /mnt/part2/testlink
ln: creating hard link `/mnt/part2/testlink' => `/mnt/part1/testfile': 
Invalid cross-device link
# ls -la /mnt/part2/testlink
ls: cannot access /mnt/part2/testlink: No such file or directory

Tested with coreutils today's git HEAD and kernel 3.9.5.




Information forwarded to bug-coreutils <at> gnu.org:
bug#14618; Package coreutils. (Fri, 14 Jun 2013 20:04:01 GMT) Full text and rfc822 format available.

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

From: Pádraig Brady <P <at> draigBrady.com>
To: Koen De Wit <koen.de.wit <at> oracle.com>
Cc: 14618 <at> debbugs.gnu.org
Subject: Re: bug#14618: Erroneous sparse copy command results in empty file
Date: Fri, 14 Jun 2013 21:03:52 +0100
On 06/14/2013 12:35 PM, Koen De Wit wrote:
> When trying to create a sparse copy of a file on a different filesystem you get an "Invalid cross-device link" error, as expected. However, an empty file is created instead of the sparse copy:

As a side note, sparse copying is a separate thing to reflinking.

> # mkfs.btrfs -f /dev/sde1
> # mkfs.btrfs -f /dev/sde2
> # mount /dev/sde1 /mnt/part1
> # mount /dev/sde2 /mnt/part2
> # echo "abc" > /mnt/part1/testfile
> # ./cp --reflink /mnt/part1/testfile /mnt/part2/testcopy
> ./cp: failed to clone ‘/mnt/part2/testcopy’ from ‘/mnt/part1/testfile’: Invalid cross-device link
> # ls -la /mnt/part1/testfile
> -rw-r--r--. 1 root root 4 Jun 14 14:49 /mnt/part1/testfile
> # ls -la /mnt/part2/testcopy
> -rw-r--r--. 1 root root 0 Jun 14 14:49 /mnt/part2/testcopy
> 
> The same occurs when trying to create a sparse copy on a filesystem that does not support sparse copies:
> 
> # mkfs.ext3 /dev/sde1
> # mount /dev/sde1 /mnt/part1
> # echo "abc" > /mnt/part1/testfile
> # ./cp --reflink /mnt/part1/testfile /mnt/part1/testcopy
> ./cp: failed to clone ‘/mnt/part1/testcopy’ from ‘/mnt/part1/testfile’: Inappropriate ioctl for device
> # ls -la /mnt/part1
> (...)
> -rw-r--r--. 1 root root 0 Jun 14 14:58 testcopy
> -rw-r--r--. 1 root root 4 Jun 14 14:58 testfile
> 
> If creating a sparse copy fails, no file should be created.
> 
> ln treats this error in the right way:
> 
> # ln /mnt/part1/testfile /mnt/part2/testlink
> ln: creating hard link `/mnt/part2/testlink' => `/mnt/part1/testfile': Invalid cross-device link
> # ls -la /mnt/part2/testlink
> ls: cannot access /mnt/part2/testlink: No such file or directory
> 
> Tested with coreutils today's git HEAD and kernel 3.9.5.

This was discussed previously:
http://lists.gnu.org/archive/html/coreutils/2013-03/msg00056.html
Summary of that is that it may be best handled outside of cp.

cheers,
Pádraig.




Information forwarded to bug-coreutils <at> gnu.org:
bug#14618; Package coreutils. (Fri, 19 Oct 2018 16:51:01 GMT) Full text and rfc822 format available.

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

From: Assaf Gordon <assafgordon <at> gmail.com>
To: 14618 <at> debbugs.gnu.org
Subject: Re: bug#14618: Erroneous sparse copy command results in empty file
Date: Fri, 19 Oct 2018 10:50:24 -0600
retitle 14618 cp: erroneous sparse copy command results in empty file
close 14618
stop

(triaging old bugs)


On 14/06/13 02:03 PM, Pádraig Brady wrote:
> On 06/14/2013 12:35 PM, Koen De Wit wrote:
>> When trying to create a sparse copy of a file on a different filesystem you get an "Invalid cross-device link" error, as expected. However, an empty file is created instead of the sparse copy:
> 
> This was discussed previously:
> http://lists.gnu.org/archive/html/coreutils/2013-03/msg00056.html
> Summary of that is that it may be best handled outside of cp.

With no further follow-ups in 5 years, I'm closing this bug.

-assaf




Changed bug title to 'cp: erroneous sparse copy command results in empty file' from 'Erroneous sparse copy command results in empty file' Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 19 Oct 2018 16:51:02 GMT) Full text and rfc822 format available.

bug closed, send any further explanations to 14618 <at> debbugs.gnu.org and Koen De Wit <koen.de.wit <at> oracle.com> Request was from Assaf Gordon <assafgordon <at> gmail.com> to control <at> debbugs.gnu.org. (Fri, 19 Oct 2018 16:51:02 GMT) Full text and rfc822 format available.

bug archived. Request was from Debbugs Internal Request <help-debbugs <at> gnu.org> to internal_control <at> debbugs.gnu.org. (Sat, 17 Nov 2018 12:24:04 GMT) Full text and rfc822 format available.

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

Previous Next


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