mirror of
https://github.com/Telecominfraproject/OpenCellular.git
synced 2025-11-26 19:25:02 +00:00
Port MTD structures to use 64-bit byte offsets instead of sectors.
As per the discussion on issue 221745 we will be using 64-bit byte offsets for the MTD partition table and converting to/from sectors internally in cgpt. Existing interfaces do not change, eg sizes are still reported in sectors, only the on-disk representation is affected. BRANCH=none BUG=chromium:221745 TEST=unit tests pass Change-Id: Id312d42783acfdabe6eb8aea11dcbd298e00a100 Reviewed-on: https://gerrit.chromium.org/gerrit/60919 Commit-Queue: Albert Chaulk <achaulk@chromium.org> Reviewed-by: Albert Chaulk <achaulk@chromium.org> Tested-by: Albert Chaulk <achaulk@chromium.org>
This commit is contained in:
@@ -103,9 +103,14 @@ static int MtdSetEntryAttributes(struct drive *drive,
|
||||
|
||||
entry = MtdGetEntry(&drive->mtd, PRIMARY, index);
|
||||
if (params->set_begin)
|
||||
entry->starting_lba = params->begin;
|
||||
if (params->set_size)
|
||||
entry->ending_lba = entry->starting_lba + params->size - 1;
|
||||
memcpy(&entry->starting_offset, ¶ms->begin, sizeof(params->begin));
|
||||
if (params->set_size) {
|
||||
uint64_t start;
|
||||
uint64_t end;
|
||||
MtdGetPartitionSize(entry, &start, NULL, NULL);
|
||||
end = start + params->size - 1;
|
||||
memcpy(&entry->ending_offset, &end, sizeof(end));
|
||||
}
|
||||
if (params->set_type)
|
||||
MtdSetEntryType(entry, LookupMtdTypeForGuid(¶ms->type_guid));
|
||||
|
||||
@@ -273,14 +278,10 @@ int CgptGetPartitionDetails(CgptAddParams *params) {
|
||||
|
||||
if(drive.is_mtd) {
|
||||
MtdDiskPartition *entry = MtdGetEntry(&drive.mtd, PRIMARY, index);
|
||||
uint64_t start_lba, end_lba;
|
||||
const Guid *guid = LookupGuidForMtdType(MtdGetEntryType(entry));
|
||||
memcpy(¶ms->type_guid, guid, sizeof(params->type_guid));
|
||||
memset(¶ms->unique_guid, 0, sizeof(params->unique_guid));
|
||||
start_lba = entry->starting_lba;
|
||||
end_lba = entry->ending_lba;
|
||||
params->begin = start_lba;
|
||||
params->size = end_lba - start_lba + 1;
|
||||
MtdGetPartitionSizeInSectors(entry, ¶ms->begin, NULL, ¶ms->size);
|
||||
params->raw_value = entry->flags;
|
||||
} else {
|
||||
// GPT-specific code
|
||||
|
||||
Reference in New Issue
Block a user