summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBowgo Tsai <bowgotsai@google.com>2019-06-10 13:54:30 +0530
committerAnilKumar Chimata <anilc@codeaurora.org>2019-06-18 15:57:20 +0530
commitbc52a620fe716974ca1ea1d48c804df15af766ad (patch)
treecd7ab6f51ab2483f5f061d8d714b583192152bfc
parent30cac35d19bef2d2cf01cd988c1372a404120981 (diff)
QcomModulePkg: avb: Allow system partition to be absent
On devices with dynamic partitions, 'system' partition might not exist. Therefore, we should not add root=$(ANDROID_SYSTEM_PARTUUID) in kernel cmdline and resolve it for devices without system partition. Bug: 119551429 Test: m libavb_host_unittest && ../../out/host/linux-x86/nativetest64/libavb_host_unittest/libavb_host_unittest Git-repo: https://source.codeaurora.org/quic/la/platform/external/avb Git-Commit: 5abd6bc2578968d24406d834471adfd995a0c2e9 Change-Id: I767fb1b18182663d8401cf0e8d19930d45c4b83a
-rw-r--r--QcomModulePkg/Library/avb/libavb/avb_slot_verify.c44
1 files changed, 39 insertions, 5 deletions
diff --git a/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c b/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c
index db650e094c..b410fec3d6 100644
--- a/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c
+++ b/QcomModulePkg/Library/avb/libavb/avb_slot_verify.c
@@ -1280,6 +1280,35 @@ out:
return ret;
}
+static bool has_system_partition(AvbOps* ops, const char* ab_suffix) {
+ char part_name[PART_NAME_MAX_SIZE];
+ char* system_part_name = "system";
+ char guid_buf[37];
+ AvbIOResult io_ret;
+
+ if (!avb_str_concat(part_name,
+ sizeof part_name,
+ system_part_name,
+ avb_strlen(system_part_name),
+ ab_suffix,
+ avb_strlen(ab_suffix))) {
+ avb_error("System partition name and suffix does not fit.\n");
+ return false;
+ }
+
+ io_ret = ops->get_unique_guid_for_partition(
+ ops, part_name, guid_buf, sizeof guid_buf);
+ if (io_ret == AVB_IO_RESULT_ERROR_NO_SUCH_PARTITION) {
+ avb_debug("No system partition.\n");
+ return false;
+ } else if (io_ret != AVB_IO_RESULT_OK) {
+ avb_error("Error getting unique GUID for system partition.\n");
+ return false;
+ }
+
+ return true;
+}
+
AvbSlotVerifyResult avb_slot_verify(AvbOps* ops,
const char* const* requested_partitions,
const char* ab_suffix,
@@ -1382,11 +1411,16 @@ AvbSlotVerifyResult avb_slot_verify(AvbOps* ops,
* that the system partition is mounted.
*/
avb_assert(slot_data->cmdline == NULL);
- slot_data->cmdline =
- avb_strdup("root=PARTUUID=$(ANDROID_SYSTEM_PARTUUID)");
- if (slot_data->cmdline == NULL) {
- ret = AVB_SLOT_VERIFY_RESULT_ERROR_OOM;
- goto fail;
+ // Devices with dynamic partitions won't have system partition.
+ // Instead, it has a large super partition to accommodate *.img files.
+ // See b/119551429 for details.
+ if (has_system_partition(ops, ab_suffix)) {
+ slot_data->cmdline =
+ avb_strdup("root=PARTUUID=$(ANDROID_SYSTEM_PARTUUID)");
+ if (slot_data->cmdline == NULL) {
+ ret = AVB_SLOT_VERIFY_RESULT_ERROR_OOM;
+ goto fail;
+ }
}
} else {
/* Add options - any failure in append_options() is either an