From: Adam Borowski Date: Sun, 17 Jun 2018 22:38:04 +0000 (+0200) Subject: cp: add --reflink=never to force standard copy mode X-Git-Tag: v8.30~19 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=163df41d45bcc6615915ca507264dde090aba44d;p=thirdparty%2Fcoreutils.git cp: add --reflink=never to force standard copy mode 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. --- diff --git a/NEWS b/NEWS index 9de2fa05df..11cce44207 100644 --- 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. diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 3821b00c3d..83d31bd342 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -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} diff --git a/src/cp.c b/src/cp.c index 04cbd4b339..21dd4441bb 100644 --- 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 (_("\ diff --git a/tests/cp/reflink-auto.sh b/tests/cp/reflink-auto.sh index 7258a6ac81..82f41bca4a 100755 --- a/tests/cp/reflink-auto.sh +++ b/tests/cp/reflink-auto.sh @@ -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