]> Dogcows Code - chaz/tar/commitdiff
tar: imply --xattrs when --xattrs-{inc,exc}lude used
authorPavel Raiskup <praiskup@redhat.com>
Thu, 23 May 2013 09:36:23 +0000 (11:36 +0200)
committerSergey Poznyakoff <gray@gnu.org.ua>
Fri, 14 Feb 2014 10:32:34 +0000 (12:32 +0200)
Options --xattrs-include=MASK and --xattrs-exclude=MASK now turn
on the --xattrs option.

Fix also bug in printing in xattrs.c - don't print when option is
negative.

* src/tar.c (set_xattr_option): New static function.
(parse_opt): Call new function when --xatrrs, --xattrs-include or
--xattrs-exclude option is used.
* src/xattrs.c (xattrs_print, xattrs_print_char): Expect positive
values in options.

src/tar.c
src/xattrs.c

index 85248091b98b149743d76406805baf6093f8ca28..08f334f554f50f0376576baaf51aa2199549f9de 100644 (file)
--- a/src/tar.c
+++ b/src/tar.c
@@ -167,6 +167,14 @@ set_archive_format (char const *name)
   archive_format = p->fmt;
 }
 
+static void
+set_xattr_option (int value)
+{
+  if (value == 1)
+    set_archive_format ("posix");
+  xattrs_option = value;
+}
+
 const char *
 archive_format_string (enum archive_format fmt)
 {
@@ -2095,16 +2103,16 @@ parse_opt (int key, char *arg, struct argp_state *state)
       break;
 
     case XATTR_OPTION:
-      set_archive_format ("posix");
-      xattrs_option = 1;
+      set_xattr_option (1);
       break;
 
     case NO_XATTR_OPTION:
-      xattrs_option = -1;
+      set_xattr_option (-1);
       break;
 
     case XATTR_INCLUDE:
     case XATTR_EXCLUDE:
+      set_xattr_option (1);
       xattrs_mask_add (arg, (key == XATTR_INCLUDE));
       break;
 
index dbe496620572a7f23c07e8f16bf037d2cf96b9b8..dbaa2092f5a208a280c3cb5b26f819701db235eb 100644 (file)
@@ -695,7 +695,7 @@ xattrs_print_char (struct tar_stat_info const *st, char *output)
   if (selinux_context_option > 0 && st->cntx_name)
     *output = '.';
 
-  if (acls_option && (st->acls_a_len || st->acls_d_len))
+  if (acls_option > 0 && (st->acls_a_len || st->acls_d_len))
     *output = '+';
 }
 
@@ -706,11 +706,11 @@ xattrs_print (struct tar_stat_info const *st)
     return;
 
   /* selinux */
-  if (selinux_context_option && st->cntx_name)
+  if (selinux_context_option > 0 && st->cntx_name)
     fprintf (stdlis, "  s: %s\n", st->cntx_name);
 
   /* acls */
-  if (acls_option && (st->acls_a_len || st->acls_d_len))
+  if (acls_option > 0 && (st->acls_a_len || st->acls_d_len))
     {
       fprintf (stdlis, "  a: ");
       acls_one_line ("", ',', st->acls_a_ptr, st->acls_a_len);
@@ -719,7 +719,7 @@ xattrs_print (struct tar_stat_info const *st)
     }
 
   /* xattrs */
-  if (xattrs_option && st->xattr_map_size)
+  if (xattrs_option > 0 && st->xattr_map_size)
     {
       int i;
 
This page took 0.022376 seconds and 4 git commands to generate.