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

Side by Side Diff: src/platform/vboot_reference/utility/cgpt/cgpt_attribute.c

Issue 2438005: Much rearranging of cgptlib. Passes all its (new) unit tests. (Closed) Base URL: ssh://gitrw.chromium.org/chromiumos
Patch Set: Pre commit 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 * Update GPT attribute bits. 5 * Update GPT attribute bits.
6 */ 6 */
7 #include <getopt.h> 7 #include <getopt.h>
8 #include <stdio.h> 8 #include <stdio.h>
9 #include <stdlib.h> 9 #include <stdlib.h>
10 #include "cgpt.h" 10 #include "cgpt.h"
11 #include "cgptlib_internal.h" 11 #include "cgptlib_internal.h"
12 #include "cgpt_tofix.h"
12 #include "utility.h" 13 #include "utility.h"
13 14
14 static struct number_range 15 static struct number_range
15 range_1_0 = {1, 0}, 16 range_1_0 = {1, 0},
16 range_15_0 = {15, 0}; 17 range_15_0 = {15, 0};
17 18
18 /* Integers to store parsed argument. */ 19 /* Integers to store parsed argument. */
19 static int help, partition, bad, successful, tries, priority; 20 static int help, partition, bad, successful, tries, priority;
20 21
21 /* The structure for getopt_long(). When you add/delete any line, please refine 22 /* The structure for getopt_long(). When you add/delete any line, please refine
(...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 printf("[ERROR] No ChromeOS kernel is found. " 120 printf("[ERROR] No ChromeOS kernel is found. "
120 "Please use --partition to specify.\n"); 121 "Please use --partition to specify.\n");
121 return CGPT_FAILED; 122 return CGPT_FAILED;
122 } else { 123 } else {
123 debug("No --partition is specified. " 124 debug("No --partition is specified. "
124 "Found the first ChromeOS kernel at index [%d].\n", 125 "Found the first ChromeOS kernel at index [%d].\n",
125 partition); 126 partition);
126 } 127 }
127 } 128 }
128 129
129 if (bad != NOT_INITED)
130 SetBad(&drive.gpt, PRIMARY, partition, bad);
131 if (successful != NOT_INITED) 130 if (successful != NOT_INITED)
132 SetSuccessful(&drive.gpt, PRIMARY, partition, successful); 131 SetSuccessful(&drive.gpt, PRIMARY, partition, successful);
133 if (tries != NOT_INITED) 132 if (tries != NOT_INITED)
134 SetTries(&drive.gpt, PRIMARY, partition, tries); 133 SetTries(&drive.gpt, PRIMARY, partition, tries);
135 if (priority != NOT_INITED) 134 if (priority != NOT_INITED)
136 SetPriority(&drive.gpt, PRIMARY, partition, priority); 135 SetPriority(&drive.gpt, PRIMARY, partition, priority);
137 136
138 /* Claims primary is good, then secondary will be overwritten. */ 137 /* Claims primary is good, then secondary will be overwritten. */
138 /* TODO: rspangler broke this during cgptlib refactoring; need to
139 * update this to match new internal APIs. */
139 RepairEntries(&drive.gpt, MASK_PRIMARY); 140 RepairEntries(&drive.gpt, MASK_PRIMARY);
140 RepairHeader(&drive.gpt, MASK_PRIMARY); 141 RepairHeader(&drive.gpt, MASK_PRIMARY);
142
141 /* Forces headers and entries are modified so that CRC32 will be re-calculated 143 /* Forces headers and entries are modified so that CRC32 will be re-calculated
142 * and headers and entries will be updated to drive. */ 144 * and headers and entries will be updated to drive. */
143 drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 | 145 drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 |
144 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); 146 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2);
145 UpdateCrc(&drive.gpt); 147 UpdateCrc(&drive.gpt);
146 DriveClose(&drive); 148 DriveClose(&drive);
147 149
148 return CGPT_OK; 150 return CGPT_OK;
149 } 151 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698