summaryrefslogtreecommitdiff
path: root/bootctl
diff options
context:
space:
mode:
authorDavid Zeuthen <zeuthen@google.com>2015-12-10 16:09:17 -0500
committerDavid Zeuthen <zeuthen@google.com>2015-12-10 16:11:52 -0500
commit942592f1ba062cf5d3051def1677154741780ac7 (patch)
tree31ee599c9dfdc755babce8a075e1f4a7b5ad2dde /bootctl
parent001077aa9293cd52ac4b4b34132eacd9b9a6ad23 (diff)
downloadextras-942592f1ba062cf5d3051def1677154741780ac7.tar.gz
bootctl: add is-slot-marked-successful command.
This makes it easy to call the newly added isSlotMarkedSuccessful() boot_control HAL method added in the CL at https://android-review.googlesource.com/#/c/185841/ This is useful for e.g. test suites. Also improve error reporting for is-slot-bootable command. Change-Id: I603e07d8310fc1de88114dadbaa1622a76289afb Test: tested on edison (Brillo).
Diffstat (limited to 'bootctl')
-rw-r--r--bootctl/bootctl.c46
1 files changed, 36 insertions, 10 deletions
diff --git a/bootctl/bootctl.c b/bootctl/bootctl.c
index 58fdbb69..ee8378be 100644
--- a/bootctl/bootctl.c
+++ b/bootctl/bootctl.c
@@ -37,17 +37,18 @@ static void usage(FILE* where, int argc, char* argv[])
" %s COMMAND\n"
"\n"
"Commands:\n"
- " %s hal-info - Show info about boot_control HAL used.\n"
- " %s get-number-slots - Prints number of slots.\n"
- " %s get-current-slot - Prints currently running SLOT.\n"
- " %s mark-boot-successful - Mark current slot as GOOD.\n"
- " %s set-active-boot-slot SLOT - On next boot, load and execute SLOT.\n"
- " %s set-slot-as-unbootable SLOT - Mark SLOT as invalid.\n"
- " %s is-slot-bootable SLOT - Returns 0 only if SLOT is bootable.\n"
- " %s get-suffix SLOT - Prints suffix for SLOT.\n"
+ " %s hal-info - Show info about boot_control HAL used.\n"
+ " %s get-number-slots - Prints number of slots.\n"
+ " %s get-current-slot - Prints currently running SLOT.\n"
+ " %s mark-boot-successful - Mark current slot as GOOD.\n"
+ " %s set-active-boot-slot SLOT - On next boot, load and execute SLOT.\n"
+ " %s set-slot-as-unbootable SLOT - Mark SLOT as invalid.\n"
+ " %s is-slot-bootable SLOT - Returns 0 only if SLOT is bootable.\n"
+ " %s is-slot-marked-successful SLOT - Returns 0 only if SLOT is marked GOOD.\n"
+ " %s get-suffix SLOT - Prints suffix for SLOT.\n"
"\n"
"SLOT parameter is the zero-based slot-number.\n",
- argv[0], argv[0], argv[0], argv[0], argv[0],
+ argv[0], argv[0], argv[0], argv[0], argv[0], argv[0],
argv[0], argv[0], argv[0], argv[0], argv[0]);
}
@@ -112,8 +113,13 @@ static int do_set_slot_as_unbootable(boot_control_module_t *module,
static int do_is_slot_bootable(boot_control_module_t *module, int slot_number)
{
int ret = module->isSlotBootable(module, slot_number);
- if (ret == 0)
+ if (ret == 0) {
+ return EX_SOFTWARE;
+ } else if (ret < 0) {
+ fprintf(stderr, "Error calling isSlotBootable(): %s\n",
+ strerror(-ret));
return EX_SOFTWARE;
+ }
return EX_OK;
}
@@ -125,6 +131,24 @@ static int do_get_suffix(boot_control_module_t *module, int slot_number)
return EX_OK;
}
+static int do_is_slot_marked_successful(boot_control_module_t *module,
+ int slot_number)
+{
+ if (module->isSlotMarkedSuccessful == NULL) {
+ fprintf(stderr, "isSlotMarkedSuccessful() is not implemented by HAL.\n");
+ return EX_UNAVAILABLE;
+ }
+ int ret = module->isSlotMarkedSuccessful(module, slot_number);
+ if (ret == 0) {
+ return EX_SOFTWARE;
+ } else if (ret < 0) {
+ fprintf(stderr, "Error calling isSlotMarkedSuccessful(): %s\n",
+ strerror(-ret));
+ return EX_SOFTWARE;
+ }
+ return EX_OK;
+}
+
static int parse_slot(int pos, int argc, char *argv[])
{
if (pos > argc - 1) {
@@ -177,6 +201,8 @@ int main(int argc, char *argv[])
return do_is_slot_bootable(module, parse_slot(2, argc, argv));
} else if (strcmp(argv[1], "get-suffix") == 0) {
return do_get_suffix(module, parse_slot(2, argc, argv));
+ } else if (strcmp(argv[1], "is-slot-marked-successful") == 0) {
+ return do_is_slot_marked_successful(module, parse_slot(2, argc, argv));
} else {
usage(stderr, argc, argv);
return EX_USAGE;