summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatt Delco <delco@google.com>2018-12-04 22:05:12 -0800
committerchrome-bot <chrome-bot@chromium.org>2018-12-06 22:06:47 -0800
commit644bb1b079bed1c2ce370aa1a80a3e943ec78a56 (patch)
tree8e8a359c935d532318980d7c7e163caa22d0152a
parent4cecb64f09db64b0ac56dbaf1f67c39ace17f7d0 (diff)
downloadvboot-644bb1b079bed1c2ce370aa1a80a3e943ec78a56.tar.gz
cgpt: enable calling CgptEdit
This change allows CgptEdit to be called via the API. Prior to this change link fails in an app that uses CgptEdit due to undefined reference. The underlying implementation wasn't checking set_unique so I've fixed that as well. BRANCH=none BUG=None TEST=Added CgptEdit(0) call to extern.c and verified that build failed. Added cgpt_edit.c to Makefile and confirmed that build is now successful. Successfully ran unit tests on both vboot_reference and the app I'm working on that calls CgptEdit (which also has a unit test for setting the drive ID). Change-Id: Ie0a46ff96406eb83d0564d3f1eac978e0565ed76 Signed-off-by: Matt Delco <delco@google.com> Reviewed-on: https://chromium-review.googlesource.com/1361948 Reviewed-by: Hung-Te Lin <hungte@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
-rw-r--r--Makefile2
-rw-r--r--cgpt/cgpt_edit.c4
-rw-r--r--host/linktest/extern.c1
3 files changed, 6 insertions, 1 deletions
diff --git a/Makefile b/Makefile
index 20f2db91..663e68fd 100644
--- a/Makefile
+++ b/Makefile
@@ -453,6 +453,7 @@ UTILLIB_SRCS = \
cgpt/cgpt_create.c \
cgpt/cgpt_add.c \
cgpt/cgpt_boot.c \
+ cgpt/cgpt_edit.c \
cgpt/cgpt_show.c \
cgpt/cgpt_repair.c \
cgpt/cgpt_prioritize.c \
@@ -496,6 +497,7 @@ HOSTLIB_SRCS = \
cgpt/cgpt_boot.c \
cgpt/cgpt_common.c \
cgpt/cgpt_create.c \
+ cgpt/cgpt_edit.c \
cgpt/cgpt_prioritize.c \
firmware/2lib/2common.c \
firmware/2lib/2crc8.c \
diff --git a/cgpt/cgpt_edit.c b/cgpt/cgpt_edit.c
index 098187f6..622819b7 100644
--- a/cgpt/cgpt_edit.c
+++ b/cgpt/cgpt_edit.c
@@ -30,7 +30,9 @@ int CgptEdit(CgptEditParams *params) {
}
h = (GptHeader *)drive.gpt.primary_header;
- memcpy(&h->disk_uuid, &params->unique_guid, sizeof(h->disk_uuid));
+ if (params->set_unique) {
+ memcpy(&h->disk_uuid, &params->unique_guid, sizeof(h->disk_uuid));
+ }
// Copy to secondary
RepairHeader(&drive.gpt, MASK_PRIMARY);
drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_HEADER2);
diff --git a/host/linktest/extern.c b/host/linktest/extern.c
index 46b5ddac..85c55a1a 100644
--- a/host/linktest/extern.c
+++ b/host/linktest/extern.c
@@ -35,6 +35,7 @@ int main(void)
CgptAdd(0);
CgptBoot(0);
CgptCreate(0);
+ CgptEdit(0);
CgptGetBootPartitionNumber(0);
CgptGetNumNonEmptyPartitions(0);
CgptGetPartitionDetails(0);