Skip to contentSkip to conversation

avb2.0: add get_size_of_partition()

PATCH New Igor Opaniuk 4 participants 5 messages Aug 10, 2018 – Aug 13, 2018

lore
Share & tools
lore
#0 lore raw

PATCH v3 1/1 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

---

Changes for v3:
- reword commit message, added avblib repository link, that stick to specific tag
- fix get_size_of_partition() function description.

Changes for v2:
- change 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(-)
common/avb_verify.c +32 -1
index 20e35ad..82ddebc 100644
@@ -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;
Signature · 1 line
2.7.4
#1 lore raw

PATCH v3 1/1 avb2.0: add get_size_of_partition()

Quoted 6 lines · Igor Opaniuk

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

Sam reviewed v1, not sure enough changed to drop his review tag, anyway for me:

Quoted 66 lines

---

Changes for v3:
- reword commit message, added avblib repository link, that stick to specific tag
- fix get_size_of_partition() function description.

Changes for v2:
- change 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(-)
common/avb_verify.c +32 -1
index 20e35ad..82ddebc 100644
@@ -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;
#2 lore raw

PATCH v3 1/1 avb2.0: add get_size_of_partition()

Sam,

Could you please double-check this patch and confirm that your tag can be still applied?

Thanks!

Quoted 80 lines · Andrew F. Davis
Quoted 6 lines · Igor Opaniuk

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

Sam reviewed v1, not sure enough changed to drop his review tag, anyway for me:

Quoted 66 lines

---

Changes for v3:
- reword commit message, added avblib repository link, that stick to specific tag
- fix get_size_of_partition() function description.

Changes for v2:
- change 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(-)
common/avb_verify.c +32 -1
index 20e35ad..82ddebc 100644
@@ -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;
Signature · 2 lines
Regards,
Igor Opaniuk
#3 lore raw

PATCH v3 1/1 avb2.0: add get_size_of_partition()

Quoted 5 lines · Igor Opaniuk

Sam,

Could you please double-check this patch and confirm that your tag can be still applied?

Sure.

Quoted 89 lines

Thanks!

Quoted 78 lines · Andrew F. Davis
Quoted 6 lines · Igor Opaniuk

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

Sam reviewed v1, not sure enough changed to drop his review tag, anyway for me:

Quoted 64 lines

---

Changes for v3:
- reword commit message, added avblib repository link, that stick to specific tag
- fix get_size_of_partition() function description.

Changes for v2:
- change 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(-)
common/avb_verify.c +32 -1
index 20e35ad..82ddebc 100644
@@ -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;
 
Quoted 2 lines

common/avb_verify.c AvbOps *avb_ops_alloc(int boot_device) · line 759

Quoted 2 lines
common/avb_verify.c +0 -0
      return &ops_data->ops;

--
Regards,
Igor Opaniuk

#4 lore raw

PATCH v3 1/1 avb2.0: add get_size_of_partition()

In reply to Igor Opaniuk
Quoted 8 lines · Igor Opaniuk

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

Applied to u-boot/master, thanks!

Signature · 8 lines
Tom
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: not available
URL: <http://lists.denx.de/pipermail/u-boot/attachments/20180813/6c6ffb0e/attachment.sig>