X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;f=src%2Fupdate.c;h=b8398724616b85f50d7d38f9220d100b210b08d1;hb=ac8cfdacf66941b0a339c7b3271138b29d7c69a4;hp=a78b9775e168a2f23e196e6eeabf08f8ae86e2ba;hpb=eed93f9a58ed79ec07028b85d54804f042bf7af9;p=chaz%2Ftar diff --git a/src/update.c b/src/update.c index a78b977..b839872 100644 --- a/src/update.c +++ b/src/update.c @@ -47,7 +47,7 @@ append_file (char *path) { int handle; struct stat stat_data; - long bytes_left; + off_t bytes_left; if (stat (path, &stat_data) != 0 || (handle = open (path, O_RDONLY | O_BINARY), handle < 0)) @@ -61,8 +61,8 @@ append_file (char *path) while (bytes_left > 0) { union block *start = find_next_block (); - long buffer_size = available_space_after (start); - int status; + size_t buffer_size = available_space_after (start); + ssize_t status; if (bytes_left < buffer_size) { @@ -73,18 +73,25 @@ append_file (char *path) (size_t) (BLOCKSIZE - status)); } - status = read (handle, start->buffer, (size_t) buffer_size); + status = read (handle, start->buffer, buffer_size); if (status < 0) - FATAL_ERROR ((0, errno, - _("Read error at byte %ld reading %d bytes in file %s"), - stat_data.st_size - bytes_left, buffer_size, path)); + { + char buf[UINTMAX_STRSIZE_BOUND]; + FATAL_ERROR ((0, errno, + _("Read error at byte %s reading %lu bytes in file %s"), + STRINGIFY_BIGINT (stat_data.st_size - bytes_left, buf), + (unsigned long) buffer_size, path)); + } bytes_left -= status; set_next_block_after (start + (status - 1) / BLOCKSIZE); if (status != buffer_size) - FATAL_ERROR ((0, 0, _("%s: File shrunk by %d bytes, (yark!)"), - path, bytes_left)); + { + char buf[UINTMAX_STRSIZE_BOUND]; + FATAL_ERROR ((0, 0, _("%s: File shrunk by %s bytes, (yark!)"), + path, STRINGIFY_BIGINT (bytes_left, buf))); + } } close (handle); @@ -135,7 +142,7 @@ update_archive (void) set_next_block_after (current_header); if (current_header->oldgnu_header.isextended) skip_extended_headers (); - skip_file ((long) current_stat.st_size); + skip_file (current_stat.st_size); break; } @@ -187,7 +194,7 @@ update_archive (void) if (subcommand_option == CAT_SUBCOMMAND) append_file (path); else - dump_file (path, -1, 1); + dump_file (path, (dev_t) -1, 1); } }