mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-24 02:05:01 +00:00
Implement cgptlib for MTD devices.
Defines MTD on-disk structures & API in mtdlib.h/c that closely mirrors the existing cgpt implementation. Currently, the disk structures do not contain guids or labels, and the number of available partition types and quantities are limited, exactly what we want to support should be decided before we ship this. Adds appropriate test coverage to the unit test library - either by modifying existing tests, or copying them and changing them accordingly. BUG=chromium:221745 TEST=added appropriate tests to the unittests BRANCH=none Change-Id: Iee19864498024c72229bc3c7811594fe762f52de Original-Change-Id: I031eca69d6c8e825b02bd0522d57e92b05eb191a Reviewed-on: https://gerrit.chromium.org/gerrit/46082 Tested-by: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Bill Richardson <wfrichar@chromium.org> Reviewed-by: Randall Spangler <rspangler@chromium.org> Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-on: https://gerrit.chromium.org/gerrit/48793 Reviewed-by: Albert Chaulk <achaulk@chromium.org>
This commit is contained in:
@@ -375,6 +375,27 @@ void GetCurrentKernelUniqueGuid(GptData *gpt, void *dest)
|
||||
Memcpy(dest, &e->unique, sizeof(Guid));
|
||||
}
|
||||
|
||||
void GptModified(GptData *gpt) {
|
||||
GptHeader *header = (GptHeader *)gpt->primary_header;
|
||||
|
||||
/* Update the CRCs */
|
||||
header->entries_crc32 = Crc32(gpt->primary_entries,
|
||||
header->size_of_entry *
|
||||
header->number_of_entries);
|
||||
header->header_crc32 = HeaderCrc(header);
|
||||
gpt->modified |= GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1;
|
||||
|
||||
/*
|
||||
* Use the repair function to update the other copy of the GPT. This
|
||||
* is a tad inefficient, but is much faster than the disk I/O to update
|
||||
* the GPT on disk so it doesn't matter.
|
||||
*/
|
||||
gpt->valid_headers = MASK_PRIMARY;
|
||||
gpt->valid_entries = MASK_PRIMARY;
|
||||
GptRepair(gpt);
|
||||
}
|
||||
|
||||
|
||||
const char *GptErrorText(int error_code)
|
||||
{
|
||||
switch(error_code) {
|
||||
@@ -414,6 +435,12 @@ const char *GptErrorText(int error_code)
|
||||
case GPT_ERROR_DUP_GUID:
|
||||
return "Duplicated GUID";
|
||||
|
||||
case GPT_ERROR_INVALID_FLASH_GEOMETRY:
|
||||
return "Invalid flash geometry";
|
||||
|
||||
case GPT_ERROR_NO_SUCH_ENTRY:
|
||||
return "No entry found";
|
||||
|
||||
default:
|
||||
break;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user