Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
View | Details | Raw Unified | Return to bug 37682 | Differences between
and this patch

Collapse All | Expand All

(-)coreutils-5.0.91.old/configure.ac (+3 lines)
Lines 235-240 Link Here
235
# For src/kill.c.
235
# For src/kill.c.
236
AC_CHECK_DECLS([strsignal, strtoimax, sys_siglist, _sys_siglist, __sys_siglist])
236
AC_CHECK_DECLS([strsignal, strtoimax, sys_siglist, _sys_siglist, __sys_siglist])
237
237
238
# Extended attribute copying.
239
AC_FUNC_XATTR
240
238
jm_LIB_CHECK
241
jm_LIB_CHECK
239
242
240
AM_GNU_GETTEXT([external], [need-ngettext])
243
AM_GNU_GETTEXT([external], [need-ngettext])
(-)coreutils-5.0.91.old/doc/coreutils.texi (-2 / +14 lines)
Lines 5937-5942 Link Here
5937
directory in a different order).
5937
directory in a different order).
5938
Equivalent to @option{-dpPR}.
5938
Equivalent to @option{-dpPR}.
5939
5939
5940
@itemx @w{@kbd{--attributes}=@var{regex}}
5941
@opindex --attributes
5942
Preserve extended attributes whose names match the specified regular
5943
expression.  The default behavior or @command{cp} if no
5944
@option{--attributes} option is given is to preserve all extended
5945
attributes except file permissions.  If @var{regex} is ``@samp{-}'', no
5946
extended attributes are preserved.
5947
5948
This option does not affect the preservation of discretionary file
5949
permissions (i.e., file mode permission bits and access control lists).
5950
To control the preservation of file permissions, the @option{-p} or
5951
@option{--preserve=mode} options are used.
5952
5940
@item -b
5953
@item -b
5941
@itemx @w{@kbd{--backup}[=@var{method}]}
5954
@itemx @w{@kbd{--backup}[=@var{method}]}
5942
@opindex -b
5955
@opindex -b
Lines 6040-6046 Link Here
6040
6053
6041
@table @samp
6054
@table @samp
6042
@itemx mode
6055
@itemx mode
6043
Preserve the permission attributes.
6056
Preserve the permission attributes, including access control lists.
6044
@itemx ownership
6057
@itemx ownership
6045
Preserve the owner and group.  On most modern systems,
6058
Preserve the owner and group.  On most modern systems,
6046
only the super-user may change the owner of a file, and regular users
6059
only the super-user may change the owner of a file, and regular users
Lines 6056-6062 Link Here
6056
@itemx all
6069
@itemx all
6057
Preserve all file attributes.
6070
Preserve all file attributes.
6058
Equivalent to specifying all of the above.
6071
Equivalent to specifying all of the above.
6059
@c Mention ACLs here.
6060
@end table
6072
@end table
6061
6073
6062
Using @option{--preserve} with no @var{attribute_list} is equivalent
6074
Using @option{--preserve} with no @var{attribute_list} is equivalent
(-)coreutils-5.0.91.old/m4/xattr.m4 (+38 lines)
Line 0 Link Here
1
# xattr.m4 - check for Extended Attributes (Linux)
2
3
# Copyright (C) 2003 Free Software Foundation, Inc.
4
5
# This program is free software; you can redistribute it and/or modify
6
# it under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 2, or (at your option)
8
# any later version.
9
10
# This program is distributed in the hope that it will be useful,
11
# but WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13
# GNU General Public License for more details.
14
15
# You should have received a copy of the GNU General Public License
16
# along with this program; if not, write to the Free Software Foundation,
17
# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18
19
# Written by Andreas Gruenbacher.
20
21
AC_DEFUN([AC_FUNC_XATTR],
22
[
23
  AC_CHECK_HEADERS(attr/error_context.h attr/libattr.h)
24
  if test "$ac_cv_header_attr_libattr_h" = yes \
25
     && test "$ac_cv_header_attr_error_context_h" = yes; then
26
    use_xattr=1
27
  else
28
    use_xattr=0
29
  fi
30
  AC_DEFINE_UNQUOTED(USE_XATTR, $use_xattr,
31
		     [Define if you want extended attribute support.])
32
  xattr_saved_LIBS=$LIBS
33
  AC_SEARCH_LIBS(attr_copy_file, attr,
34
  		 [LIB_XATTR=$ac_cv_search_attr_copy_file])
35
  AC_SUBST(LIB_XATTR)
36
  AC_CHECK_FUNCS(attr_copy_file)
37
  LIBS=$xattr_saved_LIBS
38
])
(-)coreutils-5.0.91.old/man/cp.1 (+8 lines)
Lines 60-65 Link Here
60
mode,ownership,timestamps), if possible
60
mode,ownership,timestamps), if possible
61
additional attributes: links, all
61
additional attributes: links, all
62
.TP
62
.TP
63
\fB\-\-attributes\fR=\fIregex\fR
64
preserve extended attributes whose name
65
matches the specified regular expression
66
(defaults to preserving all extended
67
.IP
68
attributes except file permissions;
69
regex=`-' preserves no extended attributes).
70
.TP
63
\fB\-\-no\-preserve\fR=\fIATTR_LIST\fR
71
\fB\-\-no\-preserve\fR=\fIATTR_LIST\fR
64
don't preserve the specified attributes
72
don't preserve the specified attributes
65
.TP
73
.TP
(-)coreutils-5.0.91.old/src/Makefile.am (-3 / +3 lines)
Lines 36-44 Link Here
36
ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -lcurses @LIB_ACL@
36
ls_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -lcurses @LIB_ACL@
37
shred_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
37
shred_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME)
38
vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -lcurses @LIB_ACL@
38
vdir_LDADD = $(LDADD) $(LIB_CLOCK_GETTIME) -lcurses @LIB_ACL@
39
cp_LDADD = $(LDADD) @LIB_ACL@
39
cp_LDADD = $(LDADD) @LIB_ACL@ @LIB_XATTR@
40
mv_LDADD = $(LDADD) @LIB_ACL@
40
mv_LDADD = $(LDADD) @LIB_ACL@ @LIB_XATTR@
41
ginstall_LDADD = $(LDADD) @LIB_ACL@
41
ginstall_LDADD = $(LDADD) @LIB_ACL@ @LIB_XATTR@
42
42
43
## If necessary, add -lm to resolve use of pow in lib/strtod.c.
43
## If necessary, add -lm to resolve use of pow in lib/strtod.c.
44
sort_LDADD = $(LDADD) $(POW_LIB)
44
sort_LDADD = $(LDADD) $(POW_LIB)
(-)coreutils-5.0.91.old/src/copy.c (+108 lines)
Lines 44-49 Link Here
44
#include "xreadlink.h"
44
#include "xreadlink.h"
45
#include "acl.h"
45
#include "acl.h"
46
46
47
#ifdef USE_XATTR
48
# include "regex.h"
49
# include <stdarg.h>
50
# include <attr/error_context.h>
51
# include <attr/libattr.h>
52
#endif
53
47
#define DO_CHOWN(Chown, File, New_uid, New_gid)				\
54
#define DO_CHOWN(Chown, File, New_uid, New_gid)				\
48
  (Chown (File, New_uid, New_gid)					\
55
  (Chown (File, New_uid, New_gid)					\
49
   /* If non-root uses -p, it's ok if we can't preserve ownership.	\
56
   /* If non-root uses -p, it's ok if we can't preserve ownership.	\
Lines 114-119 Link Here
114
  return 0;
121
  return 0;
115
}
122
}
116
123
124
#if USE_XATTR
125
static void
126
copy_attr_error (struct error_context *ctx, const char *fmt, ...)
127
{
128
  int err = errno;
129
  va_list ap;
130
  int len;
131
  char *buffer;
132
133
  /* There is no error function that takes a va_list argument,
134
     so we print the message in a buffer first.  */
135
136
  va_start (ap, fmt);
137
  len = vsnprintf (NULL, 0, fmt, ap);
138
  if (len > 0)
139
    {
140
      buffer = xmalloc (len + 1);
141
      vsnprintf (buffer, len + 1, fmt, ap);
142
      error (0, err, "%s", buffer);
143
      free (buffer);
144
    }
145
  va_end (ap);
146
}
147
148
static const char *
149
copy_attr_quote (struct error_context *ctx, const char *str)
150
{
151
  return xstrdup (quote (str));
152
}
153
154
static void
155
copy_attr_free (struct error_context *ctx, const char *str)
156
{
157
  free ((void *) str);	
158
}
159
160
struct copy_attr_context
161
  {
162
    struct error_context ctx;
163
    const char *re_pattern;
164
    struct re_pattern_buffer re_compiled;
165
  } copy_attr_ctx = {
166
    { copy_attr_error,
167
      copy_attr_quote,
168
      copy_attr_free }
169
  };
170
171
static int
172
copy_attr_filter (const char *name, struct error_context *ctx)
173
{
174
  struct copy_attr_context *copy_ctx = (struct copy_attr_context *) ctx;
175
176
  return (attr_copy_check_permissions (name, ctx)
177
	  && copy_ctx->re_pattern != NULL
178
	  && re_search (&copy_ctx->re_compiled, name, strlen (name), 0,
179
			strlen (name), NULL) >= 0);
180
}
181
#endif  /* USE_XATTR */
182
183
static int
184
copy_extended_attributes (const char *src_path, const char *dst_path,
185
			  const struct cp_options *x)
186
{
187
#if USE_XATTR
188
  if (x->attr_pattern == NULL)
189
    return 0;
190
191
  if (copy_attr_ctx.re_pattern != x->attr_pattern)
192
    {
193
      struct re_pattern_buffer *c = &copy_attr_ctx.re_compiled;
194
      size_t len = strlen (x->attr_pattern);
195
      const char *err;
196
      
197
      free (c->fastmap);
198
      free (c->buffer);
199
200
      copy_attr_ctx.re_pattern = x->attr_pattern;
201
      c->allocated = 2 * len;
202
      c->buffer = xmalloc (c->allocated);
203
      c->fastmap = xmalloc (256);
204
      c->translate = 0;
205
      err = re_compile_pattern (x->attr_pattern, len, c);
206
      if (err)
207
	{
208
	  free (c->fastmap);
209
	  free (c->buffer);
210
	  copy_attr_ctx.re_pattern = NULL;
211
	  error (EXIT_FAILURE, 0, _("%s: invalid regular expression: %s"),
212
	  	 x->attr_pattern, err);
213
	}
214
    }
215
  return attr_copy_file (src_path, dst_path,
216
			 copy_attr_filter, &copy_attr_ctx.ctx);
217
#else  /* USE_XATTR */
218
  return 0;
219
#endif  /* USE_XATTR */
220
}
221
117
/* Read the contents of the directory SRC_PATH_IN, and recursively
222
/* Read the contents of the directory SRC_PATH_IN, and recursively
118
   copy the contents to DST_PATH_IN.  NEW_DST is nonzero if
223
   copy the contents to DST_PATH_IN.  NEW_DST is nonzero if
119
   DST_PATH_IN is a directory that was created previously in the
224
   DST_PATH_IN is a directory that was created previously in the
Lines 1575-1580 Link Here
1575
  }
1680
  }
1576
#endif
1681
#endif
1577
1682
1683
  if (copy_extended_attributes (src_path, dst_path, x))
1684
    delayed_fail = 1;
1685
1578
  if (x->preserve_mode || x->move_mode)
1686
  if (x->preserve_mode || x->move_mode)
1579
    {
1687
    {
1580
      if (copy_acl (src_path, dst_path, src_mode) && x->require_preserve)
1688
      if (copy_acl (src_path, dst_path, src_mode) && x->require_preserve)
(-)coreutils-5.0.91.old/src/copy.h (+4 lines)
Lines 106-111 Link Here
106
  int preserve_mode;
106
  int preserve_mode;
107
  int preserve_timestamps;
107
  int preserve_timestamps;
108
108
109
  /* Regular expression pattern that specifies which extended attributes to
110
     copy.  NULL stands for copying no extended attributes.  */
111
  const char *attr_pattern;
112
109
  /* Enabled for mv, and for cp by the --preserve=links option.
113
  /* Enabled for mv, and for cp by the --preserve=links option.
110
     If nonzero, attempt to preserve in the destination files any
114
     If nonzero, attempt to preserve in the destination files any
111
     logical hard links between the source files.  If used with cp's
115
     logical hard links between the source files.  If used with cp's
(-)coreutils-5.0.91.old/src/cp.c (-1 / +19 lines)
Lines 77-83 Link Here
77
  SPARSE_OPTION,
77
  SPARSE_OPTION,
78
  STRIP_TRAILING_SLASHES_OPTION,
78
  STRIP_TRAILING_SLASHES_OPTION,
79
  TARGET_DIRECTORY_OPTION,
79
  TARGET_DIRECTORY_OPTION,
80
  UNLINK_DEST_BEFORE_OPENING
80
  UNLINK_DEST_BEFORE_OPENING,
81
  PRESERVE_XATTRS_OPTION
81
};
82
};
82
83
83
/* Initial number of entries in each hash table entry's table of inodes.  */
84
/* Initial number of entries in each hash table entry's table of inodes.  */
Lines 136-141 Link Here
136
  {"parents", no_argument, NULL, PARENTS_OPTION},
137
  {"parents", no_argument, NULL, PARENTS_OPTION},
137
  {"path", no_argument, NULL, PARENTS_OPTION},   /* Deprecated.  */
138
  {"path", no_argument, NULL, PARENTS_OPTION},   /* Deprecated.  */
138
  {"preserve", optional_argument, NULL, PRESERVE_ATTRIBUTES_OPTION},
139
  {"preserve", optional_argument, NULL, PRESERVE_ATTRIBUTES_OPTION},
140
  {"attributes", required_argument, NULL, PRESERVE_XATTRS_OPTION},
139
  {"recursive", no_argument, NULL, 'R'},
141
  {"recursive", no_argument, NULL, 'R'},
140
  {"remove-destination", no_argument, NULL, UNLINK_DEST_BEFORE_OPENING},
142
  {"remove-destination", no_argument, NULL, UNLINK_DEST_BEFORE_OPENING},
141
  {"reply", required_argument, NULL, REPLY_OPTION},
143
  {"reply", required_argument, NULL, REPLY_OPTION},
Lines 224-229 Link Here
224
  -v, --verbose                explain what is being done\n\
226
  -v, --verbose                explain what is being done\n\
225
  -x, --one-file-system        stay on this file system\n\
227
  -x, --one-file-system        stay on this file system\n\
226
"), stdout);
228
"), stdout);
229
      fputs(_("\n\
230
      --attributes=regex       preserve extended attributes whose name\n\
231
                               matches the specified regular expression\n\
232
                               (defaults to preserving all extended\n\
233
                                attributes except file permissions;\n\
234
                                regex=`-' preserves no extended attributes).\n\
235
"), stdout);
227
      fputs (HELP_OPTION_DESCRIPTION, stdout);
236
      fputs (HELP_OPTION_DESCRIPTION, stdout);
228
      fputs (VERSION_OPTION_DESCRIPTION, stdout);
237
      fputs (VERSION_OPTION_DESCRIPTION, stdout);
229
      fputs (_("\
238
      fputs (_("\
Lines 789-794 Link Here
789
  x->verbose = 0;
798
  x->verbose = 0;
790
  x->dest_info = NULL;
799
  x->dest_info = NULL;
791
  x->src_info = NULL;
800
  x->src_info = NULL;
801
802
  x->attr_pattern = "";  /* all extended attributes */
792
}
803
}
793
804
794
/* Given a string, ARG, containing a comma-separated list of arguments
805
/* Given a string, ARG, containing a comma-separated list of arguments
Lines 984-989 Link Here
984
	  x.require_preserve = 1;
995
	  x.require_preserve = 1;
985
	  break;
996
	  break;
986
997
998
	case PRESERVE_XATTRS_OPTION:
999
	  if (strcmp (optarg, "-") == 0)
1000
	    x.attr_pattern = NULL;
1001
	  else
1002
	    x.attr_pattern = optarg;
1003
	  break;
1004
987
	case PARENTS_OPTION:
1005
	case PARENTS_OPTION:
988
	  flag_path = 1;
1006
	  flag_path = 1;
989
	  break;
1007
	  break;
(-)coreutils-5.0.91.old/src/install.c (+2 lines)
Lines 247-252 Link Here
247
  x->xstat = stat;
247
  x->xstat = stat;
248
  x->dest_info = NULL;
248
  x->dest_info = NULL;
249
  x->src_info = NULL;
249
  x->src_info = NULL;
250
251
  x->attr_pattern = NULL;  /* no extended attributes */
250
}
252
}
251
253
252
int
254
int
(-)coreutils-5.0.91.old/src/mv.c (+2 lines)
Lines 138-143 Link Here
138
  x->xstat = lstat;
138
  x->xstat = lstat;
139
  x->dest_info = NULL;
139
  x->dest_info = NULL;
140
  x->src_info = NULL;
140
  x->src_info = NULL;
141
142
  x->attr_pattern = "";  /* all extended attributes */
141
}
143
}
142
144
143
/* If PATH is an existing directory, return nonzero, else 0.  */
145
/* If PATH is an existing directory, return nonzero, else 0.  */

Return to bug 37682