0

When I copy a file using reflink option, e.g.,

cp --reflink foo bar

how and what stage in execution of cp determines if the underneath file system supports COW. I tried looking into coreutils/src/cp.c but couldn't find the specific system call/ ioctl or any other method which determines COW capability and accordingly proceeds for cp execution / reports error:

cp: failed to clone 'bar' from 'foo': Bad address

In short, I am looking for how resolution of --reflink=auto option happens.

Vishal Sahu
  • 600
  • 10
  • 20

1 Answers1

0

BTRFS_IOC_CLONE or FICLONE are the ioctl request codes tried by cp. The former is for BTRFS reflinks while The latter got introduced when XFS gained [1] reflink support. You can strace the cp command to see what is happening in the version that you have.

[1] http://lwn.net/Articles/702633/

itisravi
  • 3,256
  • 3
  • 22
  • 29