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

Side by Side Diff: cgpt/cmd_find.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 <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 153 matching lines...) Expand 10 before | Expand all | Expand 10 after
164 164
165 if (CGPT_OK != DriveOpen(filename, &drive)) 165 if (CGPT_OK != DriveOpen(filename, &drive))
166 return 0; 166 return 0;
167 167
168 if (GPT_SUCCESS != GptSanityCheck(&drive.gpt)) { 168 if (GPT_SUCCESS != GptSanityCheck(&drive.gpt)) {
169 (void) DriveClose(&drive, 0); 169 (void) DriveClose(&drive, 0);
170 return 0; 170 return 0;
171 } 171 }
172 172
173 for (i = 0; i < GetNumberOfEntries(&drive.gpt); ++i) { 173 for (i = 0; i < GetNumberOfEntries(&drive.gpt); ++i) {
174 entry = GetEntry(&drive.gpt, PRIMARY, i); 174 entry = GetEntry(&drive.gpt, ANY_VALID, i);
175 175
176 if (IsZero(&entry->type)) 176 if (IsZero(&entry->type))
177 continue; 177 continue;
178 178
179 int found = 0; 179 int found = 0;
180 if ((set_unique && !memcmp(&unique_guid, &entry->unique, sizeof(Guid))) || 180 if ((set_unique && !memcmp(&unique_guid, &entry->unique, sizeof(Guid))) ||
181 (set_type && !memcmp(&type_guid, &entry->type, sizeof(Guid)))) { 181 (set_type && !memcmp(&type_guid, &entry->type, sizeof(Guid)))) {
182 found = 1; 182 found = 1;
183 } else if (set_label) { 183 } else if (set_label) {
184 UTF16ToUTF8(entry->name, sizeof(entry->name) / sizeof(entry->name[0]), 184 UTF16ToUTF8(entry->name, sizeof(entry->name) / sizeof(entry->name[0]),
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
377 if (oneonly && hits != 1) { 377 if (oneonly && hits != 1) {
378 return CGPT_FAILED; 378 return CGPT_FAILED;
379 } 379 }
380 380
381 if (match_partnum) { 381 if (match_partnum) {
382 return CGPT_OK; 382 return CGPT_OK;
383 } 383 }
384 384
385 return CGPT_FAILED; 385 return CGPT_FAILED;
386 } 386 }
OLDNEW
« cgpt/cmd_add.c ('K') | « cgpt/cmd_boot.c ('k') | cgpt/cmd_show.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698