btrfs/029: fix the test compatible with older cp(1)
authorAnand Jain <anand.jain@oracle.com>
Fri, 4 Jun 2021 06:25:47 +0000 (14:25 +0800)
committerEryu Guan <guaneryu@gmail.com>
Sun, 6 Jun 2021 13:13:39 +0000 (21:13 +0800)
commitffc8893a6687ec0490fd178c6b756ddec364ec24
tree416d8a6a31941f15dbbfed692cff1912615bdc3b
parent37881397f1aa62df3c63468049c80b301b0e89eb
btrfs/029: fix the test compatible with older cp(1)

cp(1) versions 8.30 and 8.32 are compared with its --reflink=always option
and they have different semantic if the target-file (with zero sizes) must be
created when the cp --reflink=alaways fails with a cross-device link
error. As shown below.

$ cp --version | head -1
cp (GNU coreutils) 8.30

$ cp --reflink=always /mnt/scratch/original /mnt/test/test-029/copy
cp: failed to clone '/mnt/test/test-029/copy' from '/mnt/scratch/original': Invalid cross-device link

$ ls -l /mnt/test/test-029/copy
ls: cannot access '/mnt/test/test-029/copy': No such file or directory

$ cp --version | head -1
cp (GNU coreutils) 8.32

$ cp --reflink=always /mnt/scratch/original /mnt/test/test-029/copy;
cp: failed to clone '/mnt/test/test-029/copy' from '/mnt/scratch/original': Invalid cross-device link

$ ls -l /mnt/test/test-029/copy
-rw------- 1 root root 0 Jun  4 13:29 /mnt/test/test-029/copy

Reported-by: Wang Yugui <wangyugui@e16-tech.com>
Signed-off-by: Anand Jain <anand.jain@oracle.com>
Reviewed-by: Eryu Guan <guaneryu@gmail.com>
Signed-off-by: Eryu Guan <guaneryu@gmail.com>
tests/btrfs/029
tests/btrfs/029.out