Take into account chdir_fd when extracting from incremental dumps.

* src/common.h (tar_savedir): New prototype.
* src/misc.c (tar_savedir): New function.
(remove_any_file): Use tar_savedir.
* src/incremen.c (try_purge_directory): Use tar_savedir.
* src/update.c (update_archive): Use tar_savedir.
* tests/incr07.at: New testcase.
* tests/Makefile.am (TESTSUITE_AT): Add new test.
* tests/testsuite.at: Likewise.
* THANKS: Updated.
This commit is contained in:
Sergey Poznyakoff
2013-09-15 10:13:45 +03:00
parent 0ea6e68655
commit 738fb9c2f4
8 changed files with 142 additions and 17 deletions

View File

@@ -111,6 +111,7 @@ TESTSUITE_AT = \
incr04.at\
incr05.at\
incr06.at\
incr07.at\
indexfile.at\
ignfail.at\
label01.at\

106
tests/incr07.at Normal file
View File

@@ -0,0 +1,106 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2009, 2013 Free Software Foundation, Inc.
#
# GNU tar is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# (at your option) any later version.
#
# GNU tar is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
AT_SETUP([incremental restores with -C])
AT_KEYWORDS([incremental extract incr07])
# Tar 1.26 had problems extracting from incremental restores when given
# the -C option. The code in incremen.c:try_purge_directory and
# misc.c:remove_any_file was using savedir(), which ignored eventual changes
# in the current working directory and caused the malfunctioning.
#
# The problem was reported by Piotr Rotter on 2013-03-22.
#
# This testcase is based on scripts provided by Piotr Rotter and Nathan
# Stratton Treadway.
#
# References: <514C8F56.90900@active24.pl>,
# http://lists.gnu.org/archive/html/bug-tar/2013-03/msg00036.html,
# <20130326181922.GZ3732@shire.ontko.com>,
# http://lists.gnu.org/archive/html/bug-tar/2013-03/msg00042.html,
# <20130327051828.GA3732@shire.ontko.com>,
# http://lists.gnu.org/archive/html/bug-tar/2013-03/msg00043.html,
# <20130327054957.GB3732@shire.ontko.com>,
# http://lists.gnu.org/archive/html/bug-tar/2013-03/msg00044.html
AT_TAR_CHECK([
mkdir A
echo 'a' > A/a
echo 'a' > A/b
decho C0
tar -g test.snar -vcf test.0.tar A
echo 'a' > A/c
decho C1
tar -g test.snar -vcf test.1.tar A
rm -f A/a
decho C2
tar -g test.snar -vcf test.2.tar A
mkdir ext
rm -rf A
decho E0
tar -g test.snar -vxf test.0.tar -C ext/
decho E1
tar -g test.snar -vxf test.1.tar -C ext/
mkdir ext/A/B
touch ext/A/B/file
decho E2
tar -g test.snar -vxf test.2.tar -C ext/
echo FIN
test -d A && echo >&2 "toplevel A exists"
exit 0
],
[0],
[C0
A/
A/a
A/b
C1
A/
A/c
C2
A/
E0
A/
A/a
A/b
E1
A/
A/c
E2
A/
tar: Deleting 'A/a'
tar: Deleting 'A/B'
FIN
],
[C0
tar: A: Directory is new
C1
C2
E0
E1
E2
],[],[],[gnu, oldgnu, posix])
AT_CLEANUP

View File

@@ -296,6 +296,7 @@ m4_include([incr03.at])
m4_include([incr04.at])
m4_include([incr05.at])
m4_include([incr06.at])
m4_include([incr07.at])
AT_BANNER([Files removed while archiving])
m4_include([filerem01.at])