X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fcompare.c;h=e93ccb0a2ccd49c23f88d4bcb6ce29e8344ca06d;hb=cdb27293;hp=03eead5933ad779a81005b10555149b79bb3979b;hpb=be48ff0699a4ea9229ebe9e32eab39d125ecf39b;p=chaz%2Ftar diff --git a/src/compare.c b/src/compare.c index 03eead5..e93ccb0 100644 --- a/src/compare.c +++ b/src/compare.c @@ -1,7 +1,7 @@ /* Diff files from a tar archive. Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, - 2003 Free Software Foundation, Inc. + 2003, 2004 Free Software Foundation, Inc. Written by John Gilmore, on 1987-04-30. @@ -19,7 +19,7 @@ with this program; if not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ -#include "system.h" +#include #if HAVE_UTIME_H # include @@ -38,7 +38,7 @@ struct utimbuf #include #include "common.h" -#include "rmt.h" +#include #include /* Nonzero if we are verifying at the moment. */ @@ -54,15 +54,15 @@ static char *diff_buffer; void diff_init (void) { - diff_buffer = valloc (record_size); - if (!diff_buffer) - xalloc_die (); + void *ptr; + diff_buffer = page_aligned_alloc (&ptr, record_size); } /* Sigh about something that differs by writing a MESSAGE to stdlis, given MESSAGE is nonzero. Also set the exit status if not already. */ void -report_difference (struct tar_stat_info *st, const char *fmt, ...) +report_difference (struct tar_stat_info *st __attribute__ ((unused)), + const char *fmt, ...) { if (fmt) { @@ -74,35 +74,34 @@ report_difference (struct tar_stat_info *st, const char *fmt, ...) va_end (ap); fprintf (stdlis, "\n"); } - + if (exit_status == TAREXIT_SUCCESS) exit_status = TAREXIT_DIFFERS; } /* Take a buffer returned by read_and_process and do nothing with it. */ static int -process_noop (size_t size, char *data) +process_noop (size_t size __attribute__ ((unused)), + char *data __attribute__ ((unused))) { - /* Yes, I know. SIZE and DATA are unused in this function. Some - compilers may even report it. That's OK, just relax! */ return 1; } static int process_rawdata (size_t bytes, char *buffer) { - ssize_t status = safe_read (diff_handle, diff_buffer, bytes); + size_t status = safe_read (diff_handle, diff_buffer, bytes); if (status != bytes) { - if (status < 0) + if (status == SAFE_READ_ERROR) { read_error (current_stat_info.file_name); report_difference (¤t_stat_info, NULL); } else { - report_difference (¤t_stat_info, + report_difference (¤t_stat_info, ngettext ("Could only read %lu of %lu byte", "Could only read %lu of %lu bytes", bytes), @@ -308,19 +307,20 @@ diff_archive (void) case LNKTYPE: { - struct stat link_data, stat_data; + struct stat file_data; + struct stat link_data; - if (!get_stat_data (current_stat_info.file_name, &stat_data)) + if (!get_stat_data (current_stat_info.file_name, &file_data)) break; if (!get_stat_data (current_stat_info.link_name, &link_data)) break; - if (!sys_compare_links (&stat_data, &link_data)) + if (!sys_compare_links (&file_data, &link_data)) report_difference (¤t_stat_info, _("Not linked to %s"), quote (current_stat_info.link_name)); } break; - + #ifdef HAVE_READLINK case SYMTYPE: { @@ -494,6 +494,14 @@ diff_archive (void) void verify_volume (void) { + if (removed_prefixes_p ()) + { + WARN((0, 0, + _("Archive contains file names with leading prefixes removed."))); + WARN((0, 0, + _("Verification may fail to locate original files."))); + } + if (!diff_buffer) diff_init (); @@ -555,6 +563,7 @@ verify_volume (void) do { counter++; + set_next_block_after (current_header); status = read_header (false); } while (status == HEADER_FAILURE); @@ -568,6 +577,8 @@ verify_volume (void) break; diff_archive (); + tar_stat_destroy (¤t_stat_info); + xheader_destroy (&extended_header); } access_mode = ACCESS_WRITE;