Fix handling of files removed during incremental dumps.

Changes to src/create.c and src/incremen.c are partially
based on patch from Alexander Peslyak <solar at openwall.com>.

The new testcases require paxutils commit f653a2b or later.

* src/common.h (struct name): New member `cmdline'.
(dump_file): Change type of the 2nd argument to bool.
(file_removed_diag, dir_removed_diag): New prototypes.
(addname): New argument `cmdline'.
(name_from_list): Change return value.
* src/create.c (dump_dir0, dump_dir): top_level is bool.
(create_archive): Update calls to name_from_list.
Take advantage of the name->cmdline to set top_level argument
during incremental backups.
(dump_file0): top_level is bool.
Do not bail out if a no-top-level file disappears during incremental
backup, use file_removed_diag instead.
(dump_filed): top_level is bool.
* src/incremen.c (update_parent_directory): Silently ignore
ENOENT.  It should have already been reported elsewhere.
(scan_directory): Use dir_removed_diag to report missing directories.
* src/misc.c (file_removed_diag, dir_removed_diag): New functions.
* src/names.c (name_gather): Set ->cmdname.
(addname): Likewise. All uses updated.
(name_from_list): Return struct name const *. All uses updated.

* tests/filerem01.at: New testcase.
* tests/filerem02.at: New testcase.
* tests/Makefile.am, tests/testsuite.at: Add filerem01.at, filerem02.at
* tests/grow.at, test/truncate.at: Use new syntax for genfile --run.

* NEWS: Update.
* doc/tar.texi: Minor fix.
This commit is contained in:
Sergey Poznyakoff
2009-08-08 19:53:54 +03:00
parent 2b1bffbad6
commit 51aee274e8
15 changed files with 250 additions and 51 deletions

View File

@@ -69,6 +69,8 @@ TESTSUITE_AT = \
extrac06.at\
extrac07.at\
extrac08.at\
filerem01.at\
filerem02.at\
gzip.at\
grow.at\
incremental.at\

88
tests/filerem01.at Normal file
View File

@@ -0,0 +1,88 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright (C) 2009 Free Software Foundation, Inc.
# This program 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, or (at your option)
# any later version.
# This program 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, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
AT_SETUP([file removed as we read it (ca. 22 seconds)])
AT_KEYWORDS([create incremental filechange filerem filerem01])
AT_TAR_CHECK([
mkdir dir
mkdir dir/sub
genfile --file dir/file1
genfile --file dir/sub/file2
genfile --run --checkpoint=3 --unlink dir/file1 -- \
tar --blocking-factor=1 --checkpoint=1 --checkpoint-action='sleep=1' \
--checkpoint-action='echo' -c -f archive.tar \
--listed-incremental db -v dir >/dev/null
],
[0],
[ignore],
[tar: dir: Directory is new
tar: dir/sub: Directory is new
tar: dir/file1: File removed before we read it
],[],[],[gnu, posix])
# Timing information:
#
# For -Hgnu the above command line takes about 8 seconds to execute and
# produces:
#
# tar: dir: Directory is new
# tar: dir/sub: Directory is new
# dir/
# tar: Write checkpoint 1
# tar: Write checkpoint 2
# dir/sub/
# tar: Write checkpoint 3
# tar: Write checkpoint 4
# dir/file1
# tar: Write checkpoint 5
# dir/sub/file2
# tar: Write checkpoint 6
# tar: Write checkpoint 7
# tar: Write checkpoint 8
#
# For -Hposix the above command line takes about 14 seconds to execute and
# produces:
#
# ./tar: dir: Directory is new
# ./tar: dir/sub: Directory is new
# dir/
# ./tar: Write checkpoint 1
# ./tar: Write checkpoint 2
# ./tar: Write checkpoint 3
# dir/sub/
# ./tar: Write checkpoint 4
# ./tar: Write checkpoint 5
# ./tar: Write checkpoint 6
# dir/file1
# ./tar: Write checkpoint 7
# ./tar: Write checkpoint 8
# ./tar: Write checkpoint 9
# dir/sub/file2
# ./tar: Write checkpoint 10
# ./tar: Write checkpoint 11
# ./tar: Write checkpoint 12
# ./tar: Write checkpoint 13
# ./tar: Write checkpoint 14
AT_CLEANUP

50
tests/filerem02.at Normal file
View File

@@ -0,0 +1,50 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright (C) 2009 Free Software Foundation, Inc.
# This program 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, or (at your option)
# any later version.
# This program 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/>.
# Description: see filerem01.at
# This test case checks if the tar exit code is still 2 if a
# file or directory disappears that is explicitly mentioned
# in the command line.
AT_SETUP([toplevel file removed (ca. 24 seconds)])
AT_KEYWORDS([create incremental filechange filerem filerem02])
AT_TAR_CHECK([
mkdir dir
mkdir dir/sub
genfile --file dir/file1
genfile --file dir/sub/file2
mkdir dir2
genfile --file dir2/file1
genfile --run --checkpoint=3 --exec 'rm -rf dir2' -- \
tar --blocking-factor=1 --checkpoint=1 --checkpoint-action='sleep=1' \
--checkpoint-action='echo' -c -f archive.tar \
--listed-incremental db -v --warning=no-new-dir dir dir2 >/dev/null
],
[2],
[ignore],
[tar: dir2: Cannot stat: No such file or directory
tar: dir2/file1: File removed before we read it
tar: Exiting with failure status due to previous errors
],[],[],[gnu, posix])
# Timing information: see filerem01.at
AT_CLEANUP

View File

@@ -27,8 +27,7 @@ AT_KEYWORDS([grow filechange])
AT_TAR_CHECK([
genfile --file foo --length 50000k
genfile --file baz
genfile --run 'tar -vcf bar foo baz' --checkpoint 10 --length 1024 \
--append foo
genfile --run --checkpoint 10 --length 1024 --append foo -- tar --checkpoint -vcf bar foo baz
],
[1],
[foo

View File

@@ -154,6 +154,10 @@ m4_include([incr03.at])
m4_include([incr04.at])
m4_include([incr05.at])
m4_include([incr06.at])
m4_include([filerem01.at])
m4_include([filerem02.at])
m4_include([rename01.at])
m4_include([rename02.at])
m4_include([rename03.at])

View File

@@ -32,7 +32,7 @@ AT_KEYWORDS([truncate filechange])
AT_TAR_CHECK([
genfile --file foo --length 50000k
genfile --file baz
genfile --run 'tar -vcf bar foo baz' --checkpoint 10 --length 49995k --truncate foo
genfile --run --checkpoint 10 --length 49995k --truncate foo -- tar --checkpoint -vcf bar foo baz
echo Exit status: $?
echo separator
sleep 1