X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fsparse.c;h=f7a9fe7c93ff046b12f19054fde10d787e097c14;hb=d36f5a3cc3280d6c4a58367bf51b527d5c14ac04;hp=9680b6052244cbb0904d5fedf9ba671995cbd1da;hpb=a9895fd20c957ce184091672f1623a5bedd82407;p=chaz%2Ftar diff --git a/src/sparse.c b/src/sparse.c index 9680b60..f7a9fe7 100644 --- a/src/sparse.c +++ b/src/sparse.c @@ -230,7 +230,7 @@ sparse_scan_file (struct tar_sparse_file *file) if (!tar_sparse_scan (file, scan_begin, NULL)) return false; - while ((count = safe_read (fd, buffer, sizeof buffer)) != 0 + while ((count = blocking_read (fd, buffer, sizeof buffer)) != 0 && count != SAFE_READ_ERROR) { /* Analyze the block. */ @@ -360,7 +360,7 @@ sparse_extract_region (struct tar_sparse_file *file, size_t i) return false; } set_next_block_after (blk); - count = full_write (file->fd, blk->buffer, wrbytes); + count = blocking_write (file->fd, blk->buffer, wrbytes); write_size -= count; file->dumped_size += count; mv_size_left (file->stat_info->archive_file_size - file->dumped_size); @@ -591,18 +591,18 @@ sparse_diff_file (int fd, struct tar_stat_info *st) /* Old GNU Format. The sparse file information is stored in the oldgnu_header in the following manner: - The header is marked with type 'S'. Its `size' field contains + The header is marked with type 'S'. Its 'size' field contains the cumulative size of all non-empty blocks of the file. The - actual file size is stored in `realsize' member of oldgnu_header. + actual file size is stored in 'realsize' member of oldgnu_header. - The map of the file is stored in a list of `struct sparse'. + The map of the file is stored in a list of 'struct sparse'. Each struct contains offset to the block of data and its size (both as octal numbers). The first file header contains at most 4 such structs (SPARSES_IN_OLDGNU_HEADER). If the map - contains more structs, then the field `isextended' of the main - header is set to 1 (binary) and the `struct sparse_header' + contains more structs, then the field 'isextended' of the main + header is set to 1 (binary) and the 'struct sparse_header' header follows, containing at most 21 following structs - (SPARSES_IN_SPARSE_HEADER). If more structs follow, `isextended' + (SPARSES_IN_SPARSE_HEADER). If more structs follow, 'isextended' field of the extended header is set and next next extension header follows, etc... */ @@ -1029,8 +1029,11 @@ pax_dump_header_1 (struct tar_sparse_file *file) xheader_store ("GNU.sparse.name", file->stat_info, NULL); xheader_store ("GNU.sparse.realsize", file->stat_info, NULL); - file->stat_info->file_name = xheader_format_name (file->stat_info, - "%d/GNUSparseFile.%p/%f", 0); + file->stat_info->file_name = + xheader_format_name (file->stat_info, "%d/GNUSparseFile.%p/%f", 0); + /* Make sure the created header name is shorter than NAME_FIELD_SIZE: */ + if (strlen (file->stat_info->file_name) > NAME_FIELD_SIZE) + file->stat_info->file_name[NAME_FIELD_SIZE] = 0; blk = start_header (file->stat_info); /* Store the effective (shrunken) file size */