The 'cp' utility does not preserve extended attributes for regular files with the exception of ACLs. This is because the ACL patch used for src/copy.c only calls copy_extended_attributes() for non-regular files (line 1871); for regular files, copy_reg() is invoked which does not handle general extended attributes (only ACLs) (see lines 615-617 and compare the code to lines 1869-1874). Test case: touch /tmp/x setfattr -n user.someattr -v somevalue /tmp/x getfattr -d /tmp/x ==> should display "user.someattr" and its value cp -a /tmp/x /tmp/x2 getfattr -d /tmp/x2 ==> should display "user.someattr" and its value, too, but doesn't as the attribute does not get copied The small patch attached corrects this behaviour by adding the missing call. It works for coreutils-6.4 and coreutils-6.6, as src/copy.c is identical in both versions. It was tested with extended attributes on ext3 (mounted with acl and user_xattr options) and xfs. output of emerge --info: Gentoo Base System version 1.12.6 Portage 2.1.1-r2 (default-linux/x86/2006.1, gcc-4.1.1, glibc-2.4-r4, 2.6.18-gent oo-r3 i686) ================================================================= System uname: 2.6.18-gentoo-r3 i686 AMD Athlon(tm) XP 2500+ Last Sync: Fri, 01 Dec 2006 01:50:01 +0000 app-admin/eselect-compiler: [Not Present] dev-java/java-config: 1.3.7, 2.0.30 dev-lang/python: 2.4.3-r4 dev-python/pycrypto: 2.0.1-r5 dev-util/ccache: [Not Present] dev-util/confcache: [Not Present] sys-apps/sandbox: 1.2.17 sys-devel/autoconf: 2.13, 2.60 sys-devel/automake: 1.4_p6, 1.5, 1.6.3, 1.7.9-r1, 1.8.5-r3, 1.9.6-r2 sys-devel/binutils: 2.16.1-r3 sys-devel/gcc-config: 1.3.13-r4 sys-devel/libtool: 1.5.22 virtual/os-headers: 2.6.17-r1 ACCEPT_KEYWORDS="x86" AUTOCLEAN="yes" CBUILD="i686-pc-linux-gnu" CFLAGS="-O2 -march=athlon-xp -fomit-frame-pointer -pipe" CHOST="i686-pc-linux-gnu" CONFIG_PROTECT="/etc /usr/share/X11/xkb" CONFIG_PROTECT_MASK="/etc/env.d /etc/env.d/java/ /etc/gconf /etc/java-config/vms / /etc/revdep-rebuild /etc/terminfo /etc/texmf/web2c" CXXFLAGS="-O2 -march=athlon-xp -fomit-frame-pointer -pipe" DISTDIR="/usr/portage/distfiles" FEATURES="autoconfig distlocks metadata-transfer sandbox sfperms strict userpriv usersandbox" GENTOO_MIRRORS="ftp://ftp.tu-clausthal.de/pub/linux/gentoo/ ftp://sunsite.inform atik.rwth-aachen.de/pub/Linux/gentoo http://linux.rz.ruhr-uni-bochum.de/download /gentoo-mirror/ ftp://ftp.join.uni-muenster.de/pub/linux/distributions/gentoo ft p://ftp.wh2.tu-dresden.de/pub/mirrors/gentoo ftp://ftp.join.uni-muenster.de/pub/ linux/distributions/gentoo http://mirrors.sec.informatik.tu-darmstadt.de/gentoo/ http://ftp-stud.fht-esslingen.de/pub/Mirrors/gentoo/ ftp://ftp-stud.fht-essling en.de/pub/Mirrors/gentoo/ ftp://ftp.gentoo.mesh-solutions.com/gentoo/ http://pan demonium.tiscali.de/pub/gentoo/ ftp://pandemonium.tiscali.de/pub/gentoo/ ftp://f tp.rz.tu-bs.de/pub/mirror/ftp.gentoo.org/gentoo-distfiles/ http://ftp.rz.tu-bs.d e/pub/mirror/ftp.gentoo.org/gentoo/ http://gentoo.intergenia.de " LC_ALL="en_US.UTF-8" LINGUAS="de en_US en_GB" PKGDIR="/usr/portage/packages" PORTAGE_RSYNC_OPTS="--recursive --links --safe-links --perms --times --compress --force --whole-file --delete --delete-after --stats --timeout=180 --exclude='/distfiles' --exclude='/local' --exclude='/packages'" PORTAGE_TMPDIR="/var/tmp" PORTDIR="/usr/portage" PORTDIR_OVERLAY="/usr/local/portage" SYNC="rsync://rsync.de.gentoo.org/gentoo-portage" USE="x86 acl alsa apache2 apm berkdb bitmap-fonts bzip2 bzlib cli cracklib crypt cups curl dlloader dri elibc_glibc expat fam gd gdbm gif gmp gpm iconv imap inn odb input_devices_evdev input_devices_keyboard input_devices_mouse ipv6 isdnlog java jpeg kernel_linux ldap libg++ linguas_de linguas_en_GB linguas_en_US mmap m ysql mysqli ncurses nls nptl nptlonly oss pam pcre pdflib perl php png postgres ppds pppd python readline reflection samba session spell spl ssl tcpd tiff truet ype truetype-fonts type1-fonts udev unicode userland_GNU video_cards_mach64 wmf xml xml2 xorg xprint zlib" Unset: CTARGET, EMERGE_DEFAULT_OPTS, INSTALL_MASK, LANG, LDFLAGS, MAKEOPTS, POR TAGE_RSYNC_EXTRA_OPTS Regards, Christoph Schulz diff -urN coreutils-6.6/src/copy.c coreutils-6.6p1/src/copy.c --- coreutils-6.6/src/copy.c 2006-12-01 09:57:57.218265638 +0100 +++ coreutils-6.6p1/src/copy.c 2006-12-01 09:55:48.675321984 +0100 @@ -614,6 +614,9 @@ set_author (dst_name, dest_desc, src_sb); + if (! copy_extended_attributes (src_name, dst_name, x)) + return_val = false; + if (x->preserve_mode || x->move_mode) { if (copy_acl (src_name, source_desc, dst_name, dest_desc,
Created attachment 103111 [details, diff] fixes copying extended attributes for regular files Attached described patch.
I forgot to say that attached patch requires the ACL patch to be applied first which is found in the patch/acl/ directory of coreutils-...-patches.tar.gz.
The fix also works with coreutils-6.9. Anyone to include it in portage?
queued up for next release http://sources.gentoo.org/gentoo/src/patchsets/coreutils/6.10/004_all_coreutils-acl-xattr.patch?r1=1.1&r2=1.2