X-Git-Url: https://git.librecmc.org/?a=blobdiff_plain;f=cmd%2Favb.c;h=a4de5c40a2dc9f006acaa7aa96e6b70623c56daa;hb=634fe73eedb9551a13296f356afae67539583f17;hp=c5af4a2e461d4ac224ab2410b846aec8ab5f6a4b;hpb=6b8e57338f3c5b65fa5b883fa3f87124f11a9e19;p=oweals%2Fu-boot.git diff --git a/cmd/avb.c b/cmd/avb.c index c5af4a2e46..a4de5c40a2 100644 --- a/cmd/avb.c +++ b/cmd/avb.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -14,11 +15,6 @@ #define AVB_BOOTARGS "avb_bootargs" static struct AvbOps *avb_ops; -static const char * const requested_partitions[] = {"boot", - "system", - "vendor", - NULL}; - int do_avb_init(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[]) { unsigned long mmc_dev; @@ -231,10 +227,12 @@ int do_avb_get_uuid(cmd_tbl_t *cmdtp, int flag, int do_avb_verify_part(cmd_tbl_t *cmdtp, int flag, int argc, char *const argv[]) { + const char * const requested_partitions[] = {"boot", NULL}; AvbSlotVerifyResult slot_result; AvbSlotVerifyData *out_data; char *cmdline; char *extra_args; + char *slot_suffix = ""; bool unlocked = false; int res = CMD_RET_FAILURE; @@ -244,9 +242,12 @@ int do_avb_verify_part(cmd_tbl_t *cmdtp, int flag, return CMD_RET_FAILURE; } - if (argc != 1) + if (argc < 1 || argc > 2) return CMD_RET_USAGE; + if (argc == 2) + slot_suffix = argv[1]; + printf("## Android Verified Boot 2.0 version %s\n", avb_version_string()); @@ -259,7 +260,7 @@ int do_avb_verify_part(cmd_tbl_t *cmdtp, int flag, slot_result = avb_slot_verify(avb_ops, requested_partitions, - "", + slot_suffix, unlocked, AVB_HASHTREE_ERROR_MODE_RESTART_AND_INVALIDATE, &out_data); @@ -368,7 +369,7 @@ int do_avb_read_pvalue(cmd_tbl_t *cmdtp, int flag, int argc, if (avb_ops->read_persistent_value(avb_ops, name, bytes, buffer, &bytes_read) == AVB_IO_RESULT_OK) { - printf("Read %ld bytes, value = %s\n", bytes_read, + printf("Read %zu bytes, value = %s\n", bytes_read, (char *)buffer); free(buffer); return CMD_RET_SUCCESS; @@ -401,7 +402,7 @@ int do_avb_write_pvalue(cmd_tbl_t *cmdtp, int flag, int argc, if (avb_ops->write_persistent_value(avb_ops, name, strlen(value) + 1, (const uint8_t *)value) == AVB_IO_RESULT_OK) { - printf("Wrote %ld bytes\n", strlen(value) + 1); + printf("Wrote %zu bytes\n", strlen(value) + 1); return CMD_RET_SUCCESS; } @@ -419,7 +420,7 @@ static cmd_tbl_t cmd_avb[] = { U_BOOT_CMD_MKENT(read_part, 5, 0, do_avb_read_part, "", ""), U_BOOT_CMD_MKENT(read_part_hex, 4, 0, do_avb_read_part_hex, "", ""), U_BOOT_CMD_MKENT(write_part, 5, 0, do_avb_write_part, "", ""), - U_BOOT_CMD_MKENT(verify, 1, 0, do_avb_verify_part, "", ""), + U_BOOT_CMD_MKENT(verify, 2, 0, do_avb_verify_part, "", ""), #ifdef CONFIG_OPTEE_TA_AVB U_BOOT_CMD_MKENT(read_pvalue, 3, 0, do_avb_read_pvalue, "", ""), U_BOOT_CMD_MKENT(write_pvalue, 3, 0, do_avb_write_pvalue, "", ""), @@ -462,6 +463,7 @@ U_BOOT_CMD( "avb read_pvalue - read a persistent value \n" "avb write_pvalue - write a persistent value \n" #endif - "avb verify - run verification process using hash data\n" + "avb verify [slot_suffix] - run verification process using hash data\n" " from vbmeta structure\n" + " [slot_suffix] - _a, _b, etc (if vbmeta partition is slotted)\n" );