| 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/postinstall_runner_action.h" | 5 #include "update_engine/postinstall_runner_action.h" |
| 6 #include <sys/mount.h> | 6 #include <sys/mount.h> |
| 7 #include <stdlib.h> | 7 #include <stdlib.h> |
| 8 #include <vector> | 8 #include <vector> |
| 9 #include "update_engine/subprocess.h" | 9 #include "update_engine/subprocess.h" |
| 10 #include "update_engine/utils.h" | 10 #include "update_engine/utils.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 command.push_back(temp_rootfs_dir_ + kPostinstallScript); | 58 command.push_back(temp_rootfs_dir_ + kPostinstallScript); |
| 59 command.push_back(install_device); | 59 command.push_back(install_device); |
| 60 Subprocess::Get().Exec(command, StaticCompletePostinstall, this); | 60 Subprocess::Get().Exec(command, StaticCompletePostinstall, this); |
| 61 } | 61 } |
| 62 | 62 |
| 63 void PostinstallRunnerAction::CompletePostinstall(int return_code) { | 63 void PostinstallRunnerAction::CompletePostinstall(int return_code) { |
| 64 ScopedActionCompleter completer(processor_, this); | 64 ScopedActionCompleter completer(processor_, this); |
| 65 ScopedTempUnmounter temp_unmounter(temp_rootfs_dir_); | 65 ScopedTempUnmounter temp_unmounter(temp_rootfs_dir_); |
| 66 if (return_code != 0) { | 66 if (return_code != 0) { |
| 67 LOG(ERROR) << "Postinst command failed with code: " << return_code; | 67 LOG(ERROR) << "Postinst command failed with code: " << return_code; |
| 68 if (return_code == 2) { |
| 69 // This special return code means that we tried to update firmware, |
| 70 // but couldn't because we booted from FW B, and we need to reboot |
| 71 // to get back to FW A. |
| 72 completer.set_code(kActionCodePostinstallBootedFromFirmwareB); |
| 73 } |
| 68 return; | 74 return; |
| 69 } | 75 } |
| 70 if (HasOutputPipe()) { | 76 if (HasOutputPipe()) { |
| 71 CHECK(HasInputObject()); | 77 CHECK(HasInputObject()); |
| 72 SetOutputObject(GetInputObject()); | 78 SetOutputObject(GetInputObject()); |
| 73 } | 79 } |
| 74 completer.set_code(kActionCodeSuccess); | 80 completer.set_code(kActionCodeSuccess); |
| 75 } | 81 } |
| 76 | 82 |
| 77 void PostinstallRunnerAction::StaticCompletePostinstall(int return_code, | 83 void PostinstallRunnerAction::StaticCompletePostinstall(int return_code, |
| 78 const string& output, | 84 const string& output, |
| 79 void* p) { | 85 void* p) { |
| 80 reinterpret_cast<PostinstallRunnerAction*>(p)->CompletePostinstall( | 86 reinterpret_cast<PostinstallRunnerAction*>(p)->CompletePostinstall( |
| 81 return_code); | 87 return_code); |
| 82 } | 88 } |
| 83 | 89 |
| 84 } // namespace chromeos_update_engine | 90 } // namespace chromeos_update_engine |
| OLD | NEW |