| 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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 244 | 244 |
| 245 if (set_begin) | 245 if (set_begin) |
| 246 entry->starting_lba = begin; | 246 entry->starting_lba = begin; |
| 247 if (set_size) | 247 if (set_size) |
| 248 entry->ending_lba = begin + size - 1; | 248 entry->ending_lba = begin + size - 1; |
| 249 if (set_type) | 249 if (set_type) |
| 250 memcpy(&entry->type, &type_guid, sizeof(Guid)); | 250 memcpy(&entry->type, &type_guid, sizeof(Guid)); |
| 251 if (set_unique) | 251 if (set_unique) |
| 252 memcpy(&entry->unique, &unique_guid, sizeof(Guid)); | 252 memcpy(&entry->unique, &unique_guid, sizeof(Guid)); |
| 253 if (label) { | 253 if (label) { |
| 254 UTF8ToUTF16((uint8_t *)label, entry->name, | 254 if (CGPT_OK != UTF8ToUTF16((uint8_t *)label, entry->name, |
| 255 sizeof(entry->name) / sizeof(entry->name[0])); | 255 sizeof(entry->name) / sizeof(entry->name[0]))) { |
| 256 Error("The label cannot be converted to UTF16.\n"); |
| 257 goto bad; |
| 258 } |
| 256 } | 259 } |
| 257 if (set_raw) { | 260 if (set_raw) { |
| 258 entry->attrs.fields.gpt_att = raw_value; | 261 entry->attrs.fields.gpt_att = raw_value; |
| 259 } else { | 262 } else { |
| 260 if (set_successful) | 263 if (set_successful) |
| 261 SetSuccessful(&drive.gpt, PRIMARY, index, successful); | 264 SetSuccessful(&drive.gpt, PRIMARY, index, successful); |
| 262 if (set_tries) | 265 if (set_tries) |
| 263 SetTries(&drive.gpt, PRIMARY, index, tries); | 266 SetTries(&drive.gpt, PRIMARY, index, tries); |
| 264 if (set_priority) | 267 if (set_priority) |
| 265 SetPriority(&drive.gpt, PRIMARY, index, priority); | 268 SetPriority(&drive.gpt, PRIMARY, index, priority); |
| 266 } | 269 } |
| 267 | 270 |
| 268 RepairEntries(&drive.gpt, MASK_PRIMARY); | 271 RepairEntries(&drive.gpt, MASK_PRIMARY); |
| 269 RepairHeader(&drive.gpt, MASK_PRIMARY); | 272 RepairHeader(&drive.gpt, MASK_PRIMARY); |
| 270 | 273 |
| 271 drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 | | 274 drive.gpt.modified |= (GPT_MODIFIED_HEADER1 | GPT_MODIFIED_ENTRIES1 | |
| 272 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); | 275 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); |
| 273 UpdateCrc(&drive.gpt); | 276 UpdateCrc(&drive.gpt); |
| 274 | 277 |
| 275 | 278 |
| 276 // Write it all out | 279 // Write it all out |
| 277 return DriveClose(&drive, 1); | 280 return DriveClose(&drive, 1); |
| 278 | 281 |
| 279 bad: | 282 bad: |
| 280 (void) DriveClose(&drive, 0); | 283 (void) DriveClose(&drive, 0); |
| 281 return CGPT_FAILED; | 284 return CGPT_FAILED; |
| 282 } | 285 } |
| OLD | NEW |