|
@@ -415,7 +415,7 @@ sparse_dump_region (struct tar_sparse_file *file, size_t i)
|
|
|
size_t bytes_read;
|
|
|
|
|
|
blk = find_next_block ();
|
|
|
- bytes_read = safe_read (file->fd, blk->buffer, bufsize);
|
|
|
+ bytes_read = full_read (file->fd, blk->buffer, bufsize);
|
|
|
if (bytes_read == SAFE_READ_ERROR)
|
|
|
{
|
|
|
read_diag_details (file->stat_info->orig_file_name,
|
|
@@ -427,27 +427,39 @@ sparse_dump_region (struct tar_sparse_file *file, size_t i)
|
|
|
}
|
|
|
else if (bytes_read == 0)
|
|
|
{
|
|
|
- char buf[UINTMAX_STRSIZE_BOUND];
|
|
|
- struct stat st;
|
|
|
- size_t n;
|
|
|
- if (fstat (file->fd, &st) == 0)
|
|
|
- n = file->stat_info->stat.st_size - st.st_size;
|
|
|
+ if (errno != 0)
|
|
|
+ {
|
|
|
+ read_diag_details (file->stat_info->orig_file_name,
|
|
|
+ (file->stat_info->sparse_map[i].offset
|
|
|
+ + file->stat_info->sparse_map[i].numbytes
|
|
|
+ - bytes_left),
|
|
|
+ bufsize);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
else
|
|
|
- n = file->stat_info->stat.st_size
|
|
|
- - (file->stat_info->sparse_map[i].offset
|
|
|
- + file->stat_info->sparse_map[i].numbytes
|
|
|
- - bytes_left);
|
|
|
-
|
|
|
- WARNOPT (WARN_FILE_SHRANK,
|
|
|
- (0, 0,
|
|
|
- ngettext ("%s: File shrank by %s byte; padding with zeros",
|
|
|
- "%s: File shrank by %s bytes; padding with zeros",
|
|
|
- n),
|
|
|
- quotearg_colon (file->stat_info->orig_file_name),
|
|
|
- STRINGIFY_BIGINT (n, buf)));
|
|
|
- if (! ignore_failed_read_option)
|
|
|
- set_exit_status (TAREXIT_DIFFERS);
|
|
|
- return false;
|
|
|
+ {
|
|
|
+ char buf[UINTMAX_STRSIZE_BOUND];
|
|
|
+ struct stat st;
|
|
|
+ size_t n;
|
|
|
+ if (fstat (file->fd, &st) == 0)
|
|
|
+ n = file->stat_info->stat.st_size - st.st_size;
|
|
|
+ else
|
|
|
+ n = file->stat_info->stat.st_size
|
|
|
+ - (file->stat_info->sparse_map[i].offset
|
|
|
+ + file->stat_info->sparse_map[i].numbytes
|
|
|
+ - bytes_left);
|
|
|
+
|
|
|
+ WARNOPT (WARN_FILE_SHRANK,
|
|
|
+ (0, 0,
|
|
|
+ ngettext ("%s: File shrank by %s byte; padding with zeros",
|
|
|
+ "%s: File shrank by %s bytes; padding with zeros",
|
|
|
+ n),
|
|
|
+ quotearg_colon (file->stat_info->orig_file_name),
|
|
|
+ STRINGIFY_BIGINT (n, buf)));
|
|
|
+ if (! ignore_failed_read_option)
|
|
|
+ set_exit_status (TAREXIT_DIFFERS);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
memset (blk->buffer + bytes_read, 0, BLOCKSIZE - bytes_read);
|
|
@@ -615,7 +627,7 @@ check_sparse_region (struct tar_sparse_file *file, off_t beg, off_t end)
|
|
|
size_t rdsize = BLOCKSIZE < end - beg ? BLOCKSIZE : end - beg;
|
|
|
char diff_buffer[BLOCKSIZE];
|
|
|
|
|
|
- bytes_read = safe_read (file->fd, diff_buffer, rdsize);
|
|
|
+ bytes_read = full_read (file->fd, diff_buffer, rdsize);
|
|
|
if (bytes_read == SAFE_READ_ERROR)
|
|
|
{
|
|
|
read_diag_details (file->stat_info->orig_file_name,
|
|
@@ -625,7 +637,12 @@ check_sparse_region (struct tar_sparse_file *file, off_t beg, off_t end)
|
|
|
}
|
|
|
else if (bytes_read == 0)
|
|
|
{
|
|
|
- report_difference (file->stat_info, _("Size differs"));
|
|
|
+ if (errno != 0)
|
|
|
+ read_diag_details (file->stat_info->orig_file_name,
|
|
|
+ beg,
|
|
|
+ rdsize);
|
|
|
+ else
|
|
|
+ report_difference (file->stat_info, _("Size differs"));
|
|
|
return false;
|
|
|
}
|
|
|
|
|
@@ -668,7 +685,7 @@ check_data_region (struct tar_sparse_file *file, size_t i)
|
|
|
}
|
|
|
set_next_block_after (blk);
|
|
|
file->dumped_size += BLOCKSIZE;
|
|
|
- bytes_read = safe_read (file->fd, diff_buffer, rdsize);
|
|
|
+ bytes_read = full_read (file->fd, diff_buffer, rdsize);
|
|
|
if (bytes_read == SAFE_READ_ERROR)
|
|
|
{
|
|
|
read_diag_details (file->stat_info->orig_file_name,
|
|
@@ -680,7 +697,14 @@ check_data_region (struct tar_sparse_file *file, size_t i)
|
|
|
}
|
|
|
else if (bytes_read == 0)
|
|
|
{
|
|
|
- report_difference (¤t_stat_info, _("Size differs"));
|
|
|
+ if (errno != 0)
|
|
|
+ read_diag_details (file->stat_info->orig_file_name,
|
|
|
+ (file->stat_info->sparse_map[i].offset
|
|
|
+ + file->stat_info->sparse_map[i].numbytes
|
|
|
+ - size_left),
|
|
|
+ rdsize);
|
|
|
+ else
|
|
|
+ report_difference (¤t_stat_info, _("Size differs"));
|
|
|
return false;
|
|
|
}
|
|
|
size_left -= bytes_read;
|