Chromium Code Reviews| 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 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 122 tries = GetEntryTries(e); | 122 tries = GetEntryTries(e); |
| 123 if (tries > 1) { | 123 if (tries > 1) { |
| 124 /* Still have tries left */ | 124 /* Still have tries left */ |
| 125 SetEntryTries(e, tries - 1); | 125 SetEntryTries(e, tries - 1); |
| 126 break; | 126 break; |
| 127 } | 127 } |
| 128 /* Out of tries, so drop through and mark partition bad. */ | 128 /* Out of tries, so drop through and mark partition bad. */ |
| 129 } | 129 } |
| 130 case GPT_UPDATE_ENTRY_BAD: { | 130 case GPT_UPDATE_ENTRY_BAD: { |
| 131 /* Giving up on this partition entirely. */ | 131 /* Giving up on this partition entirely. */ |
| 132 e->attrs.fields.gpt_att = previous_attr & ~( | 132 if (!GetEntrySuccessful(e)) { |
| 133 CGPT_ATTRIBUTE_SUCCESSFUL_MASK | | 133 » /* Only clear tries and priority if the successful bit is not set. */ |
| 134 CGPT_ATTRIBUTE_TRIES_MASK | | 134 » e->attrs.fields.gpt_att = previous_attr & ~( |
| 135 CGPT_ATTRIBUTE_PRIORITY_MASK); | 135 » CGPT_ATTRIBUTE_SUCCESSFUL_MASK | |
|
Bill Richardson
2010/09/07 17:24:53
You don't need to explicitly clear the Attribute b
| |
| 136 » CGPT_ATTRIBUTE_TRIES_MASK | | |
| 137 » CGPT_ATTRIBUTE_PRIORITY_MASK); | |
| 138 } | |
| 136 break; | 139 break; |
| 137 } | 140 } |
| 138 default: | 141 default: |
| 139 return GPT_ERROR_INVALID_UPDATE_TYPE; | 142 return GPT_ERROR_INVALID_UPDATE_TYPE; |
| 140 } | 143 } |
| 141 | 144 |
| 142 /* If no change to attributes, we're done */ | 145 /* If no change to attributes, we're done */ |
| 143 if (e->attrs.fields.gpt_att == previous_attr) | 146 if (e->attrs.fields.gpt_att == previous_attr) |
| 144 return GPT_SUCCESS; | 147 return GPT_SUCCESS; |
| 145 | 148 |
| 146 /* Update the CRCs */ | 149 /* Update the CRCs */ |
| 147 header->entries_crc32 = Crc32((const uint8_t *)entries, | 150 header->entries_crc32 = Crc32((const uint8_t *)entries, |
| 148 header->size_of_entry * | 151 header->size_of_entry * |
| 149 header->number_of_entries); | 152 header->number_of_entries); |
| 150 header->header_crc32 = HeaderCrc(header); | 153 header->header_crc32 = HeaderCrc(header); |
| 151 gpt->modified |= GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1; | 154 gpt->modified |= GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1; |
| 152 | 155 |
| 153 /* Use the repair function to update the other copy of the GPT. | 156 /* Use the repair function to update the other copy of the GPT. |
| 154 * This is a tad inefficient, but is much faster than the disk I/O | 157 * This is a tad inefficient, but is much faster than the disk I/O |
| 155 * to update the GPT on disk so it doesn't matter. */ | 158 * to update the GPT on disk so it doesn't matter. */ |
| 156 gpt->valid_headers = MASK_PRIMARY; | 159 gpt->valid_headers = MASK_PRIMARY; |
| 157 gpt->valid_entries = MASK_PRIMARY; | 160 gpt->valid_entries = MASK_PRIMARY; |
| 158 GptRepair(gpt); | 161 GptRepair(gpt); |
| 159 | 162 |
| 160 return GPT_SUCCESS; | 163 return GPT_SUCCESS; |
| 161 } | 164 } |
| OLD | NEW |