X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fsparse.c;h=a8192beda8ea5f89a7d5d93d935b381317716787;hb=2e1f904f2c14a8ac8a5b5f4773c4ab551e99f4d9;hp=011fccd16b64c6c5eddc3fbb9c8f64a0c38193bd;hpb=cb3d8b0db970780c7857ad8a7fecde4ea533e05a;p=chaz%2Ftar diff --git a/src/sparse.c b/src/sparse.c index 011fccd..a8192be 100644 --- a/src/sparse.c +++ b/src/sparse.c @@ -324,6 +324,7 @@ sparse_dump_region (struct tar_sparse_file *file, size_t i) memset (blk->buffer + bytes_read, 0, BLOCKSIZE - bytes_read); bytes_left -= bytes_read; file->dumped_size += bytes_read; + mv_size_left (file->stat_info->archive_file_size - file->dumped_size); set_next_block_after (blk); } @@ -397,8 +398,10 @@ sparse_dump_file (int fd, struct tar_stat_info *st) { size_t i; + mv_begin (file.stat_info); for (i = 0; rc && i < file.stat_info->sparse_map_avail; i++) rc = tar_sparse_dump_region (&file, i); + mv_end (); } } @@ -883,11 +886,12 @@ pax_dump_header (struct tar_sparse_file *file) size_t i; char nbuf[UINTMAX_STRSIZE_BOUND]; struct sp_array *map = file->stat_info->sparse_map; - + char *save_file_name = NULL; + /* Store the real file size */ xheader_store ("GNU.sparse.size", file->stat_info, NULL); xheader_store ("GNU.sparse.numblocks", file->stat_info, NULL); - + /* FIXME-1.14-1.15.1-1.20: See the comment above. Starting with 1.17 this should display a warning about POSIX-incompatible keywords being generated. In 1.20, the true branch of the if block below @@ -904,6 +908,11 @@ pax_dump_header (struct tar_sparse_file *file) } else { + xheader_store ("GNU.sparse.name", file->stat_info, NULL); + save_file_name = file->stat_info->file_name; + file->stat_info->file_name = xheader_format_name (file->stat_info, + "%d/GNUSparseFile.%p/%f", 0); + xheader_string_begin (); for (i = 0; i < file->stat_info->sparse_map_avail; i++) { @@ -919,6 +928,11 @@ pax_dump_header (struct tar_sparse_file *file) /* Store the effective (shrunken) file size */ OFF_TO_CHARS (file->stat_info->archive_file_size, blk->header.size); finish_header (file->stat_info, blk, block_ordinal); + if (save_file_name) + { + free (file->stat_info->file_name); + file->stat_info->file_name = save_file_name; + } return true; }