
On 07/09/2018 09:52 AM, Sam Protsenko wrote:
On Mon, Jul 9, 2018 at 3:15 PM, Igor Opaniuk igor.opaniuk@linaro.org wrote:
Implement get_size_of_partition() operation, which is required by the latest upstream libavb [1].
[1] https://android.googlesource.com/platform/external/avb/+/master/README.md
I may have missed it, where in here do we need this information? I looks to be passed in on the command line for most ops. Has a new function been added?
Signed-off-by: Igor Opaniuk igor.opaniuk@linaro.org
Reviewed-by: Sam Protsenko semen.protsenko@linaro.org
common/avb_verify.c | 33 ++++++++++++++++++++++++++++++++- 1 file changed, 32 insertions(+), 1 deletion(-)
diff --git a/common/avb_verify.c b/common/avb_verify.c index f9a00f8..5eabab0 100644 --- a/common/avb_verify.c +++ b/common/avb_verify.c @@ -699,6 +699,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_IO, out_size_num_bytes is NULL
This does not seems to be the right error code for this, this implies a hardware error, maybe AVB_IO_RESULT_ERROR_INSUFFICIENT_SPACE is a better choice? 'out_size_num_bytes' is a buffer in a way (to 8 bytes)..
Andrew
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_IO;
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
- ============================================================================
@@ -721,7 +752,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;
-- 2.7.4