diff options
author | Pádraig Brady <P@draigBrady.com> | 2010-10-26 17:55:10 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2010-10-27 11:18:51 +0100 |
commit | 883ac22239036025896ff99bd4b2a6d02712f39f (patch) | |
tree | 93bd2ebfec80b218b8fd55f144a77a4d27ce8a3d | |
parent | 0d792d061e460fd5dfe6e4226f96bbc3b8788199 (diff) | |
download | coreutils-883ac22239036025896ff99bd4b2a6d02712f39f.tar.xz |
cp: make --attributes-only override --reflink completely
* doc/coreutils.texi (cp invocation): Change the description slightly
so as users might not immediately discount using this option.
Mention that --reflink is overridden by the other linking options and
--attributes-only, and give an example where this might be useful.
* src/copy.c (copy_internal): Bypass the reflink if
--attributes-only is specifed.
* tests/cp/reflink-perm: Ensure both --reflink modes are
overridden by --attributes-only.
* NEWS: Mention the change in behavior.
Reported by Jim Meyering.
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | doc/coreutils.texi | 18 | ||||
-rw-r--r-- | src/copy.c | 3 | ||||
-rwxr-xr-x | tests/cp/reflink-perm | 3 |
4 files changed, 23 insertions, 6 deletions
@@ -7,6 +7,11 @@ GNU coreutils NEWS -*- outline -*- tail -F once again notices changes in a currently unavailable remote directory [bug introduced in coreutils-7.5] +** Changes in behavior + + cp --attributes-only now completely overrides --reflink. + Previously a reflink was needlessly attempted. + * Noteworthy changes in release 8.6 (2010-10-15) [stable] diff --git a/doc/coreutils.texi b/doc/coreutils.texi index 4d17ed18b..0b5a3d341 100644 --- a/doc/coreutils.texi +++ b/doc/coreutils.texi @@ -7614,12 +7614,11 @@ implementations that dereference symbolic links by default. @cindex COW @cindex clone @cindex copy on write -Perform a lightweight, copy-on-write (COW) copy. -Copying with this option can succeed only on some file systems. -Once it has succeeded, beware that the source and destination files -share the same disk data blocks as long as they remain unmodified. +Perform a lightweight, copy-on-write (COW) copy, if supported by the +file system. Once it has succeeded, beware that the source and destination +files share the same disk data blocks as long as they remain unmodified. Thus, if a disk I/O error affects data blocks of one of the files, -the other suffers the exact same fate. +the other suffers the same fate. The @var{when} value can be one of the following: @@ -7633,6 +7632,15 @@ If the copy-on-write operation is not supported then fall back to the standard copy behaviour. @end table +This option is overridden by the @option{--link}, @option{--symbolic-link} +and @option{--attributes-only} options, thus allowing it to be used +to configure the default data copying behavior for @command{cp}. +For example, with the following alias, @command{cp} will use the +minimum amount of space supported by the file system. + +@example +alias cp='cp --reflink=auto --sparse=always' +@end example @item --remove-destination @opindex --remove-destination diff --git a/src/copy.c b/src/copy.c index df31592db..07501dfd4 100644 --- a/src/copy.c +++ b/src/copy.c @@ -622,7 +622,8 @@ copy_reg (char const *src_name, char const *dst_name, goto close_src_and_dst_desc; } - if (x->reflink_mode) + /* --attributes-only overrides --reflink. */ + if (data_copy_required && x->reflink_mode) { bool clone_ok = clone_file (dest_desc, source_desc) == 0; if (clone_ok || x->reflink_mode == REFLINK_ALWAYS) diff --git a/tests/cp/reflink-perm b/tests/cp/reflink-perm index 77f119f4a..e1c12aa5a 100755 --- a/tests/cp/reflink-perm +++ b/tests/cp/reflink-perm @@ -39,8 +39,11 @@ test "$mode" = "-rwxrwxrwx" || fail=1 test copy -nt file && fail=1 +# Ensure that --attributes-only overrides --reflink completely echo > file2 # file with data cp --reflink=auto --preserve --attributes-only file2 empty_copy || fail=1 test -s empty_copy && fail=1 +cp --reflink=always --preserve --attributes-only file2 empty_copy || fail=1 +test -s empty_copy && fail=1 Exit $fail |