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 159 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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, ANY_VALID, 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 && GuidEqual(&unique_guid, &entry->unique)) || |
181 (set_type && !memcmp(&type_guid, &entry->type, sizeof(Guid)))) { | 181 (set_type && GuidEqual(&type_guid, &entry->type))) { |
182 found = 1; | 182 found = 1; |
183 } else if (set_label) { | 183 } else if (set_label) { |
184 if (CGPT_OK != UTF16ToUTF8(entry->name, | 184 if (CGPT_OK != UTF16ToUTF8(entry->name, |
185 sizeof(entry->name) / sizeof(entry->name[0]), | 185 sizeof(entry->name) / sizeof(entry->name[0]), |
186 (uint8_t *)partlabel, sizeof(partlabel))) { | 186 (uint8_t *)partlabel, sizeof(partlabel))) { |
187 Error("The label cannot be converted from UTF16, so abort.\n"); | 187 Error("The label cannot be converted from UTF16, so abort.\n"); |
188 return 0; | 188 return 0; |
189 } | 189 } |
190 if (!strncmp(label, partlabel, sizeof(partlabel))) { | 190 if (!strncmp(label, partlabel, sizeof(partlabel))) { |
191 found = 1; | 191 found = 1; |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
381 if (oneonly && hits != 1) { | 381 if (oneonly && hits != 1) { |
382 return CGPT_FAILED; | 382 return CGPT_FAILED; |
383 } | 383 } |
384 | 384 |
385 if (match_partnum) { | 385 if (match_partnum) { |
386 return CGPT_OK; | 386 return CGPT_OK; |
387 } | 387 } |
388 | 388 |
389 return CGPT_FAILED; | 389 return CGPT_FAILED; |
390 } | 390 } |
OLD | NEW |