diff options
author | Albert Chaulk <achaulk@chromium.org> | 2013-03-26 13:43:02 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-05-06 15:48:41 -0700 |
commit | fa6b35c1ffa33833b3250a6515869ccd4cb59121 (patch) | |
tree | 2de52d0da32d597818fe74015703056d80fdb770 /cgpt/cgpt_prioritize.c | |
parent | 5c9e4532b9bc45cff22f37d3556da679809a60a7 (diff) | |
download | vboot-fa6b35c1ffa33833b3250a6515869ccd4cb59121.tar.gz |
Refactor CgptAdd and CgptPrioitize to remove gpt-specific code
- Refactor cgpt_prioitize.c to completely remove gpt-specific code.
- Refactor cgpt_add.c to isolate gpt-dependence to one helper function
and the backup/restore logic
- Change several common apis to take a struct drive* rather than a GptData*,
this provides a path to cleanly implement mtd versions
BUG=chromium:221745
TEST=no functional changes, existing tests cover this
BRANCH=none
Change-Id: I27ed166aae390aa5dc83062f62939e45122edc76
Original-Change-Id: I1b0a73509efbf22411c4ae5cf044feede0a49a33
Reviewed-on: https://gerrit.chromium.org/gerrit/46548
Tested-by: Albert Chaulk <achaulk@chromium.org>
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Commit-Queue: Albert Chaulk <achaulk@chromium.org>
Reviewed-on: https://gerrit.chromium.org/gerrit/49788
Diffstat (limited to 'cgpt/cgpt_prioritize.c')
-rw-r--r-- | cgpt/cgpt_prioritize.c | 23 |
1 files changed, 7 insertions, 16 deletions
diff --git a/cgpt/cgpt_prioritize.c b/cgpt/cgpt_prioritize.c index 7cd73c0a..45023062 100644 --- a/cgpt/cgpt_prioritize.c +++ b/cgpt/cgpt_prioritize.c @@ -97,7 +97,6 @@ int CgptPrioritize(CgptPrioritizeParams *params) { int priority; int gpt_retval; - GptEntry *entry; uint32_t index; uint32_t max_part; int num_kernels; @@ -116,7 +115,7 @@ int CgptPrioritize(CgptPrioritizeParams *params) { return CGPT_FAILED; } - max_part = GetNumberOfEntries(&drive.gpt); + max_part = GetNumberOfEntries(&drive); if (params->set_partition) { if (params->set_partition < 1 || params->set_partition > max_part) { @@ -126,8 +125,7 @@ int CgptPrioritize(CgptPrioritizeParams *params) { } index = params->set_partition - 1; // it must be a kernel - entry = GetEntry(&drive.gpt, PRIMARY, index); - if (!GuidEqual(&entry->type, &guid_chromeos_kernel)) { + if (!IsKernel(&drive, PRIMARY, index)) { Error("partition %d is not a ChromeOS kernel\n", params->set_partition); goto bad; } @@ -136,8 +134,7 @@ int CgptPrioritize(CgptPrioritizeParams *params) { // How many kernel partitions do I have? num_kernels = 0; for (i = 0; i < max_part; i++) { - entry = GetEntry(&drive.gpt, PRIMARY, i); - if (GuidEqual(&entry->type, &guid_chromeos_kernel)) + if (IsKernel(&drive, PRIMARY, i)) num_kernels++; } @@ -145,11 +142,10 @@ int CgptPrioritize(CgptPrioritizeParams *params) { // Determine the current priority groups groups = NewGroupList(num_kernels); for (i = 0; i < max_part; i++) { - entry = GetEntry(&drive.gpt, PRIMARY, i); - if (!GuidEqual(&entry->type, &guid_chromeos_kernel)) + if (!IsKernel(&drive, PRIMARY, i)) continue; - priority = GetPriority(&drive.gpt, PRIMARY, i); + priority = GetPriority(&drive, PRIMARY, i); // Is this partition special? if (params->set_partition && (i+1 == params->set_partition)) { @@ -194,19 +190,14 @@ int CgptPrioritize(CgptPrioritizeParams *params) { // Now apply the ranking to the GPT for (i=0; i<groups->num_groups; i++) for (j=0; j<groups->group[i].num_parts; j++) - SetPriority(&drive.gpt, PRIMARY, + SetPriority(&drive, PRIMARY, groups->group[i].part[j], groups->group[i].priority); FreeGroups(groups); } // Write it all out - RepairEntries(&drive.gpt, MASK_PRIMARY); - RepairHeader(&drive.gpt, MASK_PRIMARY); - - drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 | - GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); - UpdateCrc(&drive.gpt); + UpdateAllEntries(&drive); return DriveClose(&drive, 1); |