| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium 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 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__ | 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__ | 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include "update_engine/action.h" | 9 #include "update_engine/action.h" |
| 10 #include "update_engine/install_plan.h" |
| 10 | 11 |
| 11 // This class takes in a device via the input pipe. The device is the | 12 // This class takes in a device via the input pipe. The device is the |
| 12 // partition (e.g. /dev/sda1), not the full device (e.g. /dev/sda). | 13 // partition (e.g. /dev/sda1), not the full device (e.g. /dev/sda). |
| 13 // It will make that device bootable by editing the partition table | 14 // It will make that device bootable by editing the partition table |
| 14 // in the root device. Currently, this class doesn't support extended | 15 // in the root device. Currently, this class doesn't support extended |
| 15 // partitions. | 16 // partitions. |
| 16 | 17 |
| 17 namespace chromeos_update_engine { | 18 namespace chromeos_update_engine { |
| 18 | 19 |
| 19 class SetBootableFlagAction; | 20 class SetBootableFlagAction; |
| 20 | 21 |
| 21 template<> | 22 template<> |
| 22 class ActionTraits<SetBootableFlagAction> { | 23 class ActionTraits<SetBootableFlagAction> { |
| 23 public: | 24 public: |
| 24 // Takes the device path as input. | 25 // Takes the device path as input. |
| 25 typedef std::string InputObjectType; | 26 typedef InstallPlan InputObjectType; |
| 26 // Passes the device path as output | 27 // Passes the device path as output |
| 27 typedef std::string OutputObjectType; | 28 typedef InstallPlan OutputObjectType; |
| 28 }; | 29 }; |
| 29 | 30 |
| 30 class SetBootableFlagAction : public Action<SetBootableFlagAction> { | 31 class SetBootableFlagAction : public Action<SetBootableFlagAction> { |
| 31 public: | 32 public: |
| 32 SetBootableFlagAction() {} | 33 SetBootableFlagAction() {} |
| 33 typedef ActionTraits<SetBootableFlagAction>::InputObjectType | 34 typedef ActionTraits<SetBootableFlagAction>::InputObjectType |
| 34 InputObjectType; | 35 InputObjectType; |
| 35 typedef ActionTraits<SetBootableFlagAction>::OutputObjectType | 36 typedef ActionTraits<SetBootableFlagAction>::OutputObjectType |
| 36 OutputObjectType; | 37 OutputObjectType; |
| 37 void PerformAction(); | 38 void PerformAction(); |
| 38 | 39 |
| 39 // This is a synchronous action, and thus TerminateProcessing() should | 40 // This is a synchronous action, and thus TerminateProcessing() should |
| 40 // never be called | 41 // never be called |
| 41 void TerminateProcessing() { CHECK(false); } | 42 void TerminateProcessing() { CHECK(false); } |
| 42 | 43 |
| 43 // Debugging/logging | 44 // Debugging/logging |
| 44 static std::string StaticType() { return "SetBootableFlagAction"; } | 45 static std::string StaticType() { return "SetBootableFlagAction"; } |
| 45 std::string Type() const { return StaticType(); } | 46 std::string Type() const { return StaticType(); } |
| 46 | 47 |
| 47 private: | 48 private: |
| 48 // Returns true on success | |
| 49 bool ReadMbr(char* buffer, int buffer_len, const char* device); | |
| 50 | |
| 51 // Returns true on success | |
| 52 bool WriteMbr(const char* buffer, int buffer_len, const char* device); | |
| 53 | 49 |
| 54 DISALLOW_COPY_AND_ASSIGN(SetBootableFlagAction); | 50 DISALLOW_COPY_AND_ASSIGN(SetBootableFlagAction); |
| 55 }; | 51 }; |
| 56 | 52 |
| 57 } // namespace chromeos_update_engine | 53 } // namespace chromeos_update_engine |
| 58 | 54 |
| 59 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__ | 55 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__ |
| OLD | NEW |