Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2016 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
Alessio Balsini | fcba134 | 2019-12-19 13:43:36 +0000 | [diff] [blame] | 17 | #include <optional> |
| 18 | #include <sstream> |
| 19 | |
Tianjie | cc5edd3 | 2020-11-25 15:08:38 -0800 | [diff] [blame] | 20 | #include <android/hardware/boot/1.2/IBootControl.h> |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 21 | #include <sysexits.h> |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 22 | |
| 23 | using android::sp; |
| 24 | |
| 25 | using android::hardware::hidl_string; |
| 26 | using android::hardware::Return; |
| 27 | |
| 28 | using android::hardware::boot::V1_0::BoolResult; |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 29 | using android::hardware::boot::V1_0::CommandResult; |
| 30 | using android::hardware::boot::V1_0::Slot; |
Alessio Balsini | fcba134 | 2019-12-19 13:43:36 +0000 | [diff] [blame] | 31 | using android::hardware::boot::V1_1::IBootControl; |
| 32 | using android::hardware::boot::V1_1::MergeStatus; |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 33 | |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 34 | namespace V1_0 = android::hardware::boot::V1_0; |
| 35 | namespace V1_1 = android::hardware::boot::V1_1; |
Tianjie | cc5edd3 | 2020-11-25 15:08:38 -0800 | [diff] [blame] | 36 | namespace V1_2 = android::hardware::boot::V1_2; |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 37 | |
Tianjie | cc5edd3 | 2020-11-25 15:08:38 -0800 | [diff] [blame] | 38 | enum BootCtlVersion { BOOTCTL_V1_0, BOOTCTL_V1_1, BOOTCTL_V1_2 }; |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 39 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 40 | static void usage(FILE* where, BootCtlVersion bootVersion, int /* argc */, char* argv[]) { |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 41 | fprintf(where, |
| 42 | "%s - command-line wrapper for the boot HAL.\n" |
| 43 | "\n" |
| 44 | "Usage:\n" |
| 45 | " %s COMMAND\n" |
| 46 | "\n" |
| 47 | "Commands:\n" |
Alessio Balsini | fcba134 | 2019-12-19 13:43:36 +0000 | [diff] [blame] | 48 | " hal-info - Show info about boot_control HAL used.\n" |
| 49 | " get-number-slots - Prints number of slots.\n" |
| 50 | " get-current-slot - Prints currently running SLOT.\n" |
| 51 | " mark-boot-successful - Mark current slot as GOOD.\n" |
Tianjie | cc5edd3 | 2020-11-25 15:08:38 -0800 | [diff] [blame] | 52 | " get-active-boot-slot - Prints the SLOT to load on next boot.\n" |
Alessio Balsini | fcba134 | 2019-12-19 13:43:36 +0000 | [diff] [blame] | 53 | " set-active-boot-slot SLOT - On next boot, load and execute SLOT.\n" |
| 54 | " set-slot-as-unbootable SLOT - Mark SLOT as invalid.\n" |
| 55 | " is-slot-bootable SLOT - Returns 0 only if SLOT is bootable.\n" |
| 56 | " is-slot-marked-successful SLOT - Returns 0 only if SLOT is marked GOOD.\n" |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 57 | " get-suffix SLOT - Prints suffix for SLOT.\n", |
Alessio Balsini | fcba134 | 2019-12-19 13:43:36 +0000 | [diff] [blame] | 58 | argv[0], argv[0]); |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 59 | if (bootVersion >= BOOTCTL_V1_1) { |
| 60 | fprintf(where, |
| 61 | " set-snapshot-merge-status STAT - Sets whether a snapshot-merge of any dynamic\n" |
| 62 | " partition is in progress. Valid STAT values\n" |
| 63 | " are: none, unknown, snapshotted, merging,\n" |
| 64 | " or cancelled.\n" |
| 65 | " get-snapshot-merge-status - Prints the current snapshot-merge status.\n"); |
| 66 | } |
| 67 | fprintf(where, |
| 68 | "\n" |
| 69 | "SLOT parameter is the zero-based slot-number.\n"); |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 70 | } |
| 71 | |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 72 | static int do_hal_info(const sp<V1_0::IBootControl> module) { |
Yifan Hong | 2e3024f | 2017-02-22 18:11:18 -0800 | [diff] [blame] | 73 | module->interfaceDescriptor([&](const auto& descriptor) { |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 74 | fprintf(stdout, "HAL Version: %s\n", descriptor.c_str()); |
Steven Moreland | 6b8d033 | 2017-01-04 13:00:07 -0800 | [diff] [blame] | 75 | }); |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 76 | return EX_OK; |
| 77 | } |
| 78 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 79 | static int do_get_number_slots(sp<V1_0::IBootControl> module) { |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 80 | uint32_t numSlots = module->getNumberSlots(); |
| 81 | fprintf(stdout, "%u\n", numSlots); |
| 82 | return EX_OK; |
| 83 | } |
| 84 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 85 | static int do_get_current_slot(sp<V1_0::IBootControl> module) { |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 86 | Slot curSlot = module->getCurrentSlot(); |
| 87 | fprintf(stdout, "%u\n", curSlot); |
| 88 | return EX_OK; |
| 89 | } |
| 90 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 91 | static std::function<void(CommandResult)> generate_callback(CommandResult* crp) { |
| 92 | return [=](CommandResult cr) { *crp = cr; }; |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 93 | } |
| 94 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 95 | static int handle_return(const Return<void>& ret, CommandResult cr, const char* errStr) { |
Yifan Hong | 87d71f3 | 2016-12-20 17:34:36 -0800 | [diff] [blame] | 96 | if (!ret.isOk()) { |
| 97 | fprintf(stderr, errStr, ret.description().c_str()); |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 98 | return EX_SOFTWARE; |
| 99 | } else if (!cr.success) { |
| 100 | fprintf(stderr, errStr, cr.errMsg.c_str()); |
| 101 | return EX_SOFTWARE; |
| 102 | } |
| 103 | return EX_OK; |
| 104 | } |
| 105 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 106 | static int do_mark_boot_successful(sp<V1_0::IBootControl> module) { |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 107 | CommandResult cr; |
| 108 | Return<void> ret = module->markBootSuccessful(generate_callback(&cr)); |
| 109 | return handle_return(ret, cr, "Error marking as having booted successfully: %s\n"); |
| 110 | } |
| 111 | |
Tianjie | cc5edd3 | 2020-11-25 15:08:38 -0800 | [diff] [blame] | 112 | static int do_get_active_boot_slot(sp<V1_2::IBootControl> module) { |
| 113 | uint32_t slot = module->getActiveBootSlot(); |
| 114 | fprintf(stdout, "%u\n", slot); |
| 115 | return EX_OK; |
| 116 | } |
| 117 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 118 | static int do_set_active_boot_slot(sp<V1_0::IBootControl> module, Slot slot_number) { |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 119 | CommandResult cr; |
| 120 | Return<void> ret = module->setActiveBootSlot(slot_number, generate_callback(&cr)); |
| 121 | return handle_return(ret, cr, "Error setting active boot slot: %s\n"); |
| 122 | } |
| 123 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 124 | static int do_set_slot_as_unbootable(sp<V1_0::IBootControl> module, Slot slot_number) { |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 125 | CommandResult cr; |
| 126 | Return<void> ret = module->setSlotAsUnbootable(slot_number, generate_callback(&cr)); |
| 127 | return handle_return(ret, cr, "Error setting slot as unbootable: %s\n"); |
| 128 | } |
| 129 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 130 | static int handle_return(const Return<BoolResult>& ret, const char* errStr) { |
Yifan Hong | 87d71f3 | 2016-12-20 17:34:36 -0800 | [diff] [blame] | 131 | if (!ret.isOk()) { |
| 132 | fprintf(stderr, errStr, ret.description().c_str()); |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 133 | return EX_SOFTWARE; |
| 134 | } else if (ret == BoolResult::INVALID_SLOT) { |
| 135 | fprintf(stderr, errStr, "Invalid slot"); |
| 136 | return EX_SOFTWARE; |
| 137 | } else if (ret == BoolResult::TRUE) { |
| 138 | return EX_OK; |
| 139 | } |
| 140 | return EX_SOFTWARE; |
| 141 | } |
| 142 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 143 | static int do_is_slot_bootable(sp<V1_0::IBootControl> module, Slot slot_number) { |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 144 | Return<BoolResult> ret = module->isSlotBootable(slot_number); |
| 145 | return handle_return(ret, "Error calling isSlotBootable(): %s\n"); |
| 146 | } |
| 147 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 148 | static int do_is_slot_marked_successful(sp<V1_0::IBootControl> module, Slot slot_number) { |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 149 | Return<BoolResult> ret = module->isSlotMarkedSuccessful(slot_number); |
| 150 | return handle_return(ret, "Error calling isSlotMarkedSuccessful(): %s\n"); |
| 151 | } |
| 152 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 153 | std::optional<MergeStatus> stringToMergeStatus(const std::string& status) { |
Alessio Balsini | fcba134 | 2019-12-19 13:43:36 +0000 | [diff] [blame] | 154 | if (status == "cancelled") return MergeStatus::CANCELLED; |
| 155 | if (status == "merging") return MergeStatus::MERGING; |
| 156 | if (status == "none") return MergeStatus::NONE; |
| 157 | if (status == "snapshotted") return MergeStatus::SNAPSHOTTED; |
| 158 | if (status == "unknown") return MergeStatus::UNKNOWN; |
| 159 | return {}; |
| 160 | } |
| 161 | |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 162 | static int do_set_snapshot_merge_status(sp<V1_1::IBootControl> module, BootCtlVersion bootVersion, |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 163 | int argc, char* argv[]) { |
Alessio Balsini | fcba134 | 2019-12-19 13:43:36 +0000 | [diff] [blame] | 164 | if (argc != 3) { |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 165 | usage(stderr, bootVersion, argc, argv); |
Alessio Balsini | fcba134 | 2019-12-19 13:43:36 +0000 | [diff] [blame] | 166 | exit(EX_USAGE); |
| 167 | return -1; |
| 168 | } |
| 169 | |
| 170 | auto status = stringToMergeStatus(argv[2]); |
| 171 | if (!status.has_value()) { |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 172 | usage(stderr, bootVersion, argc, argv); |
Alessio Balsini | fcba134 | 2019-12-19 13:43:36 +0000 | [diff] [blame] | 173 | exit(EX_USAGE); |
| 174 | return -1; |
| 175 | } |
| 176 | |
| 177 | if (!module->setSnapshotMergeStatus(status.value())) { |
| 178 | return EX_SOFTWARE; |
| 179 | } |
| 180 | return EX_OK; |
| 181 | } |
| 182 | |
| 183 | std::ostream& operator<<(std::ostream& os, MergeStatus state) { |
| 184 | switch (state) { |
| 185 | case MergeStatus::CANCELLED: |
| 186 | return os << "cancelled"; |
| 187 | case MergeStatus::MERGING: |
| 188 | return os << "merging"; |
| 189 | case MergeStatus::NONE: |
| 190 | return os << "none"; |
| 191 | case MergeStatus::SNAPSHOTTED: |
| 192 | return os << "snapshotted"; |
| 193 | case MergeStatus::UNKNOWN: |
| 194 | return os << "unknown"; |
| 195 | default: |
| 196 | return os; |
| 197 | } |
| 198 | } |
| 199 | |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 200 | static int do_get_snapshot_merge_status(sp<V1_1::IBootControl> module) { |
Alessio Balsini | fcba134 | 2019-12-19 13:43:36 +0000 | [diff] [blame] | 201 | MergeStatus ret = module->getSnapshotMergeStatus(); |
| 202 | std::stringstream ss; |
| 203 | ss << ret; |
| 204 | fprintf(stdout, "%s\n", ss.str().c_str()); |
| 205 | return EX_OK; |
| 206 | } |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 207 | |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 208 | static int do_get_suffix(sp<V1_0::IBootControl> module, Slot slot_number) { |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 209 | std::function<void(hidl_string)> cb = [](hidl_string suffix) { |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 210 | fprintf(stdout, "%s\n", suffix.c_str()); |
| 211 | }; |
| 212 | Return<void> ret = module->getSuffix(slot_number, cb); |
Yifan Hong | 87d71f3 | 2016-12-20 17:34:36 -0800 | [diff] [blame] | 213 | if (!ret.isOk()) { |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 214 | fprintf(stderr, "Error calling getSuffix(): %s\n", ret.description().c_str()); |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 215 | return EX_SOFTWARE; |
| 216 | } |
| 217 | return EX_OK; |
| 218 | } |
| 219 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 220 | static uint32_t parse_slot(BootCtlVersion bootVersion, int pos, int argc, char* argv[]) { |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 221 | if (pos > argc - 1) { |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 222 | usage(stderr, bootVersion, argc, argv); |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 223 | exit(EX_USAGE); |
| 224 | return -1; |
| 225 | } |
| 226 | errno = 0; |
| 227 | uint64_t ret = strtoul(argv[pos], NULL, 10); |
| 228 | if (errno != 0 || ret > UINT_MAX) { |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 229 | usage(stderr, bootVersion, argc, argv); |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 230 | exit(EX_USAGE); |
| 231 | return -1; |
| 232 | } |
| 233 | return (uint32_t)ret; |
| 234 | } |
| 235 | |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 236 | int main(int argc, char* argv[]) { |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 237 | sp<V1_0::IBootControl> v1_0_module; |
| 238 | sp<V1_1::IBootControl> v1_1_module; |
Tianjie | cc5edd3 | 2020-11-25 15:08:38 -0800 | [diff] [blame] | 239 | sp<V1_2::IBootControl> v1_2_module; |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 240 | BootCtlVersion bootVersion = BOOTCTL_V1_0; |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 241 | |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 242 | v1_0_module = V1_0::IBootControl::getService(); |
| 243 | if (v1_0_module == nullptr) { |
| 244 | fprintf(stderr, "Error getting bootctrl v1.0 module.\n"); |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 245 | return EX_SOFTWARE; |
| 246 | } |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 247 | v1_1_module = V1_1::IBootControl::castFrom(v1_0_module); |
| 248 | if (v1_1_module != nullptr) { |
| 249 | bootVersion = BOOTCTL_V1_1; |
| 250 | } |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 251 | |
Tianjie | cc5edd3 | 2020-11-25 15:08:38 -0800 | [diff] [blame] | 252 | v1_2_module = V1_2::IBootControl::castFrom(v1_0_module); |
| 253 | if (v1_2_module != nullptr) { |
| 254 | bootVersion = BOOTCTL_V1_2; |
| 255 | } |
| 256 | |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 257 | if (argc < 2) { |
| 258 | usage(stderr, bootVersion, argc, argv); |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 259 | return EX_USAGE; |
| 260 | } |
| 261 | |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 262 | // Functions present from version 1.0 |
| 263 | if (strcmp(argv[1], "hal-info") == 0) { |
| 264 | return do_hal_info(v1_0_module); |
| 265 | } else if (strcmp(argv[1], "get-number-slots") == 0) { |
| 266 | return do_get_number_slots(v1_0_module); |
| 267 | } else if (strcmp(argv[1], "get-current-slot") == 0) { |
| 268 | return do_get_current_slot(v1_0_module); |
| 269 | } else if (strcmp(argv[1], "mark-boot-successful") == 0) { |
| 270 | return do_mark_boot_successful(v1_0_module); |
| 271 | } else if (strcmp(argv[1], "set-active-boot-slot") == 0) { |
| 272 | return do_set_active_boot_slot(v1_0_module, parse_slot(bootVersion, 2, argc, argv)); |
| 273 | } else if (strcmp(argv[1], "set-slot-as-unbootable") == 0) { |
| 274 | return do_set_slot_as_unbootable(v1_0_module, parse_slot(bootVersion, 2, argc, argv)); |
| 275 | } else if (strcmp(argv[1], "is-slot-bootable") == 0) { |
| 276 | return do_is_slot_bootable(v1_0_module, parse_slot(bootVersion, 2, argc, argv)); |
| 277 | } else if (strcmp(argv[1], "is-slot-marked-successful") == 0) { |
| 278 | return do_is_slot_marked_successful(v1_0_module, parse_slot(bootVersion, 2, argc, argv)); |
| 279 | } else if (strcmp(argv[1], "get-suffix") == 0) { |
| 280 | return do_get_suffix(v1_0_module, parse_slot(bootVersion, 2, argc, argv)); |
| 281 | } |
| 282 | |
| 283 | // Functions present from version 1.1 |
| 284 | if (strcmp(argv[1], "set-snapshot-merge-status") == 0 || |
Thiébaud Weksteen | df537e1 | 2020-10-23 17:01:57 +0200 | [diff] [blame] | 285 | strcmp(argv[1], "get-snapshot-merge-status") == 0) { |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 286 | if (v1_1_module == nullptr) { |
| 287 | fprintf(stderr, "Error getting bootctrl v1.1 module.\n"); |
| 288 | return EX_SOFTWARE; |
| 289 | } |
| 290 | if (strcmp(argv[1], "set-snapshot-merge-status") == 0) { |
| 291 | return do_set_snapshot_merge_status(v1_1_module, bootVersion, argc, argv); |
| 292 | } else if (strcmp(argv[1], "get-snapshot-merge-status") == 0) { |
| 293 | return do_get_snapshot_merge_status(v1_1_module); |
| 294 | } |
| 295 | } |
| 296 | |
Tianjie | cc5edd3 | 2020-11-25 15:08:38 -0800 | [diff] [blame] | 297 | if (strcmp(argv[1], "get-active-boot-slot") == 0) { |
| 298 | if (v1_2_module == nullptr) { |
| 299 | fprintf(stderr, "Error getting bootctrl v1.2 module.\n"); |
| 300 | return EX_SOFTWARE; |
| 301 | } |
| 302 | |
| 303 | return do_get_active_boot_slot(v1_2_module); |
| 304 | } |
| 305 | |
Håkan Kvist | 079aaac | 2020-07-02 17:27:06 +0200 | [diff] [blame] | 306 | // Parameter not matched, print usage |
| 307 | usage(stderr, bootVersion, argc, argv); |
| 308 | return EX_USAGE; |
Connor O'Brien | a4fbed7 | 2016-10-14 15:03:12 -0700 | [diff] [blame] | 309 | } |