Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1247)

Side by Side Diff: src/platform/vboot_reference/vboot_firmware/lib/cgptlib/cgptlib_internal.c

Issue 2606002: Ignore the AlternateLBA field in the GPT headers. (Closed) Base URL: ssh://git@chromiumos-git/chromeos
Patch Set: Created 10 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved. 1 /* Copyright (c) 2010 The Chromium OS Authors. All rights reserved.
2 * Use of this source code is governed by a BSD-style license that can be 2 * Use of this source code is governed by a BSD-style license that can be
3 * found in the LICENSE file. 3 * found in the LICENSE file.
4 */ 4 */
5 5
6 #include "cgptlib.h" 6 #include "cgptlib.h"
7 #include "cgptlib_internal.h" 7 #include "cgptlib_internal.h"
8 #include "crc32.h" 8 #include "crc32.h"
9 #include "gpt.h" 9 #include "gpt.h"
10 #include "utility.h" 10 #include "utility.h"
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
69 if ((h->number_of_entries < MIN_NUMBER_OF_ENTRIES) || 69 if ((h->number_of_entries < MIN_NUMBER_OF_ENTRIES) ||
70 (h->number_of_entries > MAX_NUMBER_OF_ENTRIES) || 70 (h->number_of_entries > MAX_NUMBER_OF_ENTRIES) ||
71 (h->number_of_entries * h->size_of_entry != TOTAL_ENTRIES_SIZE)) 71 (h->number_of_entries * h->size_of_entry != TOTAL_ENTRIES_SIZE))
72 return 1; 72 return 1;
73 73
74 /* Check locations for the header and its entries. The primary 74 /* Check locations for the header and its entries. The primary
75 * immediately follows the PMBR, and is followed by its entries. 75 * immediately follows the PMBR, and is followed by its entries.
76 * The secondary is at the end of the drive, preceded by its 76 * The secondary is at the end of the drive, preceded by its
77 * entries. */ 77 * entries. */
78 if (is_secondary) { 78 if (is_secondary) {
79 if ((h->my_lba != drive_sectors - 1) || (h->alternate_lba != 1)) 79 if (h->my_lba != drive_sectors - 1)
80 return 1; 80 return 1;
81 if (h->entries_lba != h->my_lba - GPT_ENTRIES_SECTORS) 81 if (h->entries_lba != h->my_lba - GPT_ENTRIES_SECTORS)
82 return 1; 82 return 1;
83 } else { 83 } else {
84 if ((h->my_lba != 1) || (h->alternate_lba != drive_sectors - 1)) 84 if (h->my_lba != 1)
85 return 1; 85 return 1;
86 if (h->entries_lba != h->my_lba + 1) 86 if (h->entries_lba != h->my_lba + 1)
87 return 1; 87 return 1;
88 } 88 }
89 89
90 /* FirstUsableLBA must be after the end of the primary GPT table 90 /* FirstUsableLBA must be after the end of the primary GPT table
91 * array. LastUsableLBA must be before the start of the secondary 91 * array. LastUsableLBA must be before the start of the secondary
92 * GPT table array. FirstUsableLBA <= LastUsableLBA. */ 92 * GPT table array. FirstUsableLBA <= LastUsableLBA. */
93 if (h->first_usable_lba < 2 + GPT_ENTRIES_SECTORS) 93 if (h->first_usable_lba < 2 + GPT_ENTRIES_SECTORS)
94 return 1; 94 return 1;
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 e->attributes |= ((uint64_t)priority << CGPT_ATTRIBUTE_PRIORITY_OFFSET) & 339 e->attributes |= ((uint64_t)priority << CGPT_ATTRIBUTE_PRIORITY_OFFSET) &
340 CGPT_ATTRIBUTE_PRIORITY_MASK; 340 CGPT_ATTRIBUTE_PRIORITY_MASK;
341 } 341 }
342 342
343 343
344 void SetEntryTries(GptEntry* e, int tries) { 344 void SetEntryTries(GptEntry* e, int tries) {
345 e->attributes &= ~CGPT_ATTRIBUTE_TRIES_MASK; 345 e->attributes &= ~CGPT_ATTRIBUTE_TRIES_MASK;
346 e->attributes |= ((uint64_t)tries << CGPT_ATTRIBUTE_TRIES_OFFSET) & 346 e->attributes |= ((uint64_t)tries << CGPT_ATTRIBUTE_TRIES_OFFSET) &
347 CGPT_ATTRIBUTE_TRIES_MASK; 347 CGPT_ATTRIBUTE_TRIES_MASK;
348 } 348 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698