OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__ |
| 6 #define CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__ |
| 7 |
| 8 #include <string> |
| 9 #include "update_engine/action.h" |
| 10 |
| 11 // 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 // It will make that device bootable by editing the partition table |
| 14 // in the root device. Currently, this class doesn't support extended |
| 15 // partitions. |
| 16 |
| 17 namespace chromeos_update_engine { |
| 18 |
| 19 class SetBootableFlagAction; |
| 20 |
| 21 template<> |
| 22 class ActionTraits<SetBootableFlagAction> { |
| 23 public: |
| 24 // Takes the device path as input. |
| 25 typedef std::string InputObjectType; |
| 26 // Passes the device path as output |
| 27 typedef std::string OutputObjectType; |
| 28 }; |
| 29 |
| 30 class SetBootableFlagAction : public Action<SetBootableFlagAction> { |
| 31 public: |
| 32 SetBootableFlagAction() {} |
| 33 typedef ActionTraits<SetBootableFlagAction>::InputObjectType |
| 34 InputObjectType; |
| 35 typedef ActionTraits<SetBootableFlagAction>::OutputObjectType |
| 36 OutputObjectType; |
| 37 void PerformAction(); |
| 38 |
| 39 // This is a synchronous action, and thus TerminateProcessing() should |
| 40 // never be called |
| 41 void TerminateProcessing() { CHECK(false); } |
| 42 |
| 43 // Debugging/logging |
| 44 static std::string StaticType() { return "SetBootableFlagAction"; } |
| 45 std::string Type() const { return StaticType(); } |
| 46 |
| 47 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 |
| 54 DISALLOW_COPY_AND_ASSIGN(SetBootableFlagAction); |
| 55 }; |
| 56 |
| 57 } // namespace chromeos_update_engine |
| 58 |
| 59 #endif // CHROMEOS_PLATFORM_UPDATE_ENGINE_SET_BOOTABLE_FLAG_ACTION_H__ |
OLD | NEW |