]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
cp: add --reflink=never to force standard copy mode
authorAdam Borowski <kilobyte@angband.pl>
Sun, 17 Jun 2018 22:38:04 +0000 (00:38 +0200)
committerPádraig Brady <P@draigBrady.com>
Thu, 21 Jun 2018 04:17:19 +0000 (21:17 -0700)
This mode is currently the default, but most if not all users of
reflink-capable filesystems want --reflink=auto, which is often
encapsulated into an alias.  Adding --reflink=never allows overriding
such an alias.

* doc/coreutils.texi (cp invocation): Describe the new option.
* src/cp.c: Support --reflink=never.
* tests/cp/reflink-auto.sh: Add a test case.
* NEWS: Mention the new feature.

NEWS
doc/coreutils.texi
src/cp.c
tests/cp/reflink-auto.sh

diff --git a/NEWS b/NEWS
index 9de2fa05df51d5a196bce549337874fd77259337..11cce44207f9cac5789e0fe5679f02b3e402fff1 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -50,6 +50,8 @@ GNU coreutils NEWS                                    -*- outline -*-
 
 ** New features
 
+  cp --reflink now supports --reflink=never to enforce a standard copy.
+
   env supports a new -v/--debug option to show verbose information about
   each processing step.
 
index 3821b00c3d1b1d9f68b22c431fbac55480f34c49..83d31bd3425cc6cc590f7d9aa619b0c3e2f55df9 100644 (file)
@@ -8743,6 +8743,9 @@ then report the failure for each file and exit with a failure status.
 @item auto
 If the copy-on-write operation is not supported then fall back
 to the standard copy behavior.
+
+@item never
+Disable copy-on-write operation and use the standard copy behavior.
 @end table
 
 This option is overridden by the @option{--link}, @option{--symbolic-link}
index 04cbd4b3399f5c4553f5e20b2ddf7cd770e67193..21dd4441bb5625baa229df2c12ec46a655b93aca 100644 (file)
--- a/src/cp.c
+++ b/src/cp.c
@@ -96,11 +96,11 @@ ARGMATCH_VERIFY (sparse_type_string, sparse_type);
 
 static char const *const reflink_type_string[] =
 {
-  "auto", "always", NULL
+  "auto", "always", "never", NULL
 };
 static enum Reflink_type const reflink_type[] =
 {
-  REFLINK_AUTO, REFLINK_ALWAYS
+  REFLINK_AUTO, REFLINK_ALWAYS, REFLINK_NEVER
 };
 ARGMATCH_VERIFY (reflink_type_string, reflink_type);
 
@@ -235,10 +235,13 @@ corresponding DEST file is made sparse as well.  That is the behavior\n\
 selected by --sparse=auto.  Specify --sparse=always to create a sparse DEST\n\
 file whenever the SOURCE file contains a long enough sequence of zero bytes.\n\
 Use --sparse=never to inhibit creation of sparse files.\n\
+"), stdout);
+      fputs (_("\
 \n\
 When --reflink[=always] is specified, perform a lightweight copy, where the\n\
 data blocks are copied only when modified.  If this is not possible the copy\n\
 fails, or if --reflink=auto is specified, fall back to a standard copy.\n\
+Use --reflink=never to ensure a standard copy is performed.\n\
 "), stdout);
       emit_backup_suffix_note ();
       fputs (_("\
index 7258a6ac81f563177489f78fedaf5396d8f0d277..82f41bca4a132cdc29bac0ffabb0ecf8673c6b48 100755 (executable)
@@ -38,4 +38,8 @@ test -s b || fail=1
 cp --reflink=auto --sparse=always "$a_other" b || fail=1
 test -s b || fail=1
 
+# --reflink=auto should be overridden by --reflink=never
+cp --reflink=auto --reflink=never "$a_other" b || fail=1
+test -s b || fail=1
+
 Exit $fail