OLD | NEW |
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 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 int IsKernelEntry(const GptEntry* e) { | 112 int IsKernelEntry(const GptEntry* e) { |
113 static Guid chromeos_kernel = GPT_ENT_TYPE_CHROMEOS_KERNEL; | 113 static Guid chromeos_kernel = GPT_ENT_TYPE_CHROMEOS_KERNEL; |
114 return !Memcmp(&e->type, &chromeos_kernel, sizeof(Guid)); | 114 return !Memcmp(&e->type, &chromeos_kernel, sizeof(Guid)); |
115 } | 115 } |
116 | 116 |
117 | 117 |
118 int CheckEntries(GptEntry* entries, GptHeader* h, uint64_t drive_sectors) { | 118 int CheckEntries(GptEntry* entries, GptHeader* h, uint64_t drive_sectors) { |
119 | 119 |
120 GptEntry* entry; | 120 GptEntry* entry; |
121 uint32_t crc32; | 121 uint32_t crc32; |
122 int i; | 122 uint32_t i; |
123 | 123 |
124 /* Check CRC before examining entries. */ | 124 /* Check CRC before examining entries. */ |
125 crc32 = Crc32((const uint8_t *)entries, | 125 crc32 = Crc32((const uint8_t *)entries, |
126 h->size_of_entry * h->number_of_entries); | 126 h->size_of_entry * h->number_of_entries); |
127 if (crc32 != h->entries_crc32) | 127 if (crc32 != h->entries_crc32) |
128 return 1; | 128 return 1; |
129 | 129 |
130 /* Check all entries. */ | 130 /* Check all entries. */ |
131 for (i = 0, entry = entries; i < h->number_of_entries; i++, entry++) { | 131 for (i = 0, entry = entries; i < h->number_of_entries; i++, entry++) { |
132 GptEntry* e2; | 132 GptEntry* e2; |
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
339 e->attrs.fields.gpt_att |= (priority << CGPT_ATTRIBUTE_PRIORITY_OFFSET) & | 339 e->attrs.fields.gpt_att |= (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->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_TRIES_MASK; | 345 e->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_TRIES_MASK; |
346 e->attrs.fields.gpt_att |= (tries << CGPT_ATTRIBUTE_TRIES_OFFSET) & | 346 e->attrs.fields.gpt_att |= (tries << CGPT_ATTRIBUTE_TRIES_OFFSET) & |
347 CGPT_ATTRIBUTE_TRIES_MASK; | 347 CGPT_ATTRIBUTE_TRIES_MASK; |
348 } | 348 } |
OLD | NEW |