From c160afe902c07f5052dbd97c726a997db7fa20c0 Mon Sep 17 00:00:00 2001 From: Ondřej Vašík Date: Wed, 11 Mar 2009 16:08:20 +0100 Subject: cp: make -a option preserve xattrs, but with reduced diagnostics * copy.c (copy_attr_by_fd): Reduce xattr diagnostics for 'cp -a'. (copy_attr_by_name): Likewise. * cp.c (main): Preserve xattrs with -a option, when possible. * doc/coreutils.texi: Document that xattrs are preserved with cp -a, with no added diagnostics. * NEWS: Mention the change. * tests/misc/xattr: Add tests for 'cp --preserve=all' and 'cp -a'. --- tests/misc/xattr | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'tests/misc/xattr') diff --git a/tests/misc/xattr b/tests/misc/xattr index 4137c53cb..f067ff535 100755 --- a/tests/misc/xattr +++ b/tests/misc/xattr @@ -1,6 +1,7 @@ #!/bin/sh -# Ensure that cp --preserve=xattr and mv preserve extended attributes and -# install does not preserve extended attributes. +# Ensure that cp --preserve=xattr, cp --preserve=all and mv preserve extended +# attributes and install does not preserve extended attributes. +# cp -a should preserve xattr, error diagnostics should not be displayed # Copyright (C) 2009 Free Software Foundation, Inc. @@ -66,6 +67,16 @@ cp --preserve=xattr a b || fail=1 getfattr -d b >out_b || skip_test_ "failed to get xattr of file" grep -F "$xattr_pair" out_b >/dev/null || fail=1 +#test if --preserve=all option works +cp --preserve=all a c || fail=1 +getfattr -d c >out_c || skip_test_ "failed to get xattr of file" +grep -F "$xattr_pair" out_c >/dev/null || fail=1 + +#test if -a option works without any diagnostics +cp -a a d 2>err && test -s err && fail=1 +getfattr -d d >out_d || skip_test_ "failed to get xattr of file" +grep -F "$xattr_pair" out_d >/dev/null || fail=1 + rm b || framework_failure # install should never preserve xattr -- cgit v1.2.3-54-g00ecf