All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH v2 1/1] avb2.0: add get_size_of_partition()
@ 2018-07-17 11:44 Igor Opaniuk
  2018-07-17 13:20 ` Andrew F. Davis
  2018-07-17 22:32 ` Eugeniu Rosca
  0 siblings, 2 replies; 3+ messages in thread
From: Igor Opaniuk @ 2018-07-17 11:44 UTC (permalink / raw)
  To: u-boot

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

Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
---

Changes for v2:
- changed the return code for the case when out_size_num_bytes is NULL
  (s/AVB_IO_RESULT_ERROR_IO/AVB_IO_RESULT_ERROR_INSUFFICIENT_SPACE/g)

 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..ab5f9aa 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
+ *      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
  * ============================================================================
@@ -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

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v2 1/1] avb2.0: add get_size_of_partition()
  2018-07-17 11:44 [U-Boot] [PATCH v2 1/1] avb2.0: add get_size_of_partition() Igor Opaniuk
@ 2018-07-17 13:20 ` Andrew F. Davis
  2018-07-17 22:32 ` Eugeniu Rosca
  1 sibling, 0 replies; 3+ messages in thread
From: Andrew F. Davis @ 2018-07-17 13:20 UTC (permalink / raw)
  To: u-boot

On 07/17/2018 06:44 AM, Igor Opaniuk 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
> 
> Signed-off-by: Igor Opaniuk <igor.opaniuk@linaro.org>
> ---
> 
> Changes for v2:
> - changed the return code for the case when out_size_num_bytes is NULL
>   (s/AVB_IO_RESULT_ERROR_IO/AVB_IO_RESULT_ERROR_INSUFFICIENT_SPACE/g)
> 
>  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..ab5f9aa 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 needs updated, other than that,

Acked-by: Andrew F. Davis <afd@ti.com>


> + *      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
>   * ============================================================================
> @@ -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;
> 

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [U-Boot] [PATCH v2 1/1] avb2.0: add get_size_of_partition()
  2018-07-17 11:44 [U-Boot] [PATCH v2 1/1] avb2.0: add get_size_of_partition() Igor Opaniuk
  2018-07-17 13:20 ` Andrew F. Davis
@ 2018-07-17 22:32 ` Eugeniu Rosca
  1 sibling, 0 replies; 3+ messages in thread
From: Eugeniu Rosca @ 2018-07-17 22:32 UTC (permalink / raw)
  To: u-boot

On Tue, Jul 17, 2018 at 02:44:17PM +0300, Igor Opaniuk wrote:
> Implement get_size_of_partition() operation,
> which is required by the latest upstream libavb [1].

FWIW, any living repository is a moving target, so there is nothing more
volatile than the "latest" state of such repository. Kind request to use
specific revision/commit next time. Thank you.

> 
> [1] https://android.googlesource.com/platform/external/avb/+/master/README.md

Best regards,
Eugeniu.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2018-07-17 22:32 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-17 11:44 [U-Boot] [PATCH v2 1/1] avb2.0: add get_size_of_partition() Igor Opaniuk
2018-07-17 13:20 ` Andrew F. Davis
2018-07-17 22:32 ` Eugeniu Rosca

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.