Chromium Code Reviews| Index: runtime/bin/file_android.cc |
| diff --git a/runtime/bin/file_android.cc b/runtime/bin/file_android.cc |
| index 54d86f497b8a53d9f9febd2d57677368a40946a5..b42914967fda54859cbecaa83cbaaf9d40139c90 100644 |
| --- a/runtime/bin/file_android.cc |
| +++ b/runtime/bin/file_android.cc |
| @@ -238,13 +238,25 @@ bool File::Copy(const char* old_path, const char* new_path) { |
| return false; |
| } |
| off64_t offset = 0; |
| - int bytes = 1; |
| - while (bytes > 0) { |
| + int result = 1; |
| + while (result > 0) { |
| // Loop to ensure we copy everything, and not only up to 2GB. |
| - bytes = TEMP_FAILURE_RETRY( |
| + result = TEMP_FAILURE_RETRY( |
| sendfile(new_fd, old_fd, &offset, kMaxUint32)); |
| } |
|
Søren Gjesse
2013/12/16 08:01:52
Please add a comment to this "feature testing". Is
Anders Johnsen
2013/12/16 08:52:56
Done.
|
| - if (bytes < 0) { |
| + if (result < 0 && (errno == EINVAL || errno == ENOSYS)) { |
| + const intptr_t kBufferSize = 8 * 1024; |
|
Søren Gjesse
2013/12/16 08:01:52
We actually have the constant KB in platform/globa
Anders Johnsen
2013/12/16 08:52:56
Done.
|
| + uint8_t buffer[kBufferSize]; |
| + while ((result = TEMP_FAILURE_RETRY( |
| + read(old_fd, buffer, kBufferSize))) > 0) { |
| + int wrote = TEMP_FAILURE_RETRY(write(new_fd, buffer, result)); |
| + if (wrote != result) { |
| + result = -1; |
| + break; |
| + } |
| + } |
| + } |
| + if (result < 0) { |
| int e = errno; |
| VOID_TEMP_FAILURE_RETRY(close(old_fd)); |
| VOID_TEMP_FAILURE_RETRY(close(new_fd)); |