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

Side by Side Diff: cgpt/cmd_boot.c

Issue 5115002: Fixing the bug of CGPT when primary entry table is invalid. (Closed) Base URL: ssh://git@gitrw.chromium.org:9222/vboot_reference.git
Patch Set: Created 10 years, 1 month 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 | Annotate | Revision Log
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 #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
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
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 }
OLDNEW
« cgpt/cmd_add.c ('K') | « cgpt/cmd_add.c ('k') | cgpt/cmd_find.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698