pub fn try_reflink(source: &Path, dest: &Path) -> Result<bool>Expand description
Try a filesystem-level reflink (copy-on-write clone) from source
to dest. On success the destination has its own inode and shares
physical blocks with the source until either side is modified.
On a successful reflink: returns Ok(true). The destination file
has been created with the kernel’s choice of permissions (typically
the source’s). Callers should set_permissions afterwards if they
need a specific mode.
On a “filesystem doesn’t support reflinks” verdict (EXDEV,
EOPNOTSUPP, ENOTSUP, ENOSYS, EINVAL from the ioctl form):
returns Ok(false). The caller should fall back to fs::copy and
remember to skip future reflink attempts on this filesystem.
On any other I/O error: returns Err.
dest must not already exist on macOS (clonefile requires a
nonexistent destination). On Linux FICLONE requires the dest fd
be opened for writing on a regular file, which we create with
O_CREAT | O_WRONLY | O_TRUNC.