Warn “file changed as we read it” less often

* src/create.c (dump_file0): Remove an fstatat call that is
unnecessary because the file wasn’t read so we can treat the first
fstatat as atomic.  Warn “file changed” when the file’s size,
mtime, user ID, group ID, or mode changes, instead of when the
file’s size or ctime changes.  Also, when such a change happens,
do not change exit status if --ignore-failed-read.  Finally, don’t
attempt to change atime back if it didn’t change.
This commit is contained in:
Paul Eggert
2022-06-09 15:50:06 -07:00
parent bc7e758b27
commit c1027eb5ae
3 changed files with 61 additions and 20 deletions

View File

@@ -2859,7 +2859,7 @@ Ignore exit codes of subprocesses. @xref{Writing to an External Program}.
@opsummary{ignore-failed-read}
@item --ignore-failed-read
Do not exit unsuccessfully merely because an unreadable file was encountered.
Do not exit unsuccessfully merely because reading failed.
@xref{Ignore Failed Read}.
@opsummary{ignore-zeros}
@@ -4641,7 +4641,8 @@ Disable all warning messages.
@item file-changed
@samp{%s: file changed as we read it}
@item failed-read
Suppresses warnings about unreadable files or directories. This
Suppresses warnings about read failures, which can occur if files
or directories are unreadable, or if they change while being read. This
keyword applies only if used together with the @option{--ignore-failed-read}
option. @xref{Ignore Failed Read}.
@end table
@@ -5764,11 +5765,12 @@ Disable SELinux context support.
@table @option
@item --ignore-failed-read
@opindex ignore-failed-read
Do not exit with nonzero on unreadable files or directories.
Do not exit with nonzero if there are mild problems while reading.
@end table
This option has effect only during creation. It instructs tar to
treat as mild conditions any missing or unreadable files (directories).
treat as mild conditions any missing or unreadable files (directories),
or files that change while reading.
Such failures don't affect the program exit code, and the
corresponding diagnostic messages are marked as warnings, not errors.
These warnings can be suppressed using the