mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-04-30 23:11:25 +00:00
use lseek to get size of block devices
This commit is contained in:
parent
a9a94d59f3
commit
15fa30e3ec
20
vmtar.c
20
vmtar.c
@ -531,15 +531,19 @@ main (int argc, char **argv)
|
||||
|
||||
struct sp_array *ma = sparray_new();
|
||||
if (sparse) {
|
||||
if (!scan_sparse_file (fd, ma)) {
|
||||
fprintf (stderr, "scanning '%s' failed\n", source);
|
||||
exit (-1);
|
||||
}
|
||||
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);
|
||||
|
Loading…
Reference in New Issue
Block a user