Respect --ignore-failed-read in file_removed_diag (bug#68075)

* src/misc.c (file_removed_diag): Guard set_exit_status call
with !ignore_failed_read_option, consistent with stat_diag and
other diagnostic functions.
* tests/filerem03.at: New test.
* tests/testsuite.at: Include it.
* tests/Makefile.am: Add it.
Copyright-paperwork-exempt: yes

Signed-off-by: Marco Nenciarini <marco.nenciarini@enterprisedb.com>
This commit is contained in:
Marco Nenciarini
2026-03-11 19:18:26 +01:00
committed by Paul Eggert
parent dda26d5c53
commit dcb8c5f932
4 changed files with 50 additions and 1 deletions

View File

@@ -1445,7 +1445,8 @@ file_removed_diag (const char *name, bool top_level,
{
warnopt (WARN_FILE_REMOVED, 0, _("%s: File removed before we read it"),
quotearg_colon (name));
set_exit_status (TAREXIT_DIFFERS);
if (!ignore_failed_read_option)
set_exit_status (TAREXIT_DIFFERS);
}
else
diagfn (name);

View File

@@ -143,6 +143,7 @@ TESTSUITE_AT = \
extrac31.at\
filerem01.at\
filerem02.at\
filerem03.at\
grow.at\
gzip.at\
ignfail.at\

46
tests/filerem03.at Normal file
View File

@@ -0,0 +1,46 @@
# Process this file with autom4te to create testsuite. -*- Autotest -*-
# Test suite for GNU tar.
# Copyright 2026 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/>.
# Description: see filerem01.at
# This test case verifies that --ignore-failed-read makes tar exit
# with code 0 when a file disappears during archiving, instead of
# TAREXIT_DIFFERS (1).
AT_SETUP([file removed with --ignore-failed-read])
AT_KEYWORDS([create incremental listed filechange filerem filerem03])
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 -c -f archive.tar \
--listed-incremental db --ignore-failed-read -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])
AT_CLEANUP

View File

@@ -393,6 +393,7 @@ m4_include([incr11.at])
AT_BANNER([Files removed while archiving])
m4_include([filerem01.at])
m4_include([filerem02.at])
m4_include([filerem03.at])
AT_BANNER([Directories removed while archiving])
m4_include([dirrem01.at])