summaryrefslogtreecommitdiff
path: root/firmware/lib/cgptlib/cgptlib_internal.c
diff options
context:
space:
mode:
authorJulius Werner <jwerner@chromium.org>2016-04-19 16:55:36 -0700
committerChromeOS Commit Bot <chromeos-commit-bot@chromium.org>2016-06-21 23:51:24 +0000
commite71b164f06ee60877eadc2e8325a92c27f06f91a (patch)
tree590b7c1ed78dded67442df67c9dd7010b137e24a /firmware/lib/cgptlib/cgptlib_internal.c
parentac638a4f258b332073be2e46dbeb78ab4f35d29e (diff)
downloadvboot-e71b164f06ee60877eadc2e8325a92c27f06f91a.tar.gz
cgptlib: Add support for IGNOREME GPT signaturerelease-R51-8172.B
This patch makes cgpt aware of a special "IGNOREME" GPT header signature string that may appear in either the primary or the secondary GPT and cause cgpt (and other cgptlib clients) to completely ignore that GPT. It will continue to function correctly for all other purposes (using the data from the non-ignored GPT), but never write any data back to the ignored GPT. BRANCH=None BUG=chrome-os-partner:52595 TEST=unit tests Change-Id: I7e53542385ae9d8d24dc25b75e91f4ff4917f66f Signed-off-by: Julius Werner <jwerner@chromium.org> Reviewed-on: https://chromium-review.googlesource.com/340072 Reviewed-by: Nam Nguyen <namnguyen@google.com> (cherry picked from commit 39910d062dffcd16683e0626dac1e7064991c7e5) Reviewed-on: https://chromium-review.googlesource.com/354566 Reviewed-by: Bernie Thompson <bhthompson@chromium.org> Commit-Queue: Bernie Thompson <bhthompson@chromium.org> Tested-by: Bernie Thompson <bhthompson@chromium.org>
Diffstat (limited to 'firmware/lib/cgptlib/cgptlib_internal.c')
-rw-r--r--firmware/lib/cgptlib/cgptlib_internal.c16
1 files changed, 16 insertions, 0 deletions
diff --git a/firmware/lib/cgptlib/cgptlib_internal.c b/firmware/lib/cgptlib/cgptlib_internal.c
index 29756308..7d402dfb 100644
--- a/firmware/lib/cgptlib/cgptlib_internal.c
+++ b/firmware/lib/cgptlib/cgptlib_internal.c
@@ -245,6 +245,7 @@ int GptSanityCheck(GptData *gpt)
gpt->valid_headers = 0;
gpt->valid_entries = 0;
+ gpt->ignored = 0;
retval = CheckParameters(gpt);
if (retval != GPT_SUCCESS)
@@ -255,12 +256,18 @@ int GptSanityCheck(GptData *gpt)
gpt->gpt_drive_sectors, gpt->flags)) {
gpt->valid_headers |= MASK_PRIMARY;
goodhdr = header1;
+ } else if (header1 && !Memcmp(header1->signature,
+ GPT_HEADER_SIGNATURE_IGNORED, GPT_HEADER_SIGNATURE_SIZE)) {
+ gpt->ignored |= MASK_PRIMARY;
}
if (0 == CheckHeader(header2, 1, gpt->streaming_drive_sectors,
gpt->gpt_drive_sectors, gpt->flags)) {
gpt->valid_headers |= MASK_SECONDARY;
if (!goodhdr)
goodhdr = header2;
+ } else if (header2 && !Memcmp(header2->signature,
+ GPT_HEADER_SIGNATURE_IGNORED, GPT_HEADER_SIGNATURE_SIZE)) {
+ gpt->ignored |= MASK_SECONDARY;
}
if (!gpt->valid_headers)
@@ -309,6 +316,15 @@ int GptSanityCheck(GptData *gpt)
0 != HeaderFieldsSame(header1, header2))
gpt->valid_headers &= ~MASK_SECONDARY;
+ /*
+ * When we're ignoring a GPT, make it look in memory like the other one
+ * and pretend that everything is fine (until we try to save).
+ */
+ if (MASK_NONE != gpt->ignored) {
+ GptRepair(gpt);
+ gpt->modified = 0;
+ }
+
return GPT_SUCCESS;
}