diff options
author | Pádraig Brady <P@draigBrady.com> | 2009-09-21 08:43:03 +0100 |
---|---|---|
committer | Pádraig Brady <P@draigBrady.com> | 2010-07-01 14:33:27 +0100 |
commit | 1af81dfb4d24d104777b8917544d81097db0deab (patch) | |
tree | 3030f158798f4246a3b7d38ba9262adb57705849 /tests/cp/acl | |
parent | 8aa15b2be2bd2ab4b76d197a279abf8b9091680a (diff) | |
download | coreutils-1af81dfb4d24d104777b8917544d81097db0deab.tar.xz |
cp: add an option to only copy the file attributes
* src/copy.c (copy_attr): A new function which merges copy_attr_by_fd
and copy_attr_by_name. Also display all errors when --attributes-only
* src/copy.c (copy_reg): Skip copying the file contents if specified.
Refactor the SELinux error handling code a little and display all
SELinux errors when only copying attributes.
* src/copy.h (struct cp_options): Add a data_copy_required boolean
* src/cp.c (main): Default to copying data but don't if specified
* src/install.c: Default to copying data
* src/mv.c: Likewise
tests/cp/reflink-perm: Add a test to check that --attributes-only
does not copy data
* tests/cp/acl: Likewise. Also refactor to remove redundant
acl manipulation
* doc/coreutils.texi (cp invocation): Describe the new option
* NEWS: Mention the new feature
Diffstat (limited to 'tests/cp/acl')
-rwxr-xr-x | tests/cp/acl | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/tests/cp/acl b/tests/cp/acl index 010348a9d..c19eb4e93 100755 --- a/tests/cp/acl +++ b/tests/cp/acl @@ -36,28 +36,32 @@ grep '^#define USE_ACL 1' $CONFIG_HEADER > /dev/null || mkdir -p a b || framework_failure touch a/file || framework_failure -skip=no # Ensure that setfacl and getfacl work on this file system. +skip=no +acl1=`cd a && getfacl file` || skip=yes setfacl -m user:bin:rw a/file 2> /dev/null || skip=yes -acl1=`cd a && getfacl file | grep -v ':bin:' | grep -v 'mask::'` \ - || skip=yes - test $skip = yes && skip_test_ "'.' is not on a suitable file system for this test" # copy a file without preserving permissions cp a/file b/ || fail=1 - acl2=`cd b && getfacl file` || framework_failure test "$acl1" = "$acl2" || fail=1 -rm a/file || framework_failure -# copy a file, preserving permissions -touch a/file || framework_failure -setfacl -m user:bin:rw a/file || framework_failure +# Update with acl set above acl1=`cd a && getfacl file` || framework_failure + +# copy a file, preserving permissions cp -p a/file b/ || fail=1 acl2=`cd b && getfacl file` || framework_failure test "$acl1" = "$acl2" || fail=1 +# copy a file, preserving permissions, with --attributes-only +echo > a/file || framework_failure # add some data +test -s a/file || framework_failure +cp -p --attributes-only a/file b/ || fail=1 +test -s b/file && fail=1 +acl2=`cd b && getfacl file` || framework_failure +test "$acl1" = "$acl2" || fail=1 + Exit $fail |