| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium OS Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "update_engine/delta_performer.h" | 5 #include "update_engine/delta_performer.h" |
| 6 | 6 |
| 7 #include <endian.h> | 7 #include <endian.h> |
| 8 #include <errno.h> | 8 #include <errno.h> |
| 9 | 9 |
| 10 #include <algorithm> | 10 #include <algorithm> |
| (...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 439 NULL)); | 439 NULL)); |
| 440 ScopedPathUnlinker path_unlinker(temp_filename); | 440 ScopedPathUnlinker path_unlinker(temp_filename); |
| 441 { | 441 { |
| 442 int fd = open(temp_filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644); | 442 int fd = open(temp_filename.c_str(), O_WRONLY | O_CREAT | O_TRUNC, 0644); |
| 443 ScopedFdCloser fd_closer(&fd); | 443 ScopedFdCloser fd_closer(&fd); |
| 444 TEST_AND_RETURN_FALSE( | 444 TEST_AND_RETURN_FALSE( |
| 445 utils::WriteAll(fd, &buffer_[0], operation.data_length())); | 445 utils::WriteAll(fd, &buffer_[0], operation.data_length())); |
| 446 } | 446 } |
| 447 | 447 |
| 448 int fd = is_kernel_partition ? kernel_fd_ : fd_; | 448 int fd = is_kernel_partition ? kernel_fd_ : fd_; |
| 449 const string& path = is_kernel_partition ? kernel_path_ : path_; | 449 const string& path = StringPrintf("/dev/fd/%d", fd); |
| 450 | 450 |
| 451 // If this is a non-idempotent operation, request a delayed exit and clear the | 451 // If this is a non-idempotent operation, request a delayed exit and clear the |
| 452 // update state in case the operation gets interrupted. Do this as late as | 452 // update state in case the operation gets interrupted. Do this as late as |
| 453 // possible. | 453 // possible. |
| 454 if (!IsIdempotentOperation(operation)) { | 454 if (!IsIdempotentOperation(operation)) { |
| 455 Terminator::set_exit_blocked(true); | 455 Terminator::set_exit_blocked(true); |
| 456 ResetUpdateProgress(prefs_, true); | 456 ResetUpdateProgress(prefs_, true); |
| 457 } | 457 } |
| 458 | 458 |
| 459 vector<string> cmd; | 459 vector<string> cmd; |
| 460 cmd.push_back(kBspatchPath); | 460 cmd.push_back(kBspatchPath); |
| 461 cmd.push_back(path); | 461 cmd.push_back(path); |
| 462 cmd.push_back(path); | 462 cmd.push_back(path); |
| 463 cmd.push_back(temp_filename); | 463 cmd.push_back(temp_filename); |
| 464 cmd.push_back(input_positions); | 464 cmd.push_back(input_positions); |
| 465 cmd.push_back(output_positions); | 465 cmd.push_back(output_positions); |
| 466 int return_code = 0; | 466 int return_code = 0; |
| 467 TEST_AND_RETURN_FALSE(Subprocess::SynchronousExec(cmd, &return_code)); | 467 TEST_AND_RETURN_FALSE( |
| 468 Subprocess::SynchronousExecFlags(cmd, |
| 469 &return_code, |
| 470 G_SPAWN_LEAVE_DESCRIPTORS_OPEN)); |
| 468 TEST_AND_RETURN_FALSE(return_code == 0); | 471 TEST_AND_RETURN_FALSE(return_code == 0); |
| 469 | 472 |
| 470 if (operation.dst_length() % block_size_) { | 473 if (operation.dst_length() % block_size_) { |
| 471 // Zero out rest of final block. | 474 // Zero out rest of final block. |
| 472 // TODO(adlr): build this into bspatch; it's more efficient that way. | 475 // TODO(adlr): build this into bspatch; it's more efficient that way. |
| 473 const Extent& last_extent = | 476 const Extent& last_extent = |
| 474 operation.dst_extents(operation.dst_extents_size() - 1); | 477 operation.dst_extents(operation.dst_extents_size() - 1); |
| 475 const uint64_t end_byte = | 478 const uint64_t end_byte = |
| 476 (last_extent.start_block() + last_extent.num_blocks()) * block_size_; | 479 (last_extent.start_block() + last_extent.num_blocks()) * block_size_; |
| 477 const uint64_t begin_byte = | 480 const uint64_t begin_byte = |
| (...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 690 if (prefs_->GetInt64(kPrefsResumedUpdateFailures, &resumed_update_failures)) { | 693 if (prefs_->GetInt64(kPrefsResumedUpdateFailures, &resumed_update_failures)) { |
| 691 resumed_update_failures++; | 694 resumed_update_failures++; |
| 692 } else { | 695 } else { |
| 693 resumed_update_failures = 1; | 696 resumed_update_failures = 1; |
| 694 } | 697 } |
| 695 prefs_->SetInt64(kPrefsResumedUpdateFailures, resumed_update_failures); | 698 prefs_->SetInt64(kPrefsResumedUpdateFailures, resumed_update_failures); |
| 696 return true; | 699 return true; |
| 697 } | 700 } |
| 698 | 701 |
| 699 } // namespace chromeos_update_engine | 702 } // namespace chromeos_update_engine |
| OLD | NEW |