while (bytes_left > 0) {
size_t bufsize = (bytes_left > BLOCKSIZE) ? BLOCKSIZE : bytes_left;
- size_t bytes_read;
+ ssize_t bytes_read;
char *blkbuf = buffer_block (wbuf);
if ((bytes_read = full_read (fd, blkbuf, bufsize)) < 0) {
time_t ctime = fs.st_mtime;
struct sp_array *ma = sparray_new();
- if (sparse) {
- if (!scan_sparse_file (fd, ma)) {
- fprintf (stderr, "scanning '%s' failed\n", source);
- exit (-1);
- }
+ if (sparse && !S_ISBLK(fs.st_mode)) {
+ if (!scan_sparse_file (fd, ma)) {
+ fprintf (stderr, "scanning '%s' failed\n", source);
+ exit (-1);
+ }
} else {
- off_t file_size = fs.st_size;
- sparray_add (ma, 0, file_size);
- ma->real_size = file_size;
- ma->effective_size = file_size;
+ off_t file_size = lseek(fd, 0, SEEK_END);
+ if (file_size < 0) {
+ fprintf (stderr, "unable to get file size of '%s'\n", source);
+ exit (-1);
+ }
+ sparray_add (ma, 0, file_size);
+ ma->real_size = file_size;
+ ma->effective_size = file_size;
}
dump_header (wbuf, archivename, ctime, ma);