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 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
145 for (i2 = 0, e2 = entries; i2 < h->number_of_entries; i2++, e2++) { | 145 for (i2 = 0, e2 = entries; i2 < h->number_of_entries; i2++, e2++) { |
146 if (i2 == i || IsUnusedEntry(e2)) | 146 if (i2 == i || IsUnusedEntry(e2)) |
147 continue; | 147 continue; |
148 | 148 |
149 if ((entry->starting_lba >= e2->starting_lba) && | 149 if ((entry->starting_lba >= e2->starting_lba) && |
150 (entry->starting_lba <= e2->ending_lba)) | 150 (entry->starting_lba <= e2->ending_lba)) |
151 return 1; | 151 return 1; |
152 if ((entry->ending_lba >= e2->starting_lba) && | 152 if ((entry->ending_lba >= e2->starting_lba) && |
153 (entry->ending_lba <= e2->ending_lba)) | 153 (entry->ending_lba <= e2->ending_lba)) |
154 return 1; | 154 return 1; |
| 155 |
| 156 /* UniqueGuid field must be unique. */ |
| 157 if (0 == Memcmp(&entry->unique, &e2->unique, sizeof(Guid))) |
| 158 return 1; |
155 } | 159 } |
156 } | 160 } |
157 | 161 |
158 /* Success */ | 162 /* Success */ |
159 return 0; | 163 return 0; |
160 } | 164 } |
161 | 165 |
162 | 166 |
163 /* Returns 0 if the GptHeaders are the same for all fields which don't | 167 /* Returns 0 if the GptHeaders are the same for all fields which don't |
164 * differ between the primary and secondary headers - that is, all | 168 * differ between the primary and secondary headers - that is, all |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
345 e->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_TRIES_MASK; | 349 e->attrs.fields.gpt_att &= ~CGPT_ATTRIBUTE_TRIES_MASK; |
346 e->attrs.fields.gpt_att |= (tries << CGPT_ATTRIBUTE_TRIES_OFFSET) & | 350 e->attrs.fields.gpt_att |= (tries << CGPT_ATTRIBUTE_TRIES_OFFSET) & |
347 CGPT_ATTRIBUTE_TRIES_MASK; | 351 CGPT_ATTRIBUTE_TRIES_MASK; |
348 } | 352 } |
349 | 353 |
350 void GetCurrentKernelUniqueGuid(GptData *gpt, void *dest) { | 354 void GetCurrentKernelUniqueGuid(GptData *gpt, void *dest) { |
351 GptEntry* entries = (GptEntry*)gpt->primary_entries; | 355 GptEntry* entries = (GptEntry*)gpt->primary_entries; |
352 GptEntry* e = entries + gpt->current_kernel; | 356 GptEntry* e = entries + gpt->current_kernel; |
353 Memcpy(dest, &e->unique, sizeof(Guid)); | 357 Memcpy(dest, &e->unique, sizeof(Guid)); |
354 } | 358 } |
OLD | NEW |