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
  • 650
  • 12
  • 23

1 Answers1

1

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,406
  • 3
  • 23
  • 30