diff options
author | Pádraig Brady <P@draigBrady.com> | 2009-08-26 00:32:43 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2009-08-29 00:24:49 +0100 |
commit | 72f98388c36676e5c9ba6a72df5693c207862204 (patch) | |
tree | f0f54bfdb3a16d87cd180226021de9a7570bd9e7 /tests/cp | |
parent | f296cf4052c5299c7e6b1c14dcffa4785982a8ce (diff) | |
download | coreutils-72f98388c36676e5c9ba6a72df5693c207862204.tar.xz |
cp --reflink: add an "auto" parameter to fall back to a normal copy
* doc/coreutils.texi (cp invocation): Document the new
"auto" and "always" options to --reflink.
* src/copy.c (copy_reg): Fall back to a standard copy
when reflink() is not supported and --reflink=auto specified.
* src/copy.h [struct cp_options] (reflink): Change type s/bool/enum/.
* src/cp.c (usage): Describe the --reflink={always,auto} options
and expand a little on what --reflink does.
(main): parse the new parameters to --reflink and allow all
--sparse options with --reflink=auto.
* src/install.c (cp_option_init): Init the enum instead of bool.
* src/mv.c (cp_option_init): Likewise.
* tests/cp/reflink-auto: A new test for falling back to normal copy.
* tests/Makefile.am: Reference the new test.
* NEWS: Mention the new feature.
Diffstat (limited to 'tests/cp')
-rwxr-xr-x | tests/cp/reflink-auto | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/tests/cp/reflink-auto b/tests/cp/reflink-auto new file mode 100755 index 000000000..ff2b1b39b --- /dev/null +++ b/tests/cp/reflink-auto @@ -0,0 +1,45 @@ +#!/bin/sh +# Test cp --reflink=auto + +# Copyright (C) 2009 Free Software Foundation, Inc. + +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program. If not, see <http://www.gnu.org/licenses/>. + +if test "$VERBOSE" = yes; then + set -x + cp --version +fi + +. $srcdir/test-lib.sh + +cleanup_() { rm -rf "$other_partition_tmpdir"; } +. "$abs_srcdir/other-fs-tmpdir" +a_other="$other_partition_tmpdir/a" +rm -f $a_other || framework_failure + +echo non_zero_size > "$a_other" + +# we shouldn't be able to reflink() files on separate partitions +cp --reflink "$a_other" b && fail=1 + +# --reflink=auto should fall back to a normal copy +cp --reflink=auto "$a_other" b || fail=1 +test -s b || fail=1 + +# --reflink=auto should allow --sparse for fallback copies. +# This command can be used to create minimal sized copies. +cp --reflink=auto --sparse=always "$a_other" b || fail=1 +test -s b || fail=1 + +Exit $fail |