coreutils/coreutils-silentmv.patch

98 lines
3.3 KiB
Diff

diff -urNp coreutils-7.2-orig/src/copy.c coreutils-7.2/src/copy.c
--- coreutils-7.2-orig/src/copy.c 2009-07-08 16:21:46.000000000 +0200
+++ coreutils-7.2/src/copy.c 2009-07-08 16:31:43.000000000 +0200
@@ -139,6 +139,22 @@ copy_attr_error (struct error_context *c
int err = errno;
va_list ap;
+ if (errno != ENOTSUP && errno != ENODATA)
+ {
+ /* use verror module to print error message */
+ va_start (ap, fmt);
+ verror (0, err, fmt, ap);
+ va_end (ap);
+ }
+}
+
+static void
+copy_attr_allerror (struct error_context *ctx ATTRIBUTE_UNUSED,
+ char const *fmt, ...)
+{
+ int err = errno;
+ va_list ap;
+
/* use verror module to print error message */
va_start (ap, fmt);
verror (0, err, fmt, ap);
@@ -163,12 +179,13 @@ copy_attr_by_fd (char const *src_path, i
{
struct error_context ctx =
{
- .error = copy_attr_error,
+ .error = x->require_preserve_xattr ? copy_attr_allerror : copy_attr_error,
.quote = copy_attr_quote,
.quote_free = copy_attr_free
};
return 0 == attr_copy_fd (src_path, src_fd, dst_path, dst_fd, 0,
- x->reduce_diagnostics ? NULL : &ctx);
+ (x->reduce_diagnostics
+ && !x->require_preserve_xattr) ? NULL : &ctx);
}
static bool
@@ -177,12 +194,13 @@ copy_attr_by_name (char const *src_path,
{
struct error_context ctx =
{
- .error = copy_attr_error,
+ .error = x->require_preserve_xattr ? copy_attr_allerror : copy_attr_error,
.quote = copy_attr_quote,
.quote_free = copy_attr_free
};
return 0 == attr_copy_file (src_path, dst_path, 0,
- x-> reduce_diagnostics ? NULL :&ctx);
+ (x-> reduce_diagnostics
+ && !x->require_preserve_xattr) ? NULL :&ctx);
}
#else /* USE_XATTR */
@@ -465,7 +483,7 @@ copy_reg (char const *src_name, char con
security_context_t con = NULL;
if (getfscreatecon (&con) < 0)
{
- if (!x->reduce_diagnostics)
+ if (!x->reduce_diagnostics || x->require_preserve_context)
error (0, errno, _("failed to get file system create context"));
if (x->require_preserve_context)
{
@@ -478,7 +496,7 @@ copy_reg (char const *src_name, char con
{
if (fsetfilecon (dest_desc, con) < 0)
{
- if (!x->reduce_diagnostics)
+ if (!x->reduce_diagnostics || x->require_preserve_context)
error (0, errno,
_("failed to set the security context of %s to %s"),
quote_n (0, dst_name), quote_n (1, con));
@@ -1731,7 +1749,7 @@ copy_internal (char const *src_name, cha
{
if (setfscreatecon (con) < 0)
{
- if (!x->reduce_diagnostics)
+ if (!x->reduce_diagnostics || x->require_preserve_context)
error (0, errno,
_("failed to set default file creation context to %s"),
quote (con));
@@ -1745,9 +1763,9 @@ copy_internal (char const *src_name, cha
}
else
{
- if (errno != ENOTSUP && errno != ENODATA)
+ if ((errno != ENOTSUP && errno != ENODATA) || x->require_preserve_context)
{
- if (!x->reduce_diagnostics)
+ if (!x->reduce_diagnostics || x->require_preserve_context)
error (0, errno,
_("failed to get security context of %s"),
quote (src_name));