| 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 #include "cgpt.h" | 5 #include "cgpt.h" |
| 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 <string.h> | 10 #include <string.h> |
| (...skipping 27 matching lines...) Expand all Loading... |
| 38 struct drive drive; | 38 struct drive drive; |
| 39 int partition = 0; | 39 int partition = 0; |
| 40 uint64_t begin = 0; | 40 uint64_t begin = 0; |
| 41 uint64_t size = 0; | 41 uint64_t size = 0; |
| 42 Guid type_guid; | 42 Guid type_guid; |
| 43 Guid unique_guid; | 43 Guid unique_guid; |
| 44 char *label = 0; | 44 char *label = 0; |
| 45 int successful = 0; | 45 int successful = 0; |
| 46 int tries = 0; | 46 int tries = 0; |
| 47 int priority = 0; | 47 int priority = 0; |
| 48 uint64_t raw_value = 0; | 48 uint16_t raw_value = 0; |
| 49 int set_begin = 0; | 49 int set_begin = 0; |
| 50 int set_size = 0; | 50 int set_size = 0; |
| 51 int set_type = 0; | 51 int set_type = 0; |
| 52 int set_unique = 0; | 52 int set_unique = 0; |
| 53 int set_successful = 0; | 53 int set_successful = 0; |
| 54 int set_tries = 0; | 54 int set_tries = 0; |
| 55 int set_priority = 0; | 55 int set_priority = 0; |
| 56 int set_raw = 0; | 56 int set_raw = 0; |
| 57 | 57 |
| 58 int gpt_retval; | 58 int gpt_retval; |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 if (set_type) | 242 if (set_type) |
| 243 memcpy(&entry->type, &type_guid, sizeof(Guid)); | 243 memcpy(&entry->type, &type_guid, sizeof(Guid)); |
| 244 if (set_unique) | 244 if (set_unique) |
| 245 memcpy(&entry->unique, &unique_guid, sizeof(Guid)); | 245 memcpy(&entry->unique, &unique_guid, sizeof(Guid)); |
| 246 if (label) { | 246 if (label) { |
| 247 uint16_t buf[128]; | 247 uint16_t buf[128]; |
| 248 UTF8ToUTF16((uint8_t *)label, buf); | 248 UTF8ToUTF16((uint8_t *)label, buf); |
| 249 memcpy(entry->name, buf, sizeof(entry->name)); | 249 memcpy(entry->name, buf, sizeof(entry->name)); |
| 250 } | 250 } |
| 251 if (set_raw) { | 251 if (set_raw) { |
| 252 entry->attributes = raw_value; | 252 entry->attrs.fields.gpt_att = raw_value; |
| 253 } else { | 253 } else { |
| 254 if (set_successful) | 254 if (set_successful) |
| 255 SetSuccessful(&drive.gpt, PRIMARY, index, successful); | 255 SetSuccessful(&drive.gpt, PRIMARY, index, successful); |
| 256 if (set_tries) | 256 if (set_tries) |
| 257 SetTries(&drive.gpt, PRIMARY, index, tries); | 257 SetTries(&drive.gpt, PRIMARY, index, tries); |
| 258 if (set_priority) | 258 if (set_priority) |
| 259 SetPriority(&drive.gpt, PRIMARY, index, priority); | 259 SetPriority(&drive.gpt, PRIMARY, index, priority); |
| 260 } | 260 } |
| 261 | 261 |
| 262 RepairEntries(&drive.gpt, MASK_PRIMARY); | 262 RepairEntries(&drive.gpt, MASK_PRIMARY); |
| 263 RepairHeader(&drive.gpt, MASK_PRIMARY); | 263 RepairHeader(&drive.gpt, MASK_PRIMARY); |
| 264 | 264 |
| 265 drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 | | 265 drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 | |
| 266 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); | 266 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); |
| 267 UpdateCrc(&drive.gpt); | 267 UpdateCrc(&drive.gpt); |
| 268 | 268 |
| 269 | 269 |
| 270 // Write it all out | 270 // Write it all out |
| 271 return DriveClose(&drive, 1); | 271 return DriveClose(&drive, 1); |
| 272 | 272 |
| 273 bad: | 273 bad: |
| 274 (void) DriveClose(&drive, 0); | 274 (void) DriveClose(&drive, 0); |
| 275 return CGPT_FAILED; | 275 return CGPT_FAILED; |
| 276 } | 276 } |
| OLD | NEW |