bug#14618: Erroneous sparse copy command results in empty file
From:
Koen De Wit
Subject:
bug#14618: Erroneous sparse copy command results in empty file
Date:
Fri, 14 Jun 2013 13:35:59 +0200
User-agent:
Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.1.16) Gecko/20111110 Icedove/3.0.11
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:
./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.