diff options
author | Igor Opaniuk <igor.opaniuk@linaro.org> | 2018-08-10 16:59:59 +0300 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2018-08-13 21:03:52 +0300 |
commit | 7a5fbfe64154c7474a9af2f3ff0a57ea2089fd87 (patch) | |
tree | a5b71c4877d3bea745af7794d4dac1ba436a7301 /common/avb_verify.c | |
parent | b8a1f47be3ab050090cd8625e580cf3c63e3ff53 (diff) | |
download | u-boot-7a5fbfe64154c7474a9af2f3ff0a57ea2089fd87.tar.xz |
avb2.0: add get_size_of_partition()
Implement get_size_of_partition() operation,
which is required by the latest upstream libavb [1].
[1] https://android.googlesource.com/platform/external/avb/+/android-p-preview-5
Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
Acked-by: Andrew F. Davis <afd@ti.com>
Reviewed-by: Sam Protsenko <semen.protsenko@linaro.org>
Diffstat (limited to 'common/avb_verify.c')
-rw-r--r-- | common/avb_verify.c | 33 |
1 files changed, 32 insertions, 1 deletions
diff --git a/common/avb_verify.c b/common/avb_verify.c index 20e35ade30..82ddebcfc2 100644 --- a/common/avb_verify.c +++ b/common/avb_verify.c @@ -700,6 +700,37 @@ static AvbIOResult get_unique_guid_for_partition(AvbOps *ops, } /** + * get_size_of_partition() - gets the size of a partition identified + * by a string name + * + * @ops: contains AVB ops handlers + * @partition: partition name (NUL-terminated UTF-8 string) + * @out_size_num_bytes: returns the value of a partition size + * + * @return: + * AVB_IO_RESULT_OK, on success (GUID found) + * AVB_IO_RESULT_ERROR_INSUFFICIENT_SPACE, out_size_num_bytes is NULL + * AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION, if partition was not found + */ +static AvbIOResult get_size_of_partition(AvbOps *ops, + const char *partition, + u64 *out_size_num_bytes) +{ + struct mmc_part *part; + + if (!out_size_num_bytes) + return AVB_IO_RESULT_ERROR_INSUFFICIENT_SPACE; + + part = get_partition(ops, partition); + if (!part) + return AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION; + + *out_size_num_bytes = part->info.blksz * part->info.size; + + return AVB_IO_RESULT_OK; +} + +/** * ============================================================================ * AVB2.0 AvbOps alloc/initialisation/free * ============================================================================ @@ -722,7 +753,7 @@ AvbOps *avb_ops_alloc(int boot_device) ops_data->ops.read_is_device_unlocked = read_is_device_unlocked; ops_data->ops.get_unique_guid_for_partition = get_unique_guid_for_partition; - + ops_data->ops.get_size_of_partition = get_size_of_partition; ops_data->mmc_dev = boot_device; return &ops_data->ops; |