From: Sergey Poznyakoff Date: Sat, 14 Oct 2006 21:11:27 +0000 (+0000) Subject: (dump_regular_file,dump_file0): Set exit_status to X-Git-Url: https://git.dogcows.com/gitweb?a=commitdiff_plain;h=c455373e5b7fc3037ad9e4204ba6c6aac2faa10f;p=chaz%2Ftar (dump_regular_file,dump_file0): Set exit_status to TAREXIT_DIFFERS if the file being dumped was truncated or otherwise changed. --- diff --git a/src/create.c b/src/create.c index 8273427..b1b2fd7 100644 --- a/src/create.c +++ b/src/create.c @@ -974,8 +974,8 @@ dump_regular_file (int fd, struct tar_stat_info *st) size_left), quotearg_colon (st->orig_file_name), STRINGIFY_BIGINT (size_left, buf))); - if (! ignore_failed_read_option) - exit_status = TAREXIT_FAILURE; + if (! ignore_failed_read_option) + exit_status = TAREXIT_DIFFERS; pad_archive (size_left - (bufsize-count)); return dump_status_short; } @@ -1399,6 +1399,7 @@ dump_file0 (struct tar_stat_info *st, const char *p, { union block *header; char type; + off_t original_size; struct timespec original_ctime; struct timespec restore_times[2]; off_t block_ordinal = -1; @@ -1418,7 +1419,7 @@ dump_file0 (struct tar_stat_info *st, const char *p, stat_diag (p); return; } - st->archive_file_size = st->stat.st_size; + st->archive_file_size = original_size = st->stat.st_size; st->atime = restore_times[0] = get_stat_atime (&st->stat); st->mtime = restore_times[1] = get_stat_mtime (&st->stat); st->ctime = original_ctime = get_stat_ctime (&st->stat); @@ -1555,9 +1556,14 @@ dump_file0 (struct tar_stat_info *st, const char *p, if (ok) { - if (timespec_cmp (get_stat_ctime (&final_stat), original_ctime) != 0) - WARN ((0, 0, _("%s: file changed as we read it"), - quotearg_colon (p))); + if (timespec_cmp (get_stat_ctime (&final_stat), original_ctime) != 0 + || original_size < final_stat.st_size) + { + WARN ((0, 0, _("%s: file changed as we read it"), + quotearg_colon (p))); + if (exit_status == TAREXIT_SUCCESS) + exit_status = TAREXIT_DIFFERS; + } else if (atime_preserve_option == replace_atime_preserve && set_file_atime (fd, p, restore_times) != 0) utime_error (p);