diff options
author | Giuseppe Scrivano <gscrivano@gnu.org> | 2009-08-01 19:36:48 +0200 |
---|---|---|
committer | Jim Meyering <meyering@redhat.com> | 2009-08-07 17:14:22 +0200 |
commit | a1d7469835371ded0ad8e3496bc5a5bebf94ccef (patch) | |
tree | 925945606aa919b7b48603117db6f8ca15e7b551 /src/copy.c | |
parent | ff159a605e5bc10fe871109f66cba5ee410c9138 (diff) | |
download | coreutils-a1d7469835371ded0ad8e3496bc5a5bebf94ccef.tar.xz |
cp: accept the --reflink option
* NEWS: Mention it.
* doc/coreutils.texi (cp invocation): Describe it.
* src/copy.h (struct cp_options) [reflink]: New member.
* src/copy.c (usage): Describe it.
(copy_reg): If reflink is true try to clone the file.
(main): Check for --reflink.
(cp_option_init): Initialize the new member.
* src/install.c (cp_option_init): Initialize the new member.
* src/mv.c (cp_option_init): Likewise.
* tests/cp/sparse: Add a new test case.
Diffstat (limited to 'src/copy.c')
-rw-r--r-- | src/copy.c | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/src/copy.c b/src/copy.c index 24b5f6b46..bed90c459 100644 --- a/src/copy.c +++ b/src/copy.c @@ -624,13 +624,16 @@ copy_reg (char const *src_name, char const *dst_name, goto close_src_and_dst_desc; } - /* If --sparse=auto is in effect, attempt a btrfs clone operation. - If the operation is not supported or it fails then copy the file - in the usual way. */ - bool copied = (x->sparse_mode == SPARSE_AUTO - && clone_file (dest_desc, source_desc) == 0); + if (x->reflink) + { + if (clone_file (dest_desc, source_desc)) + { + error (0, errno, _("failed to clone %s"), quote (dst_name)); + return_val = false; + } + goto close_src_and_dst_desc; + } - if (!copied) { typedef uintptr_t word; off_t n_read_total = 0; @@ -2232,6 +2235,7 @@ valid_options (const struct cp_options *co) assert (VALID_BACKUP_TYPE (co->backup_type)); assert (VALID_SPARSE_MODE (co->sparse_mode)); assert (!(co->hard_link && co->symbolic_link)); + assert (!(co->reflink && co->sparse_mode != SPARSE_AUTO)); return true; } |