summaryrefslogtreecommitdiff
path: root/cgpt
diff options
context:
space:
mode:
authorJeffy Chen <jeffy.chen@rock-chips.com>2017-02-20 21:26:58 +0800
committerchrome-bot <chrome-bot@chromium.org>2017-08-09 19:33:48 -0700
commita9dca5c04d4bfc797ff567f3d358f819c101ec2f (patch)
treefb576ec3b49d9746c8f1a01ba8f8c69d588781da /cgpt
parentca97b25a33acbec1de6a2e74ca1e9693151dd100 (diff)
downloadvboot-a9dca5c04d4bfc797ff567f3d358f819c101ec2f.tar.gz
cgpt: prioritize: Make sure all headers/entries are valid
The prioritize cmd expected primary gpt header and entries are valid. Add a validity check to guarantee that. BUG=b:35585016 TEST=Check on bob, the secondary gpt still valid after these commands: dd if=/dev/zero of=/dev/mmcblk0 bs=512 count=64 cgpt prioritize /dev/mmcblk0 Change-Id: I853e25211a46fa3ce93cef1e5169b93b0a6430a9 Signed-off-by: Jeffy Chen <jeffy.chen@rock-chips.com> Reviewed-on: https://chromium-review.googlesource.com/604814 Reviewed-by: Randall Spangler <rspangler@chromium.org> Reviewed-by: Julius Werner <jwerner@chromium.org>
Diffstat (limited to 'cgpt')
-rw-r--r--cgpt/cgpt_add.c6
-rw-r--r--cgpt/cgpt_prioritize.c5
2 files changed, 7 insertions, 4 deletions
diff --git a/cgpt/cgpt_add.c b/cgpt/cgpt_add.c
index 4e0506e9..5ac50677 100644
--- a/cgpt/cgpt_add.c
+++ b/cgpt/cgpt_add.c
@@ -138,10 +138,8 @@ static int CgptCheckAddValidity(struct drive *drive) {
return -1;
}
- if (((drive->gpt.valid_headers & MASK_BOTH) != MASK_BOTH) ||
- ((drive->gpt.valid_entries & MASK_BOTH) != MASK_BOTH)) {
- Error("one of the GPT header/entries is invalid.\n"
- "please run 'cgpt repair' before adding anything.\n");
+ if (CGPT_OK != CheckValid(drive)) {
+ Error("please run 'cgpt repair' before adding anything.\n");
return -1;
}
diff --git a/cgpt/cgpt_prioritize.c b/cgpt/cgpt_prioritize.c
index 2bfc4843..c4e812c2 100644
--- a/cgpt/cgpt_prioritize.c
+++ b/cgpt/cgpt_prioritize.c
@@ -116,6 +116,11 @@ int CgptPrioritize(CgptPrioritizeParams *params) {
return CGPT_FAILED;
}
+ if (CGPT_OK != CheckValid(&drive)) {
+ Error("please run 'cgpt repair' before reordering the priority.\n");
+ return CGPT_OK;
+ }
+
max_part = GetNumberOfEntries(&drive);
if (params->set_partition) {