diff options
author | Albert Chaulk <achaulk@chromium.org> | 2013-06-25 11:30:46 -0700 |
---|---|---|
committer | ChromeBot <chrome-bot@google.com> | 2013-07-03 16:02:34 -0700 |
commit | 289b604f6154b118f3c47aa35b09e99a4e144814 (patch) | |
tree | 2db004eff5ba2fc4d3b80d056df970650b74a92b /cgpt/cgpt_add.c | |
parent | 7d401c5cd58ec422e239b28c334fc2e94778f565 (diff) | |
download | vboot_reference-289b604f6154b118f3c47aa35b09e99a4e144814.tar.gz |
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>
Diffstat (limited to 'cgpt/cgpt_add.c')
-rw-r--r-- | cgpt/cgpt_add.c | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/cgpt/cgpt_add.c b/cgpt/cgpt_add.c index 8332f222..e0e24b81 100644 --- a/cgpt/cgpt_add.c +++ b/cgpt/cgpt_add.c @@ -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 |