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 <errno.h> | 7 #include <errno.h> |
8 #include <fcntl.h> | 8 #include <fcntl.h> |
9 #include <getopt.h> | 9 #include <getopt.h> |
10 #include <stdio.h> | 10 #include <stdio.h> |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 gpt_retval, GptError(gpt_retval)); | 125 gpt_retval, GptError(gpt_retval)); |
126 goto done; | 126 goto done; |
127 } | 127 } |
128 | 128 |
129 if (partition > GetNumberOfEntries(&drive.gpt)) { | 129 if (partition > GetNumberOfEntries(&drive.gpt)) { |
130 Error("invalid partition number: %d\n", partition); | 130 Error("invalid partition number: %d\n", partition); |
131 goto done; | 131 goto done; |
132 } | 132 } |
133 | 133 |
134 uint32_t index = partition - 1; | 134 uint32_t index = partition - 1; |
135 GptEntry *entry = GetEntry(&drive.gpt, PRIMARY, index); | 135 GptEntry *entry = GetEntry(&drive.gpt, ANY_VALID, index); |
136 memcpy(&drive.pmbr.boot_guid, &entry->unique, sizeof(Guid)); | 136 memcpy(&drive.pmbr.boot_guid, &entry->unique, sizeof(Guid)); |
137 } | 137 } |
138 | 138 |
139 if (bootfile) { | 139 if (bootfile) { |
140 int fd = open(bootfile, O_RDONLY); | 140 int fd = open(bootfile, O_RDONLY); |
141 if (fd < 0) { | 141 if (fd < 0) { |
142 Error("Can't read %s: %s\n", bootfile, strerror(errno)); | 142 Error("Can't read %s: %s\n", bootfile, strerror(errno)); |
143 goto done; | 143 goto done; |
144 } | 144 } |
145 | 145 |
(...skipping 12 matching lines...) Expand all Loading... |
158 printf("%s\n", buf); | 158 printf("%s\n", buf); |
159 | 159 |
160 // Write it all out | 160 // Write it all out |
161 if (CGPT_OK == WritePMBR(&drive)) | 161 if (CGPT_OK == WritePMBR(&drive)) |
162 retval = 0; | 162 retval = 0; |
163 | 163 |
164 done: | 164 done: |
165 (void) DriveClose(&drive, 1); | 165 (void) DriveClose(&drive, 1); |
166 return retval; | 166 return retval; |
167 } | 167 } |
OLD | NEW |