X-Git-Url: https://git.brokenzipper.com/gitweb?a=blobdiff_plain;f=src%2Fsparse.c;h=8af4b47b8da1920cbabe6f0792339c5acdb49409;hb=a59c819beb4886ee43f16dfd80ec1151fda1abe6;hp=4a391a9cc6bd5202f89edc1b61dd81fd06a12a7c;hpb=f6edb92580aa886a2a0189463c19189a050dc62d;p=chaz%2Ftar diff --git a/src/sparse.c b/src/sparse.c index 4a391a9..8af4b47 100644 --- a/src/sparse.c +++ b/src/sparse.c @@ -1,6 +1,7 @@ /* Functions for dealing with sparse files - Copyright (C) 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2003, 2004, 2005, 2006, 2007, 2010 Free Software + Foundation, Inc. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the @@ -324,7 +325,6 @@ 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); } @@ -334,7 +334,7 @@ sparse_dump_region (struct tar_sparse_file *file, size_t i) static bool sparse_extract_region (struct tar_sparse_file *file, size_t i) { - size_t write_size; + off_t write_size; if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset)) return false; @@ -398,10 +398,11 @@ sparse_dump_file (int fd, struct tar_stat_info *st) { size_t i; - mv_begin (file.stat_info); + mv_begin_write (file.stat_info->file_name, + file.stat_info->stat.st_size, + file.stat_info->archive_file_size - file.dumped_size); for (i = 0; rc && i < file.stat_info->sparse_map_avail; i++) rc = tar_sparse_dump_region (&file, i); - mv_end (); } } @@ -508,7 +509,7 @@ check_sparse_region (struct tar_sparse_file *file, off_t beg, off_t end) static bool check_data_region (struct tar_sparse_file *file, size_t i) { - size_t size_left; + off_t size_left; if (!lseek_or_error (file, file->stat_info->sparse_map[i].offset)) return false; @@ -566,7 +567,7 @@ sparse_diff_file (int fd, struct tar_stat_info *st) file.seekable = true; /* File *must* be seekable for compare to work */ rc = tar_sparse_decode_header (&file); - mv_begin (st); + mv_begin_read (st); for (i = 0; rc && i < file.stat_info->sparse_map_avail; i++) { rc = check_sparse_region (&file, @@ -625,8 +626,9 @@ oldgnu_add_sparse (struct tar_sparse_file *file, struct sparse *s) if (s->numbytes[0] == '\0') return add_finish; sp.offset = OFF_FROM_HEADER (s->offset); - sp.numbytes = SIZE_FROM_HEADER (s->numbytes); + sp.numbytes = OFF_FROM_HEADER (s->numbytes); if (sp.offset < 0 + || sp.offset + sp.numbytes < 0 || file->stat_info->stat.st_size < sp.offset + sp.numbytes || file->stat_info->archive_file_size < 0) return add_fail; @@ -695,8 +697,8 @@ oldgnu_store_sparse_info (struct tar_sparse_file *file, size_t *pindex, { OFF_TO_CHARS (file->stat_info->sparse_map[*pindex].offset, sp->offset); - SIZE_TO_CHARS (file->stat_info->sparse_map[*pindex].numbytes, - sp->numbytes); + OFF_TO_CHARS (file->stat_info->sparse_map[*pindex].numbytes, + sp->numbytes); } } @@ -1147,7 +1149,7 @@ pax_decode_header (struct tar_sparse_file *file) } sp.offset = u; COPY_BUF (blk,nbuf,p); - if (!decode_num (&u, nbuf, TYPE_MAXIMUM (size_t))) + if (!decode_num (&u, nbuf, TYPE_MAXIMUM (off_t))) { ERROR ((0, 0, _("%s: malformed sparse archive member"), file->stat_info->orig_file_name));