diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-11-16 13:55:15 +0200 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2017-11-16 14:22:48 +0200 |
commit | 32e51de2af3ac51dd7a00754d1f6d241ea3c0403 (patch) | |
tree | 905870435765db547cbe51c1c4a6f3317bdc81c2 | |
parent | 560f67c9f03072e36d3268c16c2b0a0e810749c1 (diff) | |
download | tar-32e51de2af3ac51dd7a00754d1f6d241ea3c0403.tar.gz |
New option --warning=failed-read
* NEWS: Document the --warning=failed-read option.
* doc/tar.texi: Likewise.
* doc/tar.1: Likewise.
* src/common.h (WARN_FAILED_READ): New constant.
(WARNING_ENABLED): New macro.
* src/misc.c (close_diag, open_diag)
(read_diag_details, readlink_diag)
(savedir_diag, seek_diag_details)
(stat_diag): Suppress warnings if WARN_FAILED_READ is set.
* src/warning.c (failed-read): New keyword.
-rw-r--r-- | NEWS | 12 | ||||
-rw-r--r-- | doc/tar.1 | 8 | ||||
-rw-r--r-- | doc/tar.texi | 13 | ||||
-rw-r--r-- | src/common.h | 5 | ||||
-rw-r--r-- | src/misc.c | 35 | ||||
-rw-r--r-- | src/warning.c | 4 |
6 files changed, 66 insertions, 11 deletions
@@ -37,6 +37,18 @@ This helps the output of 'tar' to be more deterministic. In some cases tar would restore the directory permissions too early, causing subsequent link extractions in that directory to fail. +* The --warnings=failed-read option + +This new warning control option suppresses warning messages about +unreadable files and directories. It has effect only if used together +with the --ignore-failed-read option. + +* The --warnings=none option now suppresses all warnings + +This includes warnings about unreadable files produced when +--ignore-failed-read is in effect. To output these, use +--warnings=none --warnings=no-failed-read. + version 1.29 - Sergey Poznyakoff, 2016-05-16 @@ -13,7 +13,7 @@ .\" .\" You should have received a copy of the GNU General Public License .\" along with this program. If not, see <http://www.gnu.org/licenses/>. -.TH TAR 1 "March 23, 2016" "TAR" "GNU TAR Manual" +.TH TAR 1 "November 16, 2017" "TAR" "GNU TAR Manual" .SH NAME tar \- an archiving utility .SH SYNOPSIS @@ -1163,6 +1163,12 @@ Keywords applicable for \fBtar --create\fR: .TP .B file-changed "%s: file changed as we read it" +.TP +.B failed-read +Suppresses warnings about unreadable files or directories. This +keyword applies only if used together with the +.B \-\-ignore\-failed\-read +option. .HP Keywords applicable for \fBtar --extract\fR: .TP diff --git a/doc/tar.texi b/doc/tar.texi index 09c4fbb3..572e3dd9 100644 --- a/doc/tar.texi +++ b/doc/tar.texi @@ -4610,6 +4610,10 @@ Disable all warning messages. @cindex @samp{file changed as we read it}, warning message @item file-changed @samp{%s: file changed as we read it} +@item failed-read +Suppresses warnings about unreadable files or directories. This +keyword applies only if used together with the @option{--ignore-failed-read} +option. @xref{Ignore Failed Read}. @end table @subheading Keywords applicable for @command{tar --extract} @@ -5726,7 +5730,7 @@ Disable SELinux context support. @end table @node Ignore Failed Read -@subsection Ignore Fail Read +@subsection Ignore Failed Read @table @option @item --ignore-failed-read @@ -5734,6 +5738,13 @@ Disable SELinux context support. Do not exit with nonzero on unreadable files or directories. @end table +This option has effect only during creation. It instructs tar to +treat as mild conditions any missing or unreadable files (directories). +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 +@option{--warning=failed-read} option (@pxref{warnings}). + @node extract options @section Options Used by @option{--extract} @cindex options for use with @option{--extract} diff --git a/src/common.h b/src/common.h index e49bd9f1..964f0b64 100644 --- a/src/common.h +++ b/src/common.h @@ -927,6 +927,7 @@ void checkpoint_flush_actions (void); #define WARN_EXISTING_FILE 0x00100000 #define WARN_XATTR_WRITE 0x00200000 #define WARN_RECORD_SIZE 0x00400000 +#define WARN_FAILED_READ 0x00800000 /* These warnings are enabled by default in verbose mode: */ #define WARN_VERBOSE_WARNINGS (WARN_RENAME_DIRECTORY|WARN_NEW_DIRECTORY|\ @@ -938,10 +939,12 @@ void set_warning_option (const char *arg); extern int warning_option; +#define WARNING_ENABLED(opt) (warning_option & (opt)) + #define WARNOPT(opt,args) \ do \ { \ - if (warning_option & opt) WARN (args); \ + if (WARNING_ENABLED(opt)) WARN (args); \ } \ while (0) @@ -1044,7 +1044,10 @@ void close_diag (char const *name) { if (ignore_failed_read_option) - close_warn (name); + { + if (WARNING_ENABLED(WARN_FAILED_READ)) + close_warn (name); + } else close_error (name); } @@ -1053,7 +1056,10 @@ void open_diag (char const *name) { if (ignore_failed_read_option) - open_warn (name); + { + if (WARNING_ENABLED(WARN_FAILED_READ)) + open_warn (name); + } else open_error (name); } @@ -1062,7 +1068,10 @@ void read_diag_details (char const *name, off_t offset, size_t size) { if (ignore_failed_read_option) - read_warn_details (name, offset, size); + { + if (WARNING_ENABLED(WARN_FAILED_READ)) + read_warn_details (name, offset, size); + } else read_error_details (name, offset, size); } @@ -1071,7 +1080,10 @@ void readlink_diag (char const *name) { if (ignore_failed_read_option) - readlink_warn (name); + { + if (WARNING_ENABLED(WARN_FAILED_READ)) + readlink_warn (name); + } else readlink_error (name); } @@ -1080,7 +1092,10 @@ void savedir_diag (char const *name) { if (ignore_failed_read_option) - savedir_warn (name); + { + if (WARNING_ENABLED(WARN_FAILED_READ)) + savedir_warn (name); + } else savedir_error (name); } @@ -1089,7 +1104,10 @@ void seek_diag_details (char const *name, off_t offset) { if (ignore_failed_read_option) - seek_warn_details (name, offset); + { + if (WARNING_ENABLED(WARN_FAILED_READ)) + seek_warn_details (name, offset); + } else seek_error_details (name, offset); } @@ -1098,7 +1116,10 @@ void stat_diag (char const *name) { if (ignore_failed_read_option) - stat_warn (name); + { + if (WARNING_ENABLED(WARN_FAILED_READ)) + stat_warn (name); + } else stat_error (name); } diff --git a/src/warning.c b/src/warning.c index 2a436d76..bfcd2d27 100644 --- a/src/warning.c +++ b/src/warning.c @@ -47,6 +47,7 @@ static char const *const warning_args[] = { "existing-file", "xattr-write", "record-size", + "failed-read", NULL }; @@ -74,7 +75,8 @@ static int warning_types[] = { WARN_DECOMPRESS_PROGRAM, WARN_EXISTING_FILE, WARN_XATTR_WRITE, - WARN_RECORD_SIZE + WARN_RECORD_SIZE, + WARN_FAILED_READ }; ARGMATCH_VERIFY (warning_args, warning_types); |