Blame SOURCES/tar-1.26-xattrs-skip-old-files-hangs.patch

b77676
diff --git a/THANKS b/THANKS
b77676
index e87381f..6fa0a9e 100644
b77676
--- a/THANKS
b77676
+++ b/THANKS
b77676
@@ -131,6 +131,7 @@ David Nugent		davidn@blaze.net.au
b77676
 David Shaw		david.shaw@alcatel.com.au
b77676
 David Steiner		dsteiner@ispa.uni-osnabrueck.de
b77676
 David Taylor		taylor@think.com
b77676
+Dawid			dpc@dpc.pw
b77676
 Dean Gaudet		dgaudet@watdragon.uwaterloo.ca
b77676
 Demizu Noritoshi	nori-d@is.aist-nara.ac.jp
b77676
 Denis Excoffier         denis.excoffier@free.fr
b77676
diff --git a/src/extract.c b/src/extract.c
b77676
index b622a2a..63e4d14 100644
b77676
--- a/src/extract.c
b77676
+++ b/src/extract.c
b77676
@@ -745,13 +745,13 @@ maybe_recoverable (char *file_name, bool regular, bool *interdir_made)
b77676
    in advance dramatically improves the following  performance of reading and
b77676
    writing a file).  If not restoring permissions, invert the INVERT_PERMISSIONS
b77676
    bits from the file's current permissions.  TYPEFLAG specifies the type of the
b77676
-   file.  FILE_CREATED indicates set_xattr has created the file */
b77676
+   file.  Returns non-zero when error occurs (while un-available xattrs is not
b77676
+   an error, rather no-op).  Non-zero FILE_CREATED indicates set_xattr has
b77676
+   created the file. */
b77676
 static int
b77676
 set_xattr (char const *file_name, struct tar_stat_info const *st,
b77676
            mode_t invert_permissions, char typeflag, int *file_created)
b77676
 {
b77676
-  int status = 0;
b77676
-
b77676
 #ifdef HAVE_XATTRS
b77676
   bool interdir_made = false;
b77676
 
b77676
@@ -759,17 +759,32 @@ set_xattr (char const *file_name, struct tar_stat_info const *st,
b77676
     {
b77676
       mode_t mode = current_stat_info.stat.st_mode & MODE_RWX & ~ current_umask;
b77676
 
b77676
-      do
b77676
-        status = mknodat (chdir_fd, file_name, mode ^ invert_permissions, 0);
b77676
-      while (status && maybe_recoverable ((char *)file_name, false,
b77676
-                                          &interdir_made));
b77676
+      for (;;)
b77676
+        {
b77676
+          if (!mknodat (chdir_fd, file_name, mode ^ invert_permissions, 0))
b77676
+            {
b77676
+              /* Successfully created file */
b77676
+              xattrs_xattrs_set (st, file_name, typeflag, 0);
b77676
+              *file_created = 1;
b77676
+              return 0;
b77676
+            }
b77676
 
b77676
-      xattrs_xattrs_set (st, file_name, typeflag, 0);
b77676
-      *file_created = 1;
b77676
+          switch (maybe_recoverable ((char *)file_name, false, &interdir_made))
b77676
+            {
b77676
+              case RECOVER_OK:
b77676
+                continue;
b77676
+              case RECOVER_NO:
b77676
+                skip_member ();
b77676
+                open_error (file_name);
b77676
+                return 1;
b77676
+              case RECOVER_SKIP:
b77676
+                return 0;
b77676
+            }
b77676
+        }
b77676
     }
b77676
 #endif
b77676
 
b77676
-  return(status);
b77676
+  return 0;
b77676
 }
b77676
 
b77676
 /* Fix the statuses of all directories whose statuses need fixing, and
b77676
@@ -1089,11 +1104,7 @@ extract_file (char *file_name, int typeflag)
b77676
       int file_created = 0;
b77676
       if (set_xattr (file_name, &current_stat_info, invert_permissions,
b77676
                      typeflag, &file_created))
b77676
-        {
b77676
-          skip_member ();
b77676
-          open_error (file_name);
b77676
-          return 1;
b77676
-        }
b77676
+        return 1;
b77676
 
b77676
       while ((fd = open_output_file (file_name, typeflag, mode,
b77676
                                      file_created, &current_mode,
b77676
diff --git a/tests/Makefile.am b/tests/Makefile.am
b77676
index 2a70314..8e1ef8d 100644
b77676
--- a/tests/Makefile.am
b77676
+++ b/tests/Makefile.am
b77676
@@ -200,6 +200,7 @@ TESTSUITE_AT = \
b77676
  xattr04.at\
b77676
  xattr05.at\
b77676
  xattr06.at\
b77676
+ xattr07.at\
b77676
  acls01.at\
b77676
  acls02.at\
b77676
  acls03.at\
b77676
diff --git a/tests/testsuite.at b/tests/testsuite.at
b77676
index ebce9cc..3eb0eee 100644
b77676
--- a/tests/testsuite.at
b77676
+++ b/tests/testsuite.at
b77676
@@ -361,6 +361,7 @@ m4_include([xattr03.at])
b77676
 m4_include([xattr04.at])
b77676
 m4_include([xattr05.at])
b77676
 m4_include([xattr06.at])
b77676
+m4_include([xattr07.at])
b77676
 
b77676
 m4_include([acls01.at])
b77676
 m4_include([acls02.at])
b77676
diff --git a/tests/xattr07.at b/tests/xattr07.at
b77676
new file mode 100644
b77676
index 0000000..a834981
b77676
--- /dev/null
b77676
+++ b/tests/xattr07.at
b77676
@@ -0,0 +1,73 @@
b77676
+# Process this file with autom4te to create testsuite. -*- Autotest -*-
b77676
+#
b77676
+# Test suite for GNU tar.
b77676
+# Copyright 2011, 2013-2014, 2016 Free Software Foundation, Inc.
b77676
+
b77676
+# This file is part of GNU tar.
b77676
+
b77676
+# GNU tar is free software; you can redistribute it and/or modify
b77676
+# it under the terms of the GNU General Public License as published by
b77676
+# the Free Software Foundation; either version 3 of the License, or
b77676
+# (at your option) any later version.
b77676
+
b77676
+# GNU tar is distributed in the hope that it will be useful,
b77676
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
b77676
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
b77676
+# GNU General Public License for more details.
b77676
+
b77676
+# You should have received a copy of the GNU General Public License
b77676
+# along with this program.  If not, see <http://www.gnu.org/licenses/>.
b77676
+#
b77676
+# Test description:
b77676
+# Test that --keep-old-files doesn't change xattrs of already existing file.
b77676
+# Per report:
b77676
+# https://lists.gnu.org/archive/html/bug-tar/2016-10/msg00001.html
b77676
+
b77676
+AT_SETUP([xattrs: xattrs and --skip-old-files])
b77676
+AT_KEYWORDS([xattrs xattr07])
b77676
+
b77676
+AT_TAR_CHECK([
b77676
+AT_XATTRS_PREREQ
b77676
+mkdir dir
b77676
+genfile --file dir/file
b77676
+genfile --file dir/file2
b77676
+
b77676
+setfattr -n user.test -v OurDirValue dir
b77676
+setfattr -n user.test -v OurFileValue dir/file
b77676
+setfattr -n user.test -v OurFileValue dir/file2
b77676
+
b77676
+tar --xattrs -cf archive.tar dir
b77676
+
b77676
+setfattr -n user.test -v OurDirValue2 dir
b77676
+setfattr -n user.test -v OurFileValue2 dir/file
b77676
+setfattr -n user.test -v OurFileValue2 dir/file2
b77676
+
b77676
+# Check that tar continues to file2 too!
b77676
+tar --xattrs -xvf archive.tar --skip-old-files
b77676
+tar --xattrs -xvf archive.tar --keep-old-files
b77676
+
b77676
+getfattr -h -d dir         | grep -v -e '^#' -e ^$
b77676
+getfattr -h -d dir/file    | grep -v -e '^#' -e ^$
b77676
+getfattr -h -d dir/file2   | grep -v -e '^#' -e ^$
b77676
+],
b77676
+[0],
b77676
+[dir/
b77676
+dir/file
b77676
+dir/file2
b77676
+dir/
b77676
+dir/file
b77676
+dir/file2
b77676
+user.test="OurDirValue2"
b77676
+user.test="OurFileValue2"
b77676
+user.test="OurFileValue2"
b77676
+], [tar: dir: skipping existing file
b77676
+tar: dir/file: skipping existing file
b77676
+tar: dir/file: skipping existing file
b77676
+tar: dir/file2: skipping existing file
b77676
+tar: dir/file2: skipping existing file
b77676
+tar: dir/file: Cannot open: File exists
b77676
+tar: dir/file2: Cannot open: File exists
b77676
+tar: Exiting with failure status due to previous errors
b77676
+])
b77676
+
b77676
+AT_CLEANUP
b77676
From f2a7560718946e0920b55419f0953953bf824077 Mon Sep 17 00:00:00 2001
b77676
From: Pavel Raiskup <praiskup@redhat.com>
b77676
Date: Mon, 28 Nov 2016 08:44:42 +0100
b77676
Subject: [PATCH] tests: more deterministic xattr07
b77676
b77676
* tests/xattr07.at: Define order of files within tested archive.
b77676
---
b77676
 tests/xattr07.at | 2 +-
b77676
 1 file changed, 1 insertion(+), 1 deletion(-)
b77676
b77676
diff --git a/tests/xattr07.at b/tests/xattr07.at
b77676
index a834981..47d54b8 100644
b77676
--- a/tests/xattr07.at
b77676
+++ b/tests/xattr07.at
b77676
@@ -36,7 +36,7 @@ setfattr -n user.test -v OurDirValue dir
b77676
 setfattr -n user.test -v OurFileValue dir/file
b77676
 setfattr -n user.test -v OurFileValue dir/file2
b77676
 
b77676
-tar --xattrs -cf archive.tar dir
b77676
+tar --xattrs --no-recursion -cf archive.tar dir dir/file dir/file2
b77676
 
b77676
 setfattr -n user.test -v OurDirValue2 dir
b77676
 setfattr -n user.test -v OurFileValue2 dir/file
b77676
-- 
b77676
2.13.5
b77676