| 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); | 81 GPT_MODIFIED_HEADER2 | GPT_MODIFIED_ENTRIES2); |
| 82 | 82 |
| 83 // Initialize a blank set | 83 // Initialize a blank set |
| 84 if (!zap) | 84 if (!zap) |
| 85 { | 85 { |
| 86 GptHeader *h = (GptHeader *)drive.gpt.primary_header; | 86 GptHeader *h = (GptHeader *)drive.gpt.primary_header; |
| 87 memcpy(h->signature, GPT_HEADER_SIGNATURE, GPT_HEADER_SIGNATURE_SIZE); | 87 memcpy(h->signature, GPT_HEADER_SIGNATURE, GPT_HEADER_SIGNATURE_SIZE); |
| 88 h->revision = GPT_HEADER_REVISION; | 88 h->revision = GPT_HEADER_REVISION; |
| 89 h->size = sizeof(GptHeader); | 89 h->size = sizeof(GptHeader); |
| 90 h->my_lba = 1; | 90 h->my_lba = 1; |
| 91 h->alternate_lba = drive.gpt.drive_sectors - 1; |
| 91 h->first_usable_lba = 1 + 1 + GPT_ENTRIES_SECTORS; | 92 h->first_usable_lba = 1 + 1 + GPT_ENTRIES_SECTORS; |
| 92 h->last_usable_lba = drive.gpt.drive_sectors - 1 - GPT_ENTRIES_SECTORS - 1; | 93 h->last_usable_lba = drive.gpt.drive_sectors - 1 - GPT_ENTRIES_SECTORS - 1; |
| 93 uuid_generate((uint8_t *)&h->disk_uuid); | 94 uuid_generate((uint8_t *)&h->disk_uuid); |
| 94 h->entries_lba = 2; | 95 h->entries_lba = 2; |
| 95 h->number_of_entries = 128; | 96 h->number_of_entries = 128; |
| 96 h->size_of_entry = sizeof(GptEntry); | 97 h->size_of_entry = sizeof(GptEntry); |
| 97 | 98 |
| 98 // Copy to secondary | 99 // Copy to secondary |
| 99 RepairHeader(&drive.gpt, MASK_PRIMARY); | 100 RepairHeader(&drive.gpt, MASK_PRIMARY); |
| 100 | 101 |
| 101 UpdateCrc(&drive.gpt); | 102 UpdateCrc(&drive.gpt); |
| 102 } | 103 } |
| 103 | 104 |
| 104 // Write it all out | 105 // Write it all out |
| 105 return DriveClose(&drive, 1); | 106 return DriveClose(&drive, 1); |
| 106 } | 107 } |
| OLD | NEW |