diff options
| author | Kamil Dudka <kdudka@redhat.com> | 2009-01-23 12:17:53 +0100 |
|---|---|---|
| committer | Jim Meyering <meyering@redhat.com> | 2009-01-29 13:26:07 +0100 |
| commit | 0889381cbfdbb4895e6b8693d14c0f5c77bc85bc (patch) | |
| tree | 1c93168a0d0c7e5ff72df37c4b34607b0eb3aaea /src/cp.c | |
| parent | system.h: add a comment re autoconf's new AC_PACKAGE_URL (diff) | |
| download | coreutils-0889381cbfdbb4895e6b8693d14c0f5c77bc85bc.tar.gz coreutils-0889381cbfdbb4895e6b8693d14c0f5c77bc85bc.zip | |
cp/mv: add xattr support
This patch was originally written by Andreas Grünbacher, nowadays
available at
http://www.suse.de/~agruen/coreutils/5.91/coreutils-xattr.diff
* bootstrap.conf: Add gnulib module verror.
* po/POTFILES.in: Add lib/verror.c.
* m4/xattr.m4: Check for libattr availability, new configure option
--disable-xattr.
* m4/prereq.m4: Require gl_FUNC_XATTR.
* src/Makefile.am: Link cp, mv and ginstall with libattr.
* src/copy.h: Add preserve_xattr and require_preserve_xattr to
cp_options.
* src/copy.c (copy_attr_error): New function to handle errors during
xattr copying.
(copy_attr_quote): New function to quote file name in error messages
printed by libattr.
(copy_attr_free): Empty function requested by libattr to free quoted
string.
(copy_attr_by_fd): New fd-oriented function to copy xattr.
(copy_attr_by_name): New name-oriented function to copy xattr.
(copy_reg, copy_internal): Call copy_extended_attributes function.
* src/cp.c (usage): Mention new --preserve=xattr option.
(decode_preserve_arg): Handle new --preserve=xattr option.
* src/mv.c: Always attempt to preserve xattr.
* src/install.c: Never attempt to preserve xattr.
* tests/misc/xattr: New test for xattr support in cp, mv and install.
* tests/Makefile.am: Add the new test to list.
* doc/coreutils.texi: Mention xattr support, new --preserve=xattr
option.
* NEWS: Mention the change.
Diffstat (limited to 'src/cp.c')
| -rw-r--r-- | src/cp.c | 23 |
1 files changed, 20 insertions, 3 deletions
@@ -187,7 +187,8 @@ Mandatory arguments to long options are mandatory for short options too.\n\ -p same as --preserve=mode,ownership,timestamps\n\ --preserve[=ATTR_LIST] preserve the specified attributes (default:\n\ mode,ownership,timestamps), if possible\n\ - additional attributes: context, links, all\n\ + additional attributes: context, links, xattr,\n\ + all\n\ "), stdout); fputs (_("\ --no-preserve=ATTR_LIST don't preserve the specified attributes\n\ @@ -764,6 +765,8 @@ cp_option_init (struct cp_options *x) x->preserve_timestamps = false; x->preserve_security_context = false; x->require_preserve_context = false; + x->preserve_xattr = false; + x->require_preserve_xattr = false; x->require_preserve = false; x->recursive = false; @@ -800,18 +803,20 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off) PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, + PRESERVE_XATTR, PRESERVE_ALL }; static enum File_attribute const preserve_vals[] = { PRESERVE_MODE, PRESERVE_TIMESTAMPS, - PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, PRESERVE_ALL + PRESERVE_OWNERSHIP, PRESERVE_LINK, PRESERVE_CONTEXT, PRESERVE_XATTR, + PRESERVE_ALL }; /* Valid arguments to the `--preserve' option. */ static char const* const preserve_args[] = { "mode", "timestamps", - "ownership", "links", "context", "all", NULL + "ownership", "links", "context", "xattr", "all", NULL }; ARGMATCH_VERIFY (preserve_args, preserve_vals); @@ -852,6 +857,11 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off) x->require_preserve_context = on_off; break; + case PRESERVE_XATTR: + x->preserve_xattr = on_off; + x->require_preserve_xattr = on_off; + break; + case PRESERVE_ALL: x->preserve_mode = on_off; x->preserve_timestamps = on_off; @@ -859,6 +869,7 @@ decode_preserve_arg (char const *arg, struct cp_options *x, bool on_off) x->preserve_links = on_off; if (selinux_enabled) x->preserve_security_context = on_off; + x->preserve_xattr = on_off; break; default: @@ -1099,6 +1110,12 @@ main (int argc, char **argv) "without an SELinux-enabled kernel")); } +#if !USE_XATTR + if (x.require_preserve_xattr) + error (EXIT_FAILURE, 0, _("cannot preserve extended attributes, cp is " + "built without xattr support")); +#endif + /* Allocate space for remembering copied and created files. */ hash_init (); |
