summaryrefslogtreecommitdiff
path: root/cgpt
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 /cgpt
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>
Diffstat (limited to 'cgpt')
-rw-r--r--cgpt/cgpt_edit.c4
1 files changed, 3 insertions, 1 deletions
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);