When feeding filenames from 'find' to tar, it is possible for files to disappear before being processed. This forces tar to signal an error unless --ignore-failed-read has been specified. Using this switch however covers a wide variety of error conditions. To simplify the archival of big filesystems with find and tar, this change adds the command line switch "--ignore-missing" to ignore files that disappeared in the time between find identifying them and tar processing them.
Signed-off-by: Stefan Tomanek <[email protected]> --- src/common.h | 2 ++ src/misc.c | 2 +- src/tar.c | 7 +++++++ 3 files changed, 10 insertions(+), 1 deletions(-) diff --git a/src/common.h b/src/common.h index 0b9bd7a..ae5d1e2 100644 --- a/src/common.h +++ b/src/common.h @@ -163,6 +163,8 @@ GLOBAL gid_t group_option; GLOBAL bool ignore_failed_read_option; +GLOBAL bool ignore_missing_option; + GLOBAL bool ignore_zeros_option; GLOBAL bool incremental_option; diff --git a/src/misc.c b/src/misc.c index b75f2ab..e79177e 100644 --- a/src/misc.c +++ b/src/misc.c @@ -834,7 +834,7 @@ seek_diag_details (char const *name, off_t offset) void stat_diag (char const *name) { - if (ignore_failed_read_option) + if (ignore_failed_read_option || (errno == ENOENT && ignore_missing_option)) stat_warn (name); else stat_error (name); diff --git a/src/tar.c b/src/tar.c index 928cfdd..93a1136 100644 --- a/src/tar.c +++ b/src/tar.c @@ -279,6 +279,7 @@ enum IGNORE_CASE_OPTION, IGNORE_COMMAND_ERROR_OPTION, IGNORE_FAILED_READ_OPTION, + IGNORE_MISSING_OPTION, INDEX_FILE_OPTION, KEEP_NEWER_FILES_OPTION, LEVEL_OPTION, @@ -425,6 +426,8 @@ static struct argp_option options[] = { N_("dump level for created listed-incremental archive"), GRID+1 }, {"ignore-failed-read", IGNORE_FAILED_READ_OPTION, 0, 0, N_("do not exit with nonzero on unreadable files"), GRID+1 }, + {"ignore-missing", IGNORE_MISSING_OPTION, 0, 0, + N_("do not exit with nonzero on missing input files"), GRID+1 }, {"occurrence", OCCURRENCE_OPTION, N_("NUMBER"), OPTION_ARG_OPTIONAL, N_("process only the NUMBERth occurrence of each file in the archive;" " this option is valid only in conjunction with one of the subcommands" @@ -1831,6 +1834,10 @@ parse_opt (int key, char *arg, struct argp_state *state) ignore_failed_read_option = true; break; + case IGNORE_MISSING_OPTION: + ignore_missing_option = true; + break; + case KEEP_NEWER_FILES_OPTION: old_files_option = KEEP_NEWER_FILES; break; -- 1.7.2.5
