git.annexia.org
/
libguestfs.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Create /sys directory if it doesn't exist already.
[libguestfs.git]
/
daemon
/
dd.c
diff --git
a/daemon/dd.c
b/daemon/dd.c
index
2bbe855
..
f08eb36
100644
(file)
--- a/
daemon/dd.c
+++ b/
daemon/dd.c
@@
-23,7
+23,7
@@
#include <string.h>
#include <fcntl.h>
#include <string.h>
#include <fcntl.h>
-#include "
../src/
guestfs_protocol.h"
+#include "guestfs_protocol.h"
#include "daemon.h"
#include "actions.h"
#include "daemon.h"
#include "actions.h"
@@
-73,7
+73,7
@@
do_dd (const char *src, const char *dest)
}
int
}
int
-do_copy_size (const char *src, const char *dest, int64_t size)
+do_copy_size (const char *src, const char *dest, int64_t s
s
ize)
{
char *buf;
int src_fd, dest_fd;
{
char *buf;
int src_fd, dest_fd;
@@
-112,9
+112,19
@@
do_copy_size (const char *src, const char *dest, int64_t size)
return -1;
}
return -1;
}
- while (size > 0) {
+ uint64_t position = 0, size = (uint64_t) ssize;
+
+ while (position < size) {
char buf[1024*1024];
char buf[1024*1024];
- size_t n = size > (int64_t) (sizeof buf) ? sizeof buf : (size_t) size;
+
+ /* Calculate bytes to copy. */
+ uint64_t n64 = size - position;
+ size_t n;
+ if (n64 > sizeof buf)
+ n = sizeof buf;
+ else
+ n = (size_t) n64; /* safe because of if condition */
+
ssize_t r = read (src_fd, buf, n);
if (r == -1) {
reply_with_perror ("%s: read", src);
ssize_t r = read (src_fd, buf, n);
if (r == -1) {
reply_with_perror ("%s: read", src);
@@
-136,7
+146,8
@@
do_copy_size (const char *src, const char *dest, int64_t size)
return -1;
}
return -1;
}
- size -= r;
+ position += r;
+ notify_progress ((uint64_t) position, (uint64_t) size);
}
if (close (src_fd) == -1) {
}
if (close (src_fd) == -1) {