Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/globals.h" | 5 #include "platform/globals.h" |
| 6 #if defined(TARGET_OS_LINUX) | 6 #if defined(TARGET_OS_LINUX) |
| 7 | 7 |
| 8 #include "bin/file.h" | 8 #include "bin/file.h" |
| 9 | 9 |
| 10 #include <errno.h> // NOLINT | 10 #include <errno.h> // NOLINT |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 if (old_fd < 0) { | 232 if (old_fd < 0) { |
| 233 return false; | 233 return false; |
| 234 } | 234 } |
| 235 int new_fd = TEMP_FAILURE_RETRY( | 235 int new_fd = TEMP_FAILURE_RETRY( |
| 236 open64(new_path, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, st.st_mode)); | 236 open64(new_path, O_WRONLY | O_TRUNC | O_CREAT | O_CLOEXEC, st.st_mode)); |
| 237 if (new_fd < 0) { | 237 if (new_fd < 0) { |
| 238 VOID_TEMP_FAILURE_RETRY(close(old_fd)); | 238 VOID_TEMP_FAILURE_RETRY(close(old_fd)); |
| 239 return false; | 239 return false; |
| 240 } | 240 } |
| 241 off64_t offset = 0; | 241 off64_t offset = 0; |
| 242 int bytes = 1; | 242 int result = 1; |
| 243 while (bytes > 0) { | 243 while (result > 0) { |
| 244 // Loop to ensure we copy everything, and not only up to 2GB. | 244 // Loop to ensure we copy everything, and not only up to 2GB. |
| 245 bytes = TEMP_FAILURE_RETRY( | 245 result = TEMP_FAILURE_RETRY( |
| 246 sendfile64(new_fd, old_fd, &offset, kMaxUint32)); | 246 sendfile64(new_fd, old_fd, &offset, kMaxUint32)); |
| 247 } | 247 } |
|
Søren Gjesse
2013/12/16 08:01:52
So this is not Android only?
Anders Johnsen
2013/12/16 08:52:56
No, the actual failure that lead to this was on li
| |
| 248 if (bytes < 0) { | 248 if (result < 0 && (errno == EINVAL || errno == ENOSYS)) { |
| 249 const intptr_t kBufferSize = 8 * 1024; | |
| 250 uint8_t buffer[kBufferSize]; | |
| 251 while ((result = TEMP_FAILURE_RETRY( | |
| 252 read(old_fd, buffer, kBufferSize))) > 0) { | |
| 253 int wrote = TEMP_FAILURE_RETRY(write(new_fd, buffer, result)); | |
| 254 if (wrote != result) { | |
| 255 result = -1; | |
| 256 break; | |
| 257 } | |
| 258 } | |
| 259 } | |
| 260 if (result < 0) { | |
| 249 int e = errno; | 261 int e = errno; |
| 250 VOID_TEMP_FAILURE_RETRY(close(old_fd)); | 262 VOID_TEMP_FAILURE_RETRY(close(old_fd)); |
| 251 VOID_TEMP_FAILURE_RETRY(close(new_fd)); | 263 VOID_TEMP_FAILURE_RETRY(close(new_fd)); |
| 252 VOID_TEMP_FAILURE_RETRY(unlink(new_path)); | 264 VOID_TEMP_FAILURE_RETRY(unlink(new_path)); |
| 253 errno = e; | 265 errno = e; |
| 254 return false; | 266 return false; |
| 255 } | 267 } |
| 256 return true; | 268 return true; |
| 257 } else if (type == kIsDirectory) { | 269 } else if (type == kIsDirectory) { |
| 258 errno = EISDIR; | 270 errno = EISDIR; |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 394 return (file_1_info.st_ino == file_2_info.st_ino && | 406 return (file_1_info.st_ino == file_2_info.st_ino && |
| 395 file_1_info.st_dev == file_2_info.st_dev) ? | 407 file_1_info.st_dev == file_2_info.st_dev) ? |
| 396 File::kIdentical : | 408 File::kIdentical : |
| 397 File::kDifferent; | 409 File::kDifferent; |
| 398 } | 410 } |
| 399 | 411 |
| 400 } // namespace bin | 412 } // namespace bin |
| 401 } // namespace dart | 413 } // namespace dart |
| 402 | 414 |
| 403 #endif // defined(TARGET_OS_LINUX) | 415 #endif // defined(TARGET_OS_LINUX) |
| OLD | NEW |