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

Side by Side Diff: vboot_firmware/lib/cgptlib/cgptlib_internal.c

Issue 2719008: Nearly complete rewrite of cgpt tool. (Closed) Base URL: ssh://git@chromiumos-git//vboot_reference.git
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
« no previous file with comments | « utility/cgpt/cgpt_tofix.c ('k') | vboot_firmware/lib/cgptlib/include/gpt.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 if (h->revision != GPT_HEADER_REVISION) 50 if (h->revision != GPT_HEADER_REVISION)
51 return 1; 51 return 1;
52 if (h->size < MIN_SIZE_OF_HEADER || h->size > MAX_SIZE_OF_HEADER) 52 if (h->size < MIN_SIZE_OF_HEADER || h->size > MAX_SIZE_OF_HEADER)
53 return 1; 53 return 1;
54 54
55 /* Check CRC before looking at remaining fields */ 55 /* Check CRC before looking at remaining fields */
56 if (HeaderCrc(h) != h->header_crc32) 56 if (HeaderCrc(h) != h->header_crc32)
57 return 1; 57 return 1;
58 58
59 /* Reserved fields must be zero. */ 59 /* Reserved fields must be zero. */
60 if (h->reserved) 60 if (h->reserved_zero)
61 return 1; 61 return 1;
62 62
63 /* TODO: Padding must be set to zero. */ 63 /* TODO: Padding must be set to zero. */
64 64
65 /* If entry size is different than our struct, we won't be able to 65 /* If entry size is different than our struct, we won't be able to
66 * parse it. Technically, any size 2^N where N>=7 is valid. */ 66 * parse it. Technically, any size 2^N where N>=7 is valid. */
67 if (h->size_of_entry != sizeof(GptEntry)) 67 if (h->size_of_entry != sizeof(GptEntry))
68 return 1; 68 return 1;
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) ||
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
167 * my_lba 167 * my_lba
168 * alternate_lba 168 * alternate_lba
169 * entries_lba */ 169 * entries_lba */
170 int HeaderFieldsSame(GptHeader *h1, GptHeader *h2) { 170 int HeaderFieldsSame(GptHeader *h1, GptHeader *h2) {
171 if (Memcmp(h1->signature, h2->signature, sizeof(h1->signature))) 171 if (Memcmp(h1->signature, h2->signature, sizeof(h1->signature)))
172 return 1; 172 return 1;
173 if (h1->revision != h2->revision) 173 if (h1->revision != h2->revision)
174 return 1; 174 return 1;
175 if (h1->size != h2->size) 175 if (h1->size != h2->size)
176 return 1; 176 return 1;
177 if (h1->reserved != h2->reserved) 177 if (h1->reserved_zero != h2->reserved_zero)
178 return 1; 178 return 1;
179 if (h1->first_usable_lba != h2->first_usable_lba) 179 if (h1->first_usable_lba != h2->first_usable_lba)
180 return 1; 180 return 1;
181 if (h1->last_usable_lba != h2->last_usable_lba) 181 if (h1->last_usable_lba != h2->last_usable_lba)
182 return 1; 182 return 1;
183 if (Memcmp(&h1->disk_uuid, &h2->disk_uuid, sizeof(Guid))) 183 if (Memcmp(&h1->disk_uuid, &h2->disk_uuid, sizeof(Guid)))
184 return 1; 184 return 1;
185 if (h1->number_of_entries != h2->number_of_entries) 185 if (h1->number_of_entries != h2->number_of_entries)
186 return 1; 186 return 1;
187 if (h1->size_of_entry != h2->size_of_entry) 187 if (h1->size_of_entry != h2->size_of_entry)
(...skipping 151 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
« no previous file with comments | « utility/cgpt/cgpt_tofix.c ('k') | vboot_firmware/lib/cgptlib/include/gpt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698