Fix handling of linked rename chains in incremental backups

* src/incremen.c: Change the meaning of the DIRF_RENAMED flag.  Now it
marks a directory which is the last one in a chain of renames.
Regular renamed directories are recognized by their orig member being
non-NULL.  Directories marked with DIRF_RENAMED start encoding of renames.
(procdir): Clear DIRF_RENAMED flag on directories which are origins for
renames.
(makedumpdir): Use the orig member to check if the directory is a
result of a rename.
(store_rename): Move the check for DIR_IS_RENAMED to the caller. Don't
clear the DIRF_RENAMED, it is not needed any more.

* tests/rename06.at: New test.
* tests/Makefile.am: Add rename06.at
* tests/testsuite.at: Likewise.
This commit is contained in:
Sergey Poznyakoff
2020-02-15 10:57:35 +02:00
parent 8d90723d30
commit 41654f91f0
4 changed files with 133 additions and 40 deletions

View File

@@ -200,6 +200,7 @@ TESTSUITE_AT = \
rename03.at\
rename04.at\
rename05.at\
rename06.at\
remfiles01.at\
remfiles02.at\
remfiles03.at\

88
tests/rename06.at Normal file
View File

@@ -0,0 +1,88 @@
# Test suite for GNU tar.
# Copyright 2020 Free Software Foundation, Inc.
#
# This file is part of GNU tar.
#
# 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([chained renames])
AT_KEYWORDS([incremental rename06 rename])
# Description: test whether chained renames are processed correctly
# during the incremental archive creation. Tar 1.32.90 failed to
# encode them.
# Reported by: Deweloper <deweloper@wp.pl>
# References: <20200214100922.44c43334@amazur-u.kat.adbgroup.pl>,
# https://lists.gnu.org/archive/html/bug-tar/2020-02/msg00008.html
AT_TAR_CHECK([
AT_SORT_PREREQ
decho Creating directory structure
mkdir test test/d1 test/d2
genfile --file test/d1/file1
genfile --file test/d2/file2
decho First dump
tar -c -g 0.snar -C test -f backup0.tar .
decho Altering directory structure
genfile --file test/d2/file3
mv test/d1 test/d3
mv test/d2 test/d1
decho Second dump
cp 0.snar 1.snar
tar -vc -g 1.snar -C test -f backup1.tar .
mkdir test1
decho First extract
tar -C test1 -x -g /dev/null -f backup0.tar
decho Second extract
tar -C test1 -x -g /dev/null -f backup1.tar
decho Resulting directory
find test1 | sort
],
[0],
[Creating directory structure
First dump
Altering directory structure
Second dump
./
./d1/
./d3/
./d1/file3
First extract
Second extract
Resulting directory
test1
test1/d1
test1/d1/file2
test1/d1/file3
test1/d3
test1/d3/file1
],
[Creating directory structure
First dump
Altering directory structure
Second dump
tar: ./d1: Directory has been renamed from './d2'
tar: ./d3: Directory has been renamed from './d1'
First extract
Second extract
Resulting directory
],[],[],[gnu, oldgnu, posix])
AT_CLEANUP

View File

@@ -390,6 +390,7 @@ m4_include([rename02.at])
m4_include([rename03.at])
m4_include([rename04.at])
m4_include([rename05.at])
m4_include([rename06.at])
m4_include([chtype.at])
AT_BANNER([Ignore failing reads])